File: project_file.rb

package info (click to toggle)
ruby-yajl 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,036 kB
  • sloc: ansic: 3,068; ruby: 2,619; makefile: 4; sh: 3
file content (41 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')

require 'benchmark'
require 'benchmark/memory'

describe "file projection" do
  it "projects file streams" do
    schema = {
      "forced" => nil,
      "created" => nil,
      "pusher" => {
        "name" => nil,
      },
      "repository" => {
        "name" => nil,
        "full_name" => nil,
      },
      "ref" => nil,
      "compare" => nil,
      "commits" => {
        "distinct" => nil,
        "message" => nil,
        "url" => nil,
        "id" => nil,
        "author" => {
          "username" => nil,
        }
      }
    }

    file_path = ENV['JSON_FILE']
    if file_path.nil? || file_path.empty?
      return
    end

    Benchmark.memory { |x|
      x.report("project (yajl)") { Yajl::Projector.new(File.open(file_path, 'r')).project(schema) }
      x.compare!
    }
  end
end