ffi-yajl 2.2.0-universal-java → 2.2.1-universal-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b4326cfe36fdc90c1f60e9ed14e601de6898dc5
4
- data.tar.gz: cfc7023e68822af31e4e634024fa9477064516f6
3
+ metadata.gz: 80f96b6e7e007230b2fddacded3a80394a68257c
4
+ data.tar.gz: 399e10697124eda792a662aa1c43e4764211e9f5
5
5
  SHA512:
6
- metadata.gz: e8bb555094aad2ea90b2501483ee411dee20cda9ee3ae6968660db047f6af4d4a93675860e27ca4d9dcc290100b8cc2b5291f78a9a17dd0f0d3cb6cbe5d1d52e
7
- data.tar.gz: 73f5223e85d8ac1d15951eac652f02de799034b5698e0f4a2fe04e2e0e62401175a4deff8a687f85e7ca4e303ca041bdf19c9366be212ee0b0a12119424cff78
6
+ metadata.gz: a7b3d59115395597da775029b4d96f89cf3ccf26d067b79589b42758dc2076d44025fbc9fa7bfdc4ff13e3cbe67204559b5444f09a69ffed417ce9f92d10b449
7
+ data.tar.gz: 1cf49ace03a77061306d8e8dd9fe015d1acdaa1be90c6c4100993466006512d0da49438ec63be8962f2dc916487b6a5938267122a4942c1f7a9a780961a1e4cf
data/README.md CHANGED
@@ -45,7 +45,7 @@ Ruby 1.8.7 support was dropped in 2.2.0
45
45
  Start by requiring it:
46
46
 
47
47
  ```ruby
48
- require 'ffi-yajl'
48
+ require 'ffi_yajl'
49
49
  ```
50
50
 
51
51
  You can encode and parse with class objects:
@@ -146,4 +146,3 @@ preserved and this source code has deliberately not been dual licensed under
146
146
  Chef's typical Apache License. See the
147
147
  [LICENSE](https://github.com/chef/ffi-yajl/blob/master/LICENSE) file in this
148
148
  project.
149
-
data/Rakefile CHANGED
@@ -1,20 +1,20 @@
1
- $: << File.expand_path(File.join(File.dirname( __FILE__ ), "lib"))
1
+ $LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "lib"))
2
2
 
3
3
  require 'rspec/core/rake_task'
4
4
  require 'rubygems/package_task'
5
5
  require 'rake/extensiontask'
6
6
  require 'ffi_yajl/version'
7
7
 
8
- Dir[File.expand_path("../*gemspec", __FILE__)].reverse.each do |gemspec_path|
8
+ Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
9
9
  gemspec = eval(IO.read(gemspec_path))
10
10
  Gem::PackageTask.new(gemspec).define
11
11
  end
12
12
 
13
13
  desc "Build it and ship it"
14
- task :ship => [:clean, :gem] do
14
+ task ship: [:clean, :gem] do
15
15
  sh("git tag #{FFI_Yajl::VERSION}")
16
16
  sh("git push --tags")
17
- Dir[File.expand_path("../pkg/*.gem", __FILE__)].reverse.each do |built_gem|
17
+ Dir[File.expand_path("../pkg/*.gem", __FILE__)].reverse_each do |built_gem|
18
18
  sh("gem push #{built_gem}")
19
19
  end
20
20
  end
@@ -27,7 +27,7 @@ task :clean do
27
27
  end
28
28
 
29
29
  desc "install the gem locally"
30
- task :install => [:package] do
30
+ task install: [:package] do
31
31
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
32
32
  sh %{gem install pkg/#{unix_gemspec.name}-#{unix_gemspec.version}-universal-java.gem}
33
33
  else
@@ -123,7 +123,7 @@ if RUBY_VERSION.to_f >= 1.9
123
123
  puts "rubocop gem is not installed"
124
124
  end
125
125
  else
126
- Rubocop::RakeTask.new(:rubocop) do |t|
126
+ RuboCop::RakeTask.new(:rubocop) do |t|
127
127
  t.fail_on_error = false
128
128
  end
129
129
  end
@@ -138,7 +138,7 @@ if RUBY_VERSION.to_f >= 1.9
138
138
  else
139
139
  Reek::Rake::Task.new(:reek) do |t|
140
140
  t.fail_on_error = false
141
- # t.config_files = '.reek.yml'
141
+ # t.config_files = '.reek.yml'
142
142
  end
143
143
  end
144
144
  end
@@ -161,14 +161,13 @@ else
161
161
  end
162
162
  end
163
163
 
164
-
165
164
  desc 'Run all style checks'
166
- task :style => ['style:rubocop', 'style:reek']
165
+ task style: ['style:rubocop', 'style:reek']
167
166
 
168
167
  desc 'Run style + spec tests by default on travis'
169
- task :travis => ['style', 'spec']
168
+ task travis: %w{style spec}
170
169
 
171
170
  desc 'Run style, spec and test kichen on travis'
172
- task :travis_all => ['style', 'spec', 'integration:cloud']
171
+ task travis_all: ['style', 'spec', 'integration:cloud']
173
172
 
174
- task :default => ['style', 'spec', 'integration:vagrant']
173
+ task default: ['style', 'spec', 'integration:vagrant']
data/bin/ffi-yajl-bench CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
-
4
- $: << File.expand_path(File.join(File.dirname( File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ ), "../lib"))
3
+ $LOAD_PATH << File.expand_path(File.join(File.dirname( File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ ), "../lib"))
5
4
 
6
5
  require 'optparse'
7
6
  require 'ffi_yajl/benchmark'
@@ -30,8 +29,8 @@ ENV['FORCE_FFI_YAJL'] = 'ffi' if opts[:ffi]
30
29
  ENV['FORCE_FFI_YAJL'] = 'ext' if opts[:ext]
31
30
 
32
31
  if opts[:profile]
33
- FFI_Yajl::Benchmark::ParseProfileRubyProf.new().run()
32
+ FFI_Yajl::Benchmark::ParseProfileRubyProf.new.run
34
33
  else
35
- FFI_Yajl::Benchmark::Parse.new().run()
36
- FFI_Yajl::Benchmark::Encode.new().run()
34
+ FFI_Yajl::Benchmark::Parse.new.run
35
+ FFI_Yajl::Benchmark::Encode.new.run
37
36
  end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Style/GlobalVars
1
2
  require 'mkmf'
2
3
  require 'rubygems'
3
4
 
@@ -362,10 +362,15 @@ void Init_encoder() {
362
362
  cYajl_Gen = rb_define_class_under(mEncoder, "YajlGen", rb_cObject);
363
363
  rb_define_method(mEncoder, "do_yajl_encode", mEncoder_do_yajl_encode, 3);
364
364
 
365
- cDate = rb_define_class("Date", rb_cObject);
366
- cTime = rb_define_class("Time", rb_cObject);
367
- cDateTime = rb_define_class("DateTime", cDate);
368
- cStringIO = rb_define_class("StringIO", rb_cData);
365
+ /* use rb_const_get instead of rb_define_class so that we don't get superclass mismatches */
366
+ ID sym_Date = rb_intern("Date");
367
+ cDate = rb_const_get(rb_cObject, sym_Date);
368
+ ID sym_Time = rb_intern("Time");
369
+ cTime = rb_const_get(rb_cObject, sym_Time);
370
+ ID sym_DateTime = rb_intern("DateTime");
371
+ cDateTime = rb_const_get(rb_cObject, sym_DateTime);
372
+ ID sym_StringIO = rb_intern("StringIO");
373
+ cStringIO = rb_const_get(rb_cObject, sym_StringIO);
369
374
 
370
375
  rb_define_method(rb_cHash, "ffi_yajl", rb_cHash_ffi_yajl, 2);
371
376
  rb_define_method(rb_cArray, "ffi_yajl", rb_cArray_ffi_yajl, 2);
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Style/GlobalVars
1
2
  require 'mkmf'
2
3
  require 'rubygems'
3
4
  require 'libyajl2'
@@ -54,7 +55,7 @@ if !windows? && !find_header('yajl/yajl_tree.h')
54
55
  dir_config('yajl', HEADER_DIRS, LIB_DIRS)
55
56
 
56
57
  # here we use find_library in order to deliberately link with -lyajl as a useful side-effect
57
- if !(find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse'))
58
+ unless find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')
58
59
  abort "libyajl2 is missing. please install libyajl2"
59
60
  end
60
61
  end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Style/GlobalVars
1
2
  require 'mkmf'
2
3
  require 'rubygems'
3
4
  require 'libyajl2'
@@ -54,7 +55,7 @@ if !windows? && !find_header('yajl/yajl_tree.h')
54
55
  dir_config('yajl', HEADER_DIRS, LIB_DIRS)
55
56
 
56
57
  # here we use find_library in order to deliberately link with -lyajl as a useful side-effect
57
- if !(find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse'))
58
+ unless find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')
58
59
  abort "libyajl2 is missing. please install libyajl2"
59
60
  end
60
61
  end
@@ -184,6 +184,7 @@ static VALUE mParser_do_yajl_parse(VALUE self, VALUE str, VALUE yajl_opts) {
184
184
  unsigned char *err;
185
185
  volatile CTX ctx;
186
186
 
187
+ rb_ivar_set(self, rb_intern("key"), Qnil);
187
188
  rb_ivar_set(self, rb_intern("stack"), rb_ary_new());
188
189
  rb_ivar_set(self, rb_intern("key_stack"), rb_ary_new());
189
190
 
@@ -25,4 +25,3 @@ require 'ffi_yajl/benchmark/encode_profile.rb'
25
25
  require 'ffi_yajl/benchmark/parse.rb'
26
26
  require 'ffi_yajl/benchmark/parse_profile.rb'
27
27
  require 'ffi_yajl/benchmark/parse_profile_ruby_prof.rb'
28
-
@@ -5,14 +5,10 @@ require 'rubygems'
5
5
  require 'benchmark'
6
6
  require 'stringio'
7
7
  if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
8
- if ENV['FORCE_FFI_YAJL'] != 'ext'
9
- begin
10
- require 'yajl'
11
- rescue Exception
12
- puts "INFO: yajl-ruby not installed"
13
- end
14
- else
15
- puts "INFO: skipping yajl-ruby because we're using the C extension"
8
+ begin
9
+ require 'yajl'
10
+ rescue LoadError
11
+ puts "INFO: yajl-ruby not installed"
16
12
  end
17
13
  else
18
14
  puts "INFO: skipping yajl-ruby on jruby"
@@ -20,121 +16,67 @@ end
20
16
  require 'ffi_yajl'
21
17
  begin
22
18
  require 'json'
23
- rescue Exception
19
+ rescue LoadError
24
20
  puts "INFO: json gem not installed"
25
21
  end
26
- begin
27
- require 'psych'
28
- rescue Exception
29
- puts "INFO: psych gem not installed"
30
- end
31
- begin
32
- require 'active_support'
33
- rescue Exception
34
- puts "INFO: active_support gem not installed"
35
- end
36
22
  begin
37
23
  require 'oj'
38
- rescue Exception
24
+ rescue LoadError
39
25
  puts "INFO: oj gem not installed"
40
26
  end
41
27
 
42
28
  module FFI_Yajl
43
29
  class Benchmark
44
30
  class Encode
45
-
46
31
  def run
47
- #filename = ARGV[0] || 'benchmark/subjects/ohai.json'
32
+ # filename = ARGV[0] || 'benchmark/subjects/ohai.json'
48
33
  filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json"))
49
34
  hash = File.open(filename, 'rb') { |f| FFI_Yajl::Parser.parse(f.read) }
50
35
 
51
36
  times = ARGV[1] ? ARGV[1].to_i : 1000
52
37
  puts "Starting benchmark encoding #{filename} #{times} times\n\n"
53
- ::Benchmark.bmbm { |x|
54
-
55
- x.report("FFI_Yajl::Encoder.encode (to a String)") {
56
- times.times {
57
- output = FFI_Yajl::Encoder.encode(hash)
58
- }
59
- }
38
+ ::Benchmark.bmbm do |x|
39
+ x.report("FFI_Yajl::Encoder.encode (to a String)") do
40
+ times.times { FFI_Yajl::Encoder.encode(hash) }
41
+ end
60
42
 
61
43
  ffi_string_encoder = FFI_Yajl::Encoder.new
62
- x.report("FFI_Yajl::Encoder#encode (to a String)") {
63
- times.times {
64
- output = ffi_string_encoder.encode(hash)
65
- }
66
- }
44
+ x.report("FFI_Yajl::Encoder#encode (to a String)") do
45
+ times.times { ffi_string_encoder.encode(hash) }
46
+ end
67
47
 
68
48
  if defined?(Oj)
69
- x.report("Oj.dump (to a String)") {
70
- times.times {
71
- output = Oj.dump(hash)
72
- }
73
- }
49
+ x.report("Oj.dump (to a String)") do
50
+ times.times { Oj.dump(hash) }
51
+ end
74
52
  end
75
53
 
76
54
  if defined?(Yajl::Encoder)
77
- x.report("Yajl::Encoder.encode (to a String)") {
78
- times.times {
79
- output = Yajl::Encoder.encode(hash)
80
- }
81
- }
55
+ x.report("Yajl::Encoder.encode (to a String)") do
56
+ times.times { Yajl::Encoder.encode(hash) }
57
+ end
82
58
 
83
59
  io_encoder = Yajl::Encoder.new
84
- x.report("Yajl::Encoder#encode (to an IO)") {
85
- times.times {
86
- io_encoder.encode(hash, StringIO.new)
87
- }
88
- }
60
+ x.report("Yajl::Encoder#encode (to an IO)") do
61
+ times.times { io_encoder.encode(hash, StringIO.new) }
62
+ end
89
63
 
90
64
  string_encoder = Yajl::Encoder.new
91
- x.report("Yajl::Encoder#encode (to a String)") {
92
- times.times {
93
- output = string_encoder.encode(hash)
94
- }
95
- }
65
+ x.report("Yajl::Encoder#encode (to a String)") do
66
+ times.times { string_encoder.encode(hash) }
67
+ end
96
68
  end
97
69
 
98
70
  if defined?(JSON)
99
- x.report("JSON.generate") {
100
- times.times {
101
- JSON.generate(hash)
102
- }
103
- }
104
- x.report("JSON.fast_generate") {
105
- times.times {
106
- JSON.fast_generate(hash)
107
- }
108
- }
109
- end
110
- if defined?(Psych)
111
- x.report("Psych.to_json") {
112
- times.times {
113
- Psych.to_json(hash)
114
- }
115
- }
116
- if defined?(Psych::JSON::Stream)
117
- x.report("Psych::JSON::Stream") {
118
- times.times {
119
- io = StringIO.new
120
- stream = Psych::JSON::Stream.new io
121
- stream.start
122
- stream.push hash
123
- stream.finish
124
- }
125
- }
71
+ x.report("JSON.generate") do
72
+ times.times { JSON.generate(hash) }
73
+ end
74
+ x.report("JSON.fast_generate") do
75
+ times.times { JSON.fast_generate(hash) }
126
76
  end
127
77
  end
128
- # if defined?(ActiveSupport::JSON)
129
- # x.report("ActiveSupport::JSON.encode") {
130
- # times.times {
131
- # ActiveSupport::JSON.encode(hash)
132
- # }
133
- # }
134
- # end
135
- }
78
+ end
136
79
  end
137
80
  end
138
81
  end
139
-
140
82
  end
@@ -17,26 +17,26 @@ hash = Yajl::Parser.new.parse(json)
17
17
  json.close
18
18
 
19
19
  puts "Starting benchmark encoding #{filename} #{times} times\n\n"
20
- Benchmark.bmbm { |x|
20
+ Benchmark.bmbm do |x|
21
21
  encoder = Yajl::Encoder.new
22
- x.report {
22
+ x.report do
23
23
  puts "Yajl::Encoder#encode"
24
- times.times {
24
+ times.times do
25
25
  encoder.encode(hash, StringIO.new)
26
- }
27
- }
26
+ end
27
+ end
28
28
  if defined?(JSON)
29
- x.report {
29
+ x.report do
30
30
  puts "JSON's #to_json"
31
- times.times {
31
+ times.times do
32
32
  JSON.generate(hash)
33
- }
34
- }
33
+ end
34
+ end
35
35
  end
36
- x.report {
36
+ x.report do
37
37
  puts "Marshal.dump"
38
- times.times {
38
+ times.times do
39
39
  Marshal.dump(hash)
40
- }
41
- }
42
- }
40
+ end
41
+ end
42
+ end
@@ -18,23 +18,19 @@ json.close
18
18
 
19
19
  times = ARGV[0] ? ARGV[0].to_i : 1000
20
20
  puts "Starting benchmark encoding #{filename} into JSON #{times} times\n\n"
21
- Benchmark.bmbm { |x|
21
+ Benchmark.bmbm do |x|
22
22
  encoder = Yajl::Encoder.new
23
- x.report {
23
+ x.report do
24
24
  puts "Yajl::Encoder#encode"
25
- times.times {
26
- encoder.encode(hash, StringIO.new)
27
- }
28
- }
25
+ times.times { encoder.encode(hash, StringIO.new) }
26
+ end
29
27
  if defined?(JSON)
30
- x.report {
28
+ x.report do
31
29
  puts "JSON's #to_json"
32
- times.times {
33
- JSON.generate(hash)
34
- }
35
- }
30
+ times.times { JSON.generate(hash) }
31
+ end
36
32
  end
37
- }
33
+ end
38
34
 
39
35
  # YAML Section
40
36
  filename = 'benchmark/subjects/ohai.yml'
@@ -43,11 +39,9 @@ data = YAML.load_stream(yml)
43
39
  yml.close
44
40
 
45
41
  puts "Starting benchmark encoding #{filename} into YAML #{times} times\n\n"
46
- Benchmark.bmbm { |x|
47
- x.report {
42
+ Benchmark.bmbm do |x|
43
+ x.report do
48
44
  puts "YAML.dump"
49
- times.times {
50
- YAML.dump(data, StringIO.new)
51
- }
52
- }
53
- }
45
+ times.times { YAML.dump(data, StringIO.new) }
46
+ end
47
+ end