yajl-ruby 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yajl-ruby might be problematic. Click here for more details.
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/VERSION.yml +1 -1
- data/benchmark/encode.rb +22 -12
- data/benchmark/encode_json_and_marshal.rb +11 -6
- data/benchmark/encode_json_and_yaml.rb +11 -6
- data/benchmark/parse.rb +24 -14
- data/benchmark/parse_json_and_marshal.rb +12 -7
- data/benchmark/parse_json_and_yaml.rb +12 -7
- data/benchmark/parse_stream.rb +28 -18
- data/ext/yajl_ext.c +88 -55
- data/ext/yajl_ext.h +32 -9
- data/lib/yajl/http_stream.rb +52 -3
- data/spec/http/fixtures/http.chunked.dump +11 -0
- data/spec/http/fixtures/http.html.dump +1220 -0
- data/spec/http/http_delete_spec.rb +6 -0
- data/spec/http/http_get_spec.rb +15 -0
- data/spec/http/http_post_spec.rb +31 -1
- data/spec/http/http_put_spec.rb +12 -0
- data/spec/rcov.opts +0 -1
- data/yajl-ruby.gemspec +4 -2
- metadata +4 -2
@@ -52,6 +52,12 @@ describe "Yajl HTTP DELETE request" do
|
|
52
52
|
@template_hash.should == Yajl::HttpStream.delete(@uri)
|
53
53
|
end
|
54
54
|
|
55
|
+
it "should parse a raw response using instance method" do
|
56
|
+
prepare_mock_request_dump :raw
|
57
|
+
stream = Yajl::HttpStream.new
|
58
|
+
@template_hash.should == stream.delete(@uri)
|
59
|
+
end
|
60
|
+
|
55
61
|
it "should parse a raw response and symbolize keys" do
|
56
62
|
prepare_mock_request_dump :raw
|
57
63
|
@template_hash_symbolized.should == Yajl::HttpStream.delete(@uri, :symbolize_keys => true)
|
data/spec/http/http_get_spec.rb
CHANGED
@@ -29,6 +29,7 @@ describe "Yajl HTTP GET request" do
|
|
29
29
|
|
30
30
|
@deflate = File.new(File.expand_path(File.dirname(__FILE__) + '/fixtures/http.deflate.dump'), 'r')
|
31
31
|
@gzip = File.new(File.expand_path(File.dirname(__FILE__) + '/fixtures/http.gzip.dump'), 'r')
|
32
|
+
@chunked_body = {"item"=>{"price"=>1.99, "updated_by_id"=>nil, "cached_tag_list"=>"", "name"=>"generated", "created_at"=>"2009-03-24T05:25:09Z", "cost"=>0.597, "delta"=>false, "created_by_id"=>nil, "updated_at"=>"2009-03-24T05:25:09Z", "import_tag"=>nil, "account_id"=>16, "id"=>1, "taxable"=>true, "unit"=>nil, "sku"=>"06317-0306", "company_id"=>0, "description"=>nil, "active"=>true}}
|
32
33
|
end
|
33
34
|
|
34
35
|
after(:each) do
|
@@ -57,6 +58,20 @@ describe "Yajl HTTP GET request" do
|
|
57
58
|
@template_hash_symbolized.should == Yajl::HttpStream.get(@uri, :symbolize_keys => true)
|
58
59
|
end
|
59
60
|
|
61
|
+
it "should parse a raw response using instance method" do
|
62
|
+
prepare_mock_request_dump :raw
|
63
|
+
stream = Yajl::HttpStream.new
|
64
|
+
@template_hash.should == stream.get(@uri)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should parse a chunked response using instance method" do
|
68
|
+
prepare_mock_request_dump :chunked
|
69
|
+
stream = Yajl::HttpStream.new
|
70
|
+
stream.get(@uri) do |obj|
|
71
|
+
obj.should eql(@chunked_body)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
60
75
|
if defined?(Yajl::Bzip2::StreamReader)
|
61
76
|
it "should parse a bzip2 compressed response" do
|
62
77
|
prepare_mock_request_dump :bzip2
|
data/spec/http/http_post_spec.rb
CHANGED
@@ -30,6 +30,8 @@ describe "Yajl HTTP POST request" do
|
|
30
30
|
@deflate = File.new(File.expand_path(File.dirname(__FILE__) + '/fixtures/http.deflate.dump'), 'r')
|
31
31
|
@gzip = File.new(File.expand_path(File.dirname(__FILE__) + '/fixtures/http.gzip.dump'), 'r')
|
32
32
|
@body = "blah=foo&bar=baz"
|
33
|
+
@hashed_body = {:blah => 'foo', 'bar' => 'baz'}
|
34
|
+
@chunked_body = {"item"=>{"price"=>1.99, "updated_by_id"=>nil, "cached_tag_list"=>"", "name"=>"generated", "created_at"=>"2009-03-24T05:25:09Z", "cost"=>0.597, "delta"=>false, "created_by_id"=>nil, "updated_at"=>"2009-03-24T05:25:09Z", "import_tag"=>nil, "account_id"=>16, "id"=>1, "taxable"=>true, "unit"=>nil, "sku"=>"06317-0306", "company_id"=>0, "description"=>nil, "active"=>true}}
|
33
35
|
end
|
34
36
|
|
35
37
|
after(:each) do
|
@@ -47,11 +49,22 @@ describe "Yajl HTTP POST request" do
|
|
47
49
|
@uri.should_receive(:query)
|
48
50
|
@uri.should_receive(:userinfo)
|
49
51
|
end
|
50
|
-
|
52
|
+
|
51
53
|
it "should parse a raw response" do
|
52
54
|
prepare_mock_request_dump :raw
|
53
55
|
@template_hash.should == Yajl::HttpStream.post(@uri, @body)
|
54
56
|
end
|
57
|
+
|
58
|
+
it "should parse a raw response using instance method" do
|
59
|
+
prepare_mock_request_dump :raw
|
60
|
+
stream = Yajl::HttpStream.new
|
61
|
+
@template_hash.should == stream.post(@uri, @body)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should parse a raw response with hashed body" do
|
65
|
+
prepare_mock_request_dump :raw
|
66
|
+
@template_hash.should == Yajl::HttpStream.post(@uri, @hashed_body)
|
67
|
+
end
|
55
68
|
|
56
69
|
it "should parse a raw response and symbolize keys" do
|
57
70
|
prepare_mock_request_dump :raw
|
@@ -89,4 +102,21 @@ describe "Yajl HTTP POST request" do
|
|
89
102
|
prepare_mock_request_dump :gzip
|
90
103
|
@template_hash_symbolized.should == Yajl::HttpStream.post(@uri, @body, :symbolize_keys => true)
|
91
104
|
end
|
105
|
+
|
106
|
+
it "should parse a chunked raw response" do
|
107
|
+
prepare_mock_request_dump :chunked
|
108
|
+
Yajl::HttpStream.post(@uri, @body) do |obj|
|
109
|
+
obj.should eql(@chunked_body)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should throw Exception if chunked response and no block given" do
|
114
|
+
prepare_mock_request_dump :chunked
|
115
|
+
lambda {Yajl::HttpStream.post(@uri, @body)}.should raise_error(Exception)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should throw InvalidContentType if unable to handle the MIME type" do
|
119
|
+
prepare_mock_request_dump :html
|
120
|
+
lambda {Yajl::HttpStream.post(@uri, @body)}.should raise_error(Yajl::HttpStream::InvalidContentType)
|
121
|
+
end
|
92
122
|
end
|
data/spec/http/http_put_spec.rb
CHANGED
@@ -30,6 +30,7 @@ describe "Yajl HTTP PUT request" do
|
|
30
30
|
@deflate = File.new(File.expand_path(File.dirname(__FILE__) + '/fixtures/http.deflate.dump'), 'r')
|
31
31
|
@gzip = File.new(File.expand_path(File.dirname(__FILE__) + '/fixtures/http.gzip.dump'), 'r')
|
32
32
|
@body = "blah=foo&bar=baz"
|
33
|
+
@hashed_body = {:blah => 'foo', 'bar' => 'baz'}
|
33
34
|
end
|
34
35
|
|
35
36
|
after(:each) do
|
@@ -52,6 +53,17 @@ describe "Yajl HTTP PUT request" do
|
|
52
53
|
prepare_mock_request_dump :raw
|
53
54
|
@template_hash.should == Yajl::HttpStream.put(@uri, @body)
|
54
55
|
end
|
56
|
+
|
57
|
+
it "should parse a raw response using instance method" do
|
58
|
+
prepare_mock_request_dump :raw
|
59
|
+
stream = Yajl::HttpStream.new
|
60
|
+
@template_hash.should == stream.put(@uri, @body)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should parse a raw response with hashed body" do
|
64
|
+
prepare_mock_request_dump :raw
|
65
|
+
@template_hash.should == Yajl::HttpStream.post(@uri, @hashed_body)
|
66
|
+
end
|
55
67
|
|
56
68
|
it "should parse a raw response and symbolize keys" do
|
57
69
|
prepare_mock_request_dump :raw
|
data/spec/rcov.opts
CHANGED
data/yajl-ruby.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{yajl-ruby}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Lopez", "Lloyd Hilaiel"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-12-01}
|
13
13
|
s.email = %q{seniorlopez@gmail.com}
|
14
14
|
s.extensions = ["ext/extconf.rb"]
|
15
15
|
s.extra_rdoc_files = [
|
@@ -81,8 +81,10 @@ Gem::Specification.new do |s|
|
|
81
81
|
"spec/encoding/encoding_spec.rb",
|
82
82
|
"spec/global/global_spec.rb",
|
83
83
|
"spec/http/fixtures/http.bzip2.dump",
|
84
|
+
"spec/http/fixtures/http.chunked.dump",
|
84
85
|
"spec/http/fixtures/http.deflate.dump",
|
85
86
|
"spec/http/fixtures/http.gzip.dump",
|
87
|
+
"spec/http/fixtures/http.html.dump",
|
86
88
|
"spec/http/fixtures/http.raw.dump",
|
87
89
|
"spec/http/http_delete_spec.rb",
|
88
90
|
"spec/http/http_get_spec.rb",
|
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: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Lopez
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-12-01 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -88,8 +88,10 @@ files:
|
|
88
88
|
- spec/encoding/encoding_spec.rb
|
89
89
|
- spec/global/global_spec.rb
|
90
90
|
- spec/http/fixtures/http.bzip2.dump
|
91
|
+
- spec/http/fixtures/http.chunked.dump
|
91
92
|
- spec/http/fixtures/http.deflate.dump
|
92
93
|
- spec/http/fixtures/http.gzip.dump
|
94
|
+
- spec/http/fixtures/http.html.dump
|
93
95
|
- spec/http/fixtures/http.raw.dump
|
94
96
|
- spec/http/http_delete_spec.rb
|
95
97
|
- spec/http/http_get_spec.rb
|