ffi-yajl 2.2.3 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -73
- data/Rakefile +55 -95
- data/bin/ffi-yajl-bench +7 -7
- data/ext/ffi_yajl/ext/dlopen/extconf.rb +5 -5
- data/ext/ffi_yajl/ext/encoder/encoder.c +4 -0
- data/ext/ffi_yajl/ext/encoder/extconf.rb +12 -12
- data/ext/ffi_yajl/ext/parser/extconf.rb +12 -12
- data/lib/ffi_yajl/benchmark/encode.rb +8 -8
- data/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb +9 -9
- data/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb +11 -11
- data/lib/ffi_yajl/benchmark/encode_profile.rb +5 -5
- data/lib/ffi_yajl/benchmark/http.rb +12 -12
- data/lib/ffi_yajl/benchmark/parse.rb +8 -8
- data/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb +10 -10
- data/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb +11 -11
- data/lib/ffi_yajl/benchmark/parse_profile.rb +5 -5
- data/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb +4 -4
- data/lib/ffi_yajl/benchmark/parse_stream.rb +9 -9
- data/lib/ffi_yajl/benchmark.rb +5 -5
- data/lib/ffi_yajl/encoder.rb +2 -2
- data/lib/ffi_yajl/ext.rb +9 -9
- data/lib/ffi_yajl/ffi/encoder.rb +9 -27
- data/lib/ffi_yajl/ffi/parser.rb +5 -5
- data/lib/ffi_yajl/ffi.rb +8 -8
- data/lib/ffi_yajl/map_library_name.rb +3 -3
- data/lib/ffi_yajl/parser.rb +2 -2
- data/lib/ffi_yajl/version.rb +2 -2
- data/lib/ffi_yajl.rb +7 -7
- data/spec/ffi_yajl/encoder_spec.rb +10 -10
- data/spec/ffi_yajl/map_library_name_spec.rb +2 -2
- data/spec/ffi_yajl/parser_spec.rb +7 -7
- data/spec/spec_helper.rb +4 -4
- metadata +15 -15
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
|
|
24
|
-
require
|
|
25
|
-
require
|
|
24
|
+
require "spec_helper"
|
|
25
|
+
require "date"
|
|
26
26
|
|
|
27
27
|
describe "FFI_Yajl::Encoder" do
|
|
28
28
|
let(:options) { {} }
|
|
@@ -30,7 +30,7 @@ describe "FFI_Yajl::Encoder" do
|
|
|
30
30
|
let(:encoder) { FFI_Yajl::Encoder.new(options) }
|
|
31
31
|
|
|
32
32
|
it "encodes hashes in keys as strings", ruby_gte_193: true do
|
|
33
|
-
ruby = { {
|
|
33
|
+
ruby = { { "a" => "b" } => 2 }
|
|
34
34
|
expect(encoder.encode(ruby)).to eq('{"{\"a\"=>\"b\"}":2}')
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -126,23 +126,23 @@ describe "FFI_Yajl::Encoder" do
|
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
it "can encode Date objects" do
|
|
129
|
-
ruby = Date.parse(
|
|
129
|
+
ruby = Date.parse("2001-02-03")
|
|
130
130
|
expect(encoder.encode(ruby)).to eq( '"2001-02-03"' )
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
it "can encode StringIOs" do
|
|
134
|
-
ruby = { "foo" => StringIO.new(
|
|
134
|
+
ruby = { "foo" => StringIO.new("THING") }
|
|
135
135
|
expect(encoder.encode(ruby)).to eq("{\"foo\":\"THING\"}")
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
context "when encoding Time objects in UTC timezone" do
|
|
139
139
|
before do
|
|
140
|
-
@saved_tz = ENV[
|
|
141
|
-
ENV[
|
|
140
|
+
@saved_tz = ENV["TZ"]
|
|
141
|
+
ENV["TZ"] = "UTC"
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
after do
|
|
145
|
-
ENV[
|
|
145
|
+
ENV["TZ"] = @saved_tz
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
it "encodes them correctly" do
|
|
@@ -152,7 +152,7 @@ describe "FFI_Yajl::Encoder" do
|
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
it "can encode DateTime objects" do
|
|
155
|
-
ruby = DateTime.parse(
|
|
155
|
+
ruby = DateTime.parse("2001-02-03T04:05:06.1+07:00")
|
|
156
156
|
expect(encoder.encode(ruby)).to eq( '"2001-02-03T04:05:06+07:00"' )
|
|
157
157
|
end
|
|
158
158
|
|
|
@@ -191,7 +191,7 @@ describe "FFI_Yajl::Encoder" do
|
|
|
191
191
|
end
|
|
192
192
|
|
|
193
193
|
context "when validate_utf8 is off" do
|
|
194
|
-
let(:options) {
|
|
194
|
+
let(:options) { { validate_utf8: false } }
|
|
195
195
|
|
|
196
196
|
it "does not raise an error" do
|
|
197
197
|
expect { encoder.encode(ruby) }.not_to raise_error
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
|
|
23
|
-
require
|
|
23
|
+
require "spec_helper"
|
|
24
24
|
|
|
25
25
|
class Test
|
|
26
26
|
extend FFI_Yajl::MapLibraryName
|
|
@@ -107,7 +107,7 @@ describe "FFI_Yajl::MapLibraryName" do
|
|
|
107
107
|
allow(File).to receive(:file?).with(path).and_return(true)
|
|
108
108
|
allow(Test).to receive(:ffi_lib).with(path).and_raise(LoadError)
|
|
109
109
|
end
|
|
110
|
-
allow(Test).to receive(:ffi_lib).with(
|
|
110
|
+
allow(Test).to receive(:ffi_lib).with("yajl").and_return(nil)
|
|
111
111
|
Test.send(:ffi_open_yajl_library)
|
|
112
112
|
end
|
|
113
113
|
end
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
|
|
24
|
-
require
|
|
24
|
+
require "spec_helper"
|
|
25
25
|
|
|
26
26
|
describe "FFI_Yajl::Parser" do
|
|
27
27
|
shared_examples_for "correct json parsing" do
|
|
28
28
|
context "when json has 23456789012E666" do
|
|
29
|
-
let(:json) {
|
|
29
|
+
let(:json) { '{"key": 23456789012E666}' }
|
|
30
30
|
|
|
31
31
|
it "should return infinity" do
|
|
32
32
|
infinity = (1.0 / 0)
|
|
@@ -271,10 +271,10 @@ describe "FFI_Yajl::Parser" do
|
|
|
271
271
|
Encoding.default_internal = @saved_encoding
|
|
272
272
|
end
|
|
273
273
|
it "encodes keys to UTF-8" do
|
|
274
|
-
expect(parser.keys.first.encoding).to eql(Encoding.find(
|
|
274
|
+
expect(parser.keys.first.encoding).to eql(Encoding.find("utf-8"))
|
|
275
275
|
end
|
|
276
276
|
it "encodes values to UTF-8" do
|
|
277
|
-
expect(parser.values.first.encoding).to eql(Encoding.find(
|
|
277
|
+
expect(parser.values.first.encoding).to eql(Encoding.find("utf-8"))
|
|
278
278
|
end
|
|
279
279
|
end
|
|
280
280
|
|
|
@@ -349,7 +349,7 @@ describe "FFI_Yajl::Parser" do
|
|
|
349
349
|
# NOTE: we are choosing to be compatible with yajl-ruby here vs. JSON
|
|
350
350
|
# gem and libyajl C behavior (which is to throw an exception in this case)
|
|
351
351
|
context "when the JSON is empty string" do
|
|
352
|
-
let(:json) {
|
|
352
|
+
let(:json) { "" }
|
|
353
353
|
|
|
354
354
|
it "returns nil" do
|
|
355
355
|
expect(parser).to be_nil
|
|
@@ -475,7 +475,7 @@ describe "FFI_Yajl::Parser" do
|
|
|
475
475
|
# NOTE: parsing floats with 8 million digits on windows has some kind of huge
|
|
476
476
|
# perf issues likely in ruby and/or the underlying windows libs
|
|
477
477
|
context "when parsing big floats", ruby_gte_193: true, unix_only: true do
|
|
478
|
-
let(:json) {
|
|
478
|
+
let(:json) { "[0." + "1" * 2**23 + "]" }
|
|
479
479
|
|
|
480
480
|
it "parses" do
|
|
481
481
|
expect { parser }.not_to raise_error
|
|
@@ -483,7 +483,7 @@ describe "FFI_Yajl::Parser" do
|
|
|
483
483
|
end
|
|
484
484
|
|
|
485
485
|
context "when parsing long hash keys with symbolize_keys option", ruby_gte_193: true do
|
|
486
|
-
let(:json) { '{"' +
|
|
486
|
+
let(:json) { '{"' + "a" * 2**23 + '": 0}' }
|
|
487
487
|
let(:options) { { symbolize_keys: true } }
|
|
488
488
|
|
|
489
489
|
it "parses" do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -26,18 +26,18 @@ $LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "../lib"))
|
|
|
26
26
|
# linked in the same process). this should work, see:
|
|
27
27
|
# http://stackoverflow.com/questions/3232822/linking-with-multiple-versions-of-a-library
|
|
28
28
|
begin
|
|
29
|
-
require
|
|
29
|
+
require "yajl"
|
|
30
30
|
rescue LoadError
|
|
31
|
-
puts
|
|
31
|
+
puts "WARN: yajl cannot be loaded, expected if this is jruby"
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
require
|
|
34
|
+
require "ffi_yajl"
|
|
35
35
|
|
|
36
36
|
RSpec.configure do |conf|
|
|
37
37
|
conf.filter_run_excluding unix_only: true unless RUBY_PLATFORM !~ /mswin|mingw|windows/
|
|
38
38
|
conf.filter_run_excluding ruby_gte_193: true unless RUBY_VERSION.to_f >= 2.0 || RUBY_VERSION =~ /^1\.9\.3/
|
|
39
39
|
|
|
40
|
-
conf.order =
|
|
40
|
+
conf.order = "random"
|
|
41
41
|
|
|
42
42
|
conf.expect_with :rspec do |rspec|
|
|
43
43
|
rspec.syntax = :expect
|
metadata
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ffi-yajl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lamont Granquist
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '10.1'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '10.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '3.0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '3.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: pry
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,28 +58,28 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0
|
|
61
|
+
version: '1.0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0
|
|
68
|
+
version: '1.0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: rack
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
75
|
+
version: '2.0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
82
|
+
version: '2.0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: libyajl2
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -109,7 +109,7 @@ dependencies:
|
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '1.5'
|
|
111
111
|
description: Ruby FFI wrapper around YAJL 2.x
|
|
112
|
-
email: lamont@
|
|
112
|
+
email: lamont@chef.io
|
|
113
113
|
executables:
|
|
114
114
|
- ffi-yajl-bench
|
|
115
115
|
extensions:
|
|
@@ -167,7 +167,7 @@ files:
|
|
|
167
167
|
- spec/spec_helper.rb
|
|
168
168
|
homepage: http://github.com/chef/ffi-yajl
|
|
169
169
|
licenses:
|
|
170
|
-
-
|
|
170
|
+
- MIT
|
|
171
171
|
metadata: {}
|
|
172
172
|
post_install_message:
|
|
173
173
|
rdoc_options: []
|
|
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
177
177
|
requirements:
|
|
178
178
|
- - ">="
|
|
179
179
|
- !ruby/object:Gem::Version
|
|
180
|
-
version:
|
|
180
|
+
version: '2.2'
|
|
181
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
requirements:
|
|
183
183
|
- - ">="
|
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
185
185
|
version: '0'
|
|
186
186
|
requirements: []
|
|
187
187
|
rubyforge_project:
|
|
188
|
-
rubygems_version: 2.
|
|
188
|
+
rubygems_version: 2.6.11
|
|
189
189
|
signing_key:
|
|
190
190
|
specification_version: 4
|
|
191
191
|
summary: Ruby FFI wrapper around YAJL 2.x
|