yajl-ruby 1.2.3 → 1.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.
Potentially problematic release.
This version of yajl-ruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.codeclimate.yml +40 -0
- data/.travis.yml +4 -13
- data/LICENSE +21 -0
- data/examples/encoding/chunked_encoding.rb +1 -1
- data/examples/encoding/one_shot.rb +1 -1
- data/examples/encoding/to_an_io.rb +1 -1
- data/examples/http/twitter_search_api.rb +1 -1
- data/examples/http/twitter_stream_api.rb +1 -1
- data/examples/parsing/from_file.rb +1 -1
- data/examples/parsing/from_stdin.rb +1 -1
- data/examples/parsing/from_string.rb +1 -1
- data/lib/yajl/bzip2.rb +2 -2
- data/lib/yajl/http_stream.rb +3 -2
- data/lib/yajl/version.rb +1 -1
- data/lib/yajl.rb +2 -2
- data/spec/encoding/encoding_spec.rb +45 -45
- data/spec/global/global_spec.rb +10 -10
- data/spec/http/http_delete_spec.rb +15 -15
- data/spec/http/http_error_spec.rb +7 -8
- data/spec/http/http_get_spec.rb +17 -17
- data/spec/http/http_post_spec.rb +19 -19
- data/spec/http/http_put_spec.rb +16 -16
- data/spec/http/http_stream_options_spec.rb +4 -4
- data/spec/json_gem_compatibility/compatibility_spec.rb +70 -70
- data/spec/parsing/active_support_spec.rb +10 -10
- data/spec/parsing/chunked_spec.rb +18 -18
- data/spec/parsing/fixtures_spec.rb +8 -8
- data/spec/parsing/large_number_spec.rb +1 -1
- data/spec/parsing/one_off_spec.rb +22 -22
- data/tasks/rspec.rake +1 -1
- data/yajl-ruby.gemspec +2 -2
- metadata +6 -5
- data/MIT-LICENSE +0 -20
@@ -14,25 +14,25 @@ describe "Chunked parser" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should parse a single chunk" do
|
17
|
-
@callback.
|
17
|
+
expect(@callback).to receive(:call).with(@final)
|
18
18
|
@parser << '[{"abc": 123},{"def": 456}]'
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should parse a single chunk, 3 times" do
|
22
|
-
@callback.
|
22
|
+
expect(@callback).to receive(:call).with(@final).exactly(3).times
|
23
23
|
@parser << '[{"abc": 123},{"def": 456}]'
|
24
24
|
@parser << '[{"abc": 123},{"def": 456}]'
|
25
25
|
@parser << '[{"abc": 123},{"def": 456}]'
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should parse in two chunks" do
|
29
|
-
@callback.
|
29
|
+
expect(@callback).to receive(:call).with(@final)
|
30
30
|
@parser << '[{"abc": 123},'
|
31
31
|
@parser << '{"def": 456}]'
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should parse in 2 chunks, twice" do
|
35
|
-
@callback.
|
35
|
+
expect(@callback).to receive(:call).with(@final).exactly(2).times
|
36
36
|
@parser << '[{"abc": 123},'
|
37
37
|
@parser << '{"def": 456}]'
|
38
38
|
@parser << '[{"abc": 123},'
|
@@ -40,57 +40,57 @@ describe "Chunked parser" do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should parse 2 JSON strings, in 3 chunks" do
|
43
|
-
@callback.
|
43
|
+
expect(@callback).to receive(:call).with(@final).exactly(2).times
|
44
44
|
@parser << '[{"abc": 123},'
|
45
45
|
@parser << '{"def": 456}][{"abc": 123},{"def":'
|
46
46
|
@parser << ' 456}]'
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should parse 2 JSON strings in 1 chunk" do
|
50
|
-
@callback.
|
50
|
+
expect(@callback).to receive(:call).with(@final).exactly(2).times
|
51
51
|
@parser << '[{"abc": 123},{"def": 456}][{"abc": 123},{"def": 456}]'
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should parse 2 JSON strings from an IO" do
|
55
|
-
@callback.
|
55
|
+
expect(@callback).to receive(:call).with(@final).exactly(2).times
|
56
56
|
@parser.parse(StringIO.new('[{"abc": 123},{"def": 456}][{"abc": 123},{"def": 456}]'))
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should parse a JSON string an IO and fire callback once" do
|
60
|
-
@callback.
|
60
|
+
expect(@callback).to receive(:call).with(@final)
|
61
61
|
@parser.parse(StringIO.new('[{"abc": 123},{"def": 456}]'))
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should parse twitter_stream.json and fire callback 430 times" do
|
65
65
|
path = File.expand_path(File.dirname(__FILE__) + '/../../benchmark/subjects/twitter_stream.json')
|
66
66
|
json = File.new(path, 'r')
|
67
|
-
@callback.
|
68
|
-
|
67
|
+
expect(@callback).to receive(:call).exactly(430).times
|
68
|
+
expect {
|
69
69
|
@parser.parse(json)
|
70
|
-
}.
|
70
|
+
}.not_to raise_error
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should parse twitter_stream.json and fire callback 430 times, with a block as the callback" do
|
74
74
|
path = File.expand_path(File.dirname(__FILE__) + '/../../benchmark/subjects/twitter_stream.json')
|
75
75
|
json = File.new(path, 'r')
|
76
|
-
@callback.
|
76
|
+
expect(@callback).to receive(:call).exactly(0).times
|
77
77
|
@parser.on_parse_complete = nil
|
78
|
-
|
78
|
+
expect {
|
79
79
|
times = 0
|
80
80
|
@parser.parse(json) do |hsh|
|
81
81
|
times += 1
|
82
82
|
end
|
83
|
-
times.
|
84
|
-
}.
|
83
|
+
expect(times).to eql(430)
|
84
|
+
}.not_to raise_error
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should raise a Yajl::ParseError error if multiple JSON strings were found when no on_parse_complete callback assigned" do
|
88
88
|
path = File.expand_path(File.dirname(__FILE__) + '/../../benchmark/subjects/twitter_stream.json')
|
89
89
|
json = File.new(path, 'r')
|
90
90
|
@parser.on_parse_complete = nil
|
91
|
-
@callback.
|
92
|
-
|
91
|
+
expect(@callback).to receive(:call).exactly(0).times
|
92
|
+
expect {
|
93
93
|
@parser.parse(json)
|
94
|
-
}.
|
94
|
+
}.to raise_error(Yajl::ParseError)
|
95
95
|
end
|
96
96
|
end
|
@@ -8,33 +8,33 @@ describe "Parsing JSON Fixtures" do
|
|
8
8
|
|
9
9
|
FAILED.each do |name, source|
|
10
10
|
it "should not be able to parse #{File.basename(name)} as an IO" do
|
11
|
-
|
11
|
+
expect {
|
12
12
|
Yajl::Parser.parse(StringIO.new(source))
|
13
|
-
}.
|
13
|
+
}.to raise_error(Yajl::ParseError)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
FAILED.each do |name, source|
|
18
18
|
it "should not be able to parse #{File.basename(name)} as a string" do
|
19
|
-
|
19
|
+
expect {
|
20
20
|
Yajl::Parser.parse(source)
|
21
|
-
}.
|
21
|
+
}.to raise_error(Yajl::ParseError)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
PASSED.each do |name, source|
|
26
26
|
it "should be able to parse #{File.basename(name)} as an IO" do
|
27
|
-
|
27
|
+
expect {
|
28
28
|
Yajl::Parser.parse(StringIO.new(source))
|
29
|
-
}.
|
29
|
+
}.not_to raise_error
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
PASSED.each do |name, source|
|
34
34
|
it "should be able to parse #{File.basename(name)} as a string" do
|
35
|
-
|
35
|
+
expect {
|
36
36
|
Yajl::Parser.parse(source)
|
37
|
-
}.
|
37
|
+
}.not_to raise_error
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -12,29 +12,29 @@ describe "One-off JSON examples" do
|
|
12
12
|
it "should parse 23456789012E666 and return Infinity" do
|
13
13
|
infinity = (1.0/0)
|
14
14
|
silence_warnings do
|
15
|
-
Yajl::Parser.parse(StringIO.new('{"key": 23456789012E666}')).
|
15
|
+
expect(Yajl::Parser.parse(StringIO.new('{"key": 23456789012E666}'))).to eq({"key" => infinity})
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should not parse JSON with a comment, with :allow_comments set to false" do
|
20
20
|
json = StringIO.new('{"key": /* this is a comment */ "value"}')
|
21
|
-
|
21
|
+
expect {
|
22
22
|
Yajl::Parser.parse(json, :allow_comments => false)
|
23
|
-
}.
|
23
|
+
}.to raise_error(Yajl::ParseError)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should parse JSON with a comment, with :allow_comments set to true" do
|
27
27
|
json = StringIO.new('{"key": /* this is a comment */ "value"}')
|
28
|
-
|
28
|
+
expect {
|
29
29
|
Yajl::Parser.parse(json, :allow_comments => true)
|
30
|
-
}.
|
30
|
+
}.not_to raise_error
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should not parse invalid UTF8 with :check_utf8 set to true" do
|
34
34
|
parser = Yajl::Parser.new(:check_utf8 => true)
|
35
|
-
|
35
|
+
expect {
|
36
36
|
parser.parse("[\"#{"\201\203"}\"]")
|
37
|
-
}.
|
37
|
+
}.to raise_error(Yajl::ParseError)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should parse invalid UTF8 with :check_utf8 set to false" do
|
@@ -44,19 +44,19 @@ describe "One-off JSON examples" do
|
|
44
44
|
|
45
45
|
it "should parse using it's class method, from an IO" do
|
46
46
|
io = StringIO.new('{"key": 1234}')
|
47
|
-
Yajl::Parser.parse(io).
|
47
|
+
expect(Yajl::Parser.parse(io)).to eq({"key" => 1234})
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should parse using it's class method, from a string with symbolized keys" do
|
51
|
-
Yajl::Parser.parse('{"key": 1234}', :symbolize_keys => true).
|
51
|
+
expect(Yajl::Parser.parse('{"key": 1234}', :symbolize_keys => true)).to eq({:key => 1234})
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should parse using it's class method, from a utf-8 string with multibyte characters, with symbolized keys" do
|
55
|
-
Yajl::Parser.parse('{"日本語": 1234}', :symbolize_keys => true).
|
55
|
+
expect(Yajl::Parser.parse('{"日本語": 1234}', :symbolize_keys => true)).to eq({:"日本語" => 1234})
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should parse using it's class method, from a string" do
|
59
|
-
Yajl::Parser.parse('{"key": 1234}').
|
59
|
+
expect(Yajl::Parser.parse('{"key": 1234}')).to eq({"key" => 1234})
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should parse using it's class method, from a string with a block" do
|
@@ -64,34 +64,34 @@ describe "One-off JSON examples" do
|
|
64
64
|
Yajl::Parser.parse('{"key": 1234}') do |obj|
|
65
65
|
output = obj
|
66
66
|
end
|
67
|
-
output.
|
67
|
+
expect(output).to eq({"key" => 1234})
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should parse numbers greater than 2,147,483,648" do
|
71
|
-
Yajl::Parser.parse("{\"id\": 2147483649}").
|
72
|
-
Yajl::Parser.parse("{\"id\": 5687389800}").
|
73
|
-
Yajl::Parser.parse("{\"id\": 1046289770033519442869495707521600000000}").
|
71
|
+
expect(Yajl::Parser.parse("{\"id\": 2147483649}")).to eql({"id" => 2147483649})
|
72
|
+
expect(Yajl::Parser.parse("{\"id\": 5687389800}")).to eql({"id" => 5687389800})
|
73
|
+
expect(Yajl::Parser.parse("{\"id\": 1046289770033519442869495707521600000000}")).to eql({"id" => 1046289770033519442869495707521600000000})
|
74
74
|
end
|
75
75
|
|
76
76
|
if RUBY_VERSION =~ /^1.9/
|
77
77
|
it "should encode non-ascii symbols in utf-8" do
|
78
78
|
parsed = Yajl::Parser.parse('{"曦": 1234}', :symbolize_keys => true)
|
79
|
-
parsed.keys.fetch(0).encoding.
|
79
|
+
expect(parsed.keys.fetch(0).encoding).to eq(Encoding::UTF_8)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should return strings and hash keys in utf-8 if Encoding.default_internal is nil" do
|
83
83
|
Encoding.default_internal = nil
|
84
|
-
Yajl::Parser.parse('{"key": "value"}').keys.first.encoding.
|
85
|
-
Yajl::Parser.parse('{"key": "value"}').values.first.encoding.
|
84
|
+
expect(Yajl::Parser.parse('{"key": "value"}').keys.first.encoding).to eql(Encoding.find('utf-8'))
|
85
|
+
expect(Yajl::Parser.parse('{"key": "value"}').values.first.encoding).to eql(Encoding.find('utf-8'))
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should return strings and hash keys encoded as specified in Encoding.default_internal if it's set" do
|
89
89
|
Encoding.default_internal = Encoding.find('utf-8')
|
90
|
-
Yajl::Parser.parse('{"key": "value"}').keys.first.encoding.
|
91
|
-
Yajl::Parser.parse('{"key": "value"}').values.first.encoding.
|
90
|
+
expect(Yajl::Parser.parse('{"key": "value"}').keys.first.encoding).to eql(Encoding.default_internal)
|
91
|
+
expect(Yajl::Parser.parse('{"key": "value"}').values.first.encoding).to eql(Encoding.default_internal)
|
92
92
|
Encoding.default_internal = Encoding.find('us-ascii')
|
93
|
-
Yajl::Parser.parse('{"key": "value"}').keys.first.encoding.
|
94
|
-
Yajl::Parser.parse('{"key": "value"}').values.first.encoding.
|
93
|
+
expect(Yajl::Parser.parse('{"key": "value"}').keys.first.encoding).to eql(Encoding.default_internal)
|
94
|
+
expect(Yajl::Parser.parse('{"key": "value"}').values.first.encoding).to eql(Encoding.default_internal)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
data/tasks/rspec.rake
CHANGED
data/yajl-ruby.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.required_ruby_version = ">= 1.8.6"
|
18
18
|
|
19
19
|
# tests
|
20
|
-
s.add_development_dependency 'rake-compiler',
|
21
|
-
s.add_development_dependency 'rspec',
|
20
|
+
s.add_development_dependency 'rake-compiler', '>= 0.7.5'
|
21
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
22
22
|
# benchmarks
|
23
23
|
s.add_development_dependency 'activesupport', '~> 3.1.2'
|
24
24
|
s.add_development_dependency 'json'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yajl-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Lopez
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-11-
|
12
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '3.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '3.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: activesupport
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,12 +74,13 @@ extensions:
|
|
74
74
|
- ext/yajl/extconf.rb
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- ".codeclimate.yml"
|
77
78
|
- ".gitignore"
|
78
79
|
- ".rspec"
|
79
80
|
- ".travis.yml"
|
80
81
|
- CHANGELOG.md
|
81
82
|
- Gemfile
|
82
|
-
-
|
83
|
+
- LICENSE
|
83
84
|
- README.md
|
84
85
|
- Rakefile
|
85
86
|
- benchmark/encode.rb
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|