yajl-ruby 1.2.3 → 1.3.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96b69dbb79f06c9b9167f6a46db45696ceffcba0
4
- data.tar.gz: 2d1114946f2aead4371317dac549a662698f66a8
3
+ metadata.gz: 731d0a5e71e781ff6061f6fda922f73c773ad0ee
4
+ data.tar.gz: c3a1f37875013458989cf34988bed786d58c7c00
5
5
  SHA512:
6
- metadata.gz: be6ae35da914550194edccd71507555b97973592dbb7155f34182d08fcac4a75450eda8cabb083c67d4e6daaee6ba3c0198da6fc3aa854ed54098bc5514a3ff4
7
- data.tar.gz: 49a24d166c2adc2aa938bd3c91b3440e02e7bfaa6f9e30cd0c745c17afc6be906721391241f08d6612d3a3044d3bc4b5b1105bddfe42547430a39c2e74829814
6
+ metadata.gz: 33df12d70c43f4599438ce478755967d174ce403fddc946dd5b5ca2e76723ba064fc10bb1185513927a230bdbbf2ebe479d1666632127bfcd4afe367ea24e646
7
+ data.tar.gz: 2d78f6564a3c14a17fc55187a1951b5a5fa2b263dff0f47fd8d6d6d377727771989bdcb9b68970b5995fb53449e0d4053cffc96412820525dec184074e68225c
@@ -0,0 +1,40 @@
1
+ # This is a sample .codeclimate.yml configured for Engine analysis on Code
2
+ # Climate Platform. For an overview of the Code Climate Platform, see here:
3
+ # http://docs.codeclimate.com/article/300-the-codeclimate-platform
4
+
5
+ # Under the engines key, you can configure which engines will analyze your repo.
6
+ # Each key is an engine name. For each value, you need to specify enabled: true
7
+ # to enable the engine as well as any other engines-specific configuration.
8
+
9
+ # For more details, see here:
10
+ # http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
11
+
12
+ # For a list of all available engines, see here:
13
+ # http://docs.codeclimate.com/article/296-engines-available-engines
14
+
15
+ engines:
16
+ # to turn on an engine, add it here and set enabled to `true`
17
+ # to turn off an engine, set enabled to `false` or remove it
18
+ rubocop:
19
+ enabled: true
20
+
21
+ # Engines can analyze files and report issues on them, but you can separately
22
+ # decide which files will receive ratings based on those issues. This is
23
+ # specified by path patterns under the ratings key.
24
+
25
+ # For more details see here:
26
+ # http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
27
+
28
+ # Note: If the ratings key is not specified, this will result in a 0.0 GPA on your dashboard.
29
+
30
+ ratings:
31
+ paths:
32
+ - ext/**
33
+ - lib/**
34
+
35
+ # You can globally exclude files from being analyzed by any engine using the
36
+ # exclude_paths key.
37
+
38
+ #exclude_paths:
39
+ #- spec/**/*
40
+ #- vendor/**/*
@@ -4,15 +4,11 @@ rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - 2.1.0
8
- - 2.1.1
7
+ - 2.1
8
+ - rbx-2
9
9
  - ree
10
10
  - ruby-head
11
- - rbx-18mode
12
- - rbx-19mode
13
11
  before_install: gem install bundler --no-document
14
12
  matrix:
15
13
  allow_failures:
16
- - rvm: rbx
17
- - rvm: rbx-18mode
18
- - rvm: rbx-19mode
14
+ - rvm: rbx-2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Brian Lopez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -24,4 +24,4 @@ Yajl::Encoder.encode(obj) do |chunk|
24
24
  STDOUT << chunk
25
25
  end
26
26
 
27
- puts "\n\nEncoder generated #{total_size} bytes of data, in #{chunks} chunks"
27
+ puts "\n\nEncoder generated #{total_size} bytes of data, in #{chunks} chunks"
@@ -10,4 +10,4 @@ obj = {
10
10
  }
11
11
 
12
12
  str = Yajl::Encoder.encode(obj)
13
- puts str
13
+ puts str
@@ -9,4 +9,4 @@ obj = {
9
9
  :as_easy_as => 123
10
10
  }
11
11
 
12
- Yajl::Encoder.encode(obj, STDOUT)
12
+ Yajl::Encoder.encode(obj, STDOUT)
@@ -9,4 +9,4 @@ unless keywords = ARGV[0]
9
9
  exit(0)
10
10
  end
11
11
 
12
- puts Yajl::HttpStream.get("http://search.twitter.com/search.json?q=#{keywords}").inspect
12
+ puts Yajl::HttpStream.get("http://search.twitter.com/search.json?q=#{keywords}").inspect
@@ -23,4 +23,4 @@ Yajl::HttpStream.get(uri, :symbolize_keys => true) do |hash|
23
23
  STDOUT.putc '.'
24
24
  STDOUT.flush
25
25
  captured += 1
26
- end
26
+ end
@@ -11,4 +11,4 @@ end
11
11
  json = File.new(file, 'r')
12
12
 
13
13
  hash = Yajl::Parser.parse(json)
14
- puts hash.inspect
14
+ puts hash.inspect
@@ -6,4 +6,4 @@ require 'yajl'
6
6
  # Usage: cat benchmark/subjects/item.json | ruby examples/from_stdin.rb
7
7
 
8
8
  hash = Yajl::Parser.parse(STDIN)
9
- puts hash.inspect
9
+ puts hash.inspect
@@ -10,4 +10,4 @@ unless string = ARGV[0]
10
10
  end
11
11
 
12
12
  hash = Yajl::Parser.parse(string)
13
- puts hash.inspect
13
+ puts hash.inspect
@@ -162,8 +162,8 @@ void yajl_string_decode(yajl_buf buf, const unsigned char * str,
162
162
  end+=3;
163
163
  /* check if this is a surrogate */
164
164
  if ((codepoint & 0xFC00) == 0xD800) {
165
- if (end + 2 < len && str[end + 1] == '\\' && str[end + 2] == 'u') {
166
- end++;
165
+ end++;
166
+ if (str[end] == '\\' && str[end + 1] == 'u') {
167
167
  unsigned int surrogate = 0;
168
168
  hexToDigit(&surrogate, str + end + 2);
169
169
  codepoint =
@@ -1,7 +1,7 @@
1
1
  require 'yajl/yajl'
2
2
 
3
3
  # = Extras
4
- # We're not going to load these auotmatically, because you might not need them ;)
4
+ # We're not going to load these automatically, because you might not need them ;)
5
5
  #
6
6
  # require 'yajl/http_stream.rb' unless defined?(Yajl::HttpStream)
7
7
  # require 'yajl/gzip.rb' unless defined?(Yajl::Gzip)
@@ -73,4 +73,4 @@ module Yajl
73
73
  new(options).encode(obj, io, &block)
74
74
  end
75
75
  end
76
- end
76
+ end
@@ -1,3 +1,3 @@
1
1
  module Yajl
2
- VERSION = '1.2.3'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -37,7 +37,7 @@ describe "Yajl JSON encoder" do
37
37
  hash2 = Yajl::Parser.parse(io)
38
38
  io.close
39
39
  input.close
40
- hash.should == hash2
40
+ expect(hash).to eq(hash2)
41
41
  end
42
42
  end
43
43
  end
@@ -58,7 +58,7 @@ describe "Yajl JSON encoder" do
58
58
  Yajl::Parser.parse(reader.read)
59
59
  end
60
60
  end
61
- hash.should == hash2
61
+ expect(hash).to eq(hash2)
62
62
  end
63
63
  end
64
64
  end
@@ -73,7 +73,7 @@ describe "Yajl JSON encoder" do
73
73
  output = encoder.encode(hash)
74
74
  hash2 = Yajl::Parser.parse(output)
75
75
  input.close
76
- hash.should == hash2
76
+ expect(hash).to eq(hash2)
77
77
  end
78
78
  end
79
79
  end
@@ -91,7 +91,7 @@ describe "Yajl JSON encoder" do
91
91
  end
92
92
  hash2 = Yajl::Parser.parse(output)
93
93
  input.close
94
- hash.should == hash2
94
+ expect(hash).to eq(hash2)
95
95
  end
96
96
  end
97
97
  end
@@ -103,7 +103,7 @@ describe "Yajl JSON encoder" do
103
103
  encoder = Yajl::Encoder.new(:pretty => true, :indent => ' ')
104
104
  encoder.encode(obj, io)
105
105
  io.rewind
106
- io.read.should == output
106
+ expect(io.read).to eq(output)
107
107
  end
108
108
 
109
109
  it "should encode with :pretty turned on and a single space indent, and return a String" do
@@ -111,7 +111,7 @@ describe "Yajl JSON encoder" do
111
111
  obj = {:foo => 1234}
112
112
  encoder = Yajl::Encoder.new(:pretty => true, :indent => ' ')
113
113
  output = encoder.encode(obj)
114
- output.should == output
114
+ expect(output).to eq(output)
115
115
  end
116
116
 
117
117
  it "should encode with :pretty turned on and a tab character indent, to an IO" do
@@ -121,7 +121,7 @@ describe "Yajl JSON encoder" do
121
121
  encoder = Yajl::Encoder.new(:pretty => true, :indent => "\t")
122
122
  encoder.encode(obj, io)
123
123
  io.rewind
124
- io.read.should == output
124
+ expect(io.read).to eq(output)
125
125
  end
126
126
 
127
127
  it "should encode with :pretty turned on and a tab character indent, and return a String" do
@@ -129,7 +129,7 @@ describe "Yajl JSON encoder" do
129
129
  obj = {:foo => 1234}
130
130
  encoder = Yajl::Encoder.new(:pretty => true, :indent => "\t")
131
131
  output = encoder.encode(obj)
132
- output.should == output
132
+ expect(output).to eq(output)
133
133
  end
134
134
 
135
135
  it "should encode with it's class method with :pretty and a tab character indent options set, to an IO" do
@@ -138,14 +138,14 @@ describe "Yajl JSON encoder" do
138
138
  io = StringIO.new
139
139
  Yajl::Encoder.encode(obj, io, :pretty => true, :indent => "\t")
140
140
  io.rewind
141
- io.read.should == output
141
+ expect(io.read).to eq(output)
142
142
  end
143
143
 
144
144
  it "should encode with it's class method with :pretty and a tab character indent options set, and return a String" do
145
145
  output = "{\n\t\"foo\": 1234\n}"
146
146
  obj = {:foo => 1234}
147
147
  output = Yajl::Encoder.encode(obj, :pretty => true, :indent => "\t")
148
- output.should == output
148
+ expect(output).to eq(output)
149
149
  end
150
150
 
151
151
  it "should encode with it's class method with :pretty and a tab character indent options set, to a block" do
@@ -155,7 +155,7 @@ describe "Yajl JSON encoder" do
155
155
  Yajl::Encoder.encode(obj, :pretty => true, :indent => "\t") do |json_str|
156
156
  output = json_str
157
157
  end
158
- output.should == output
158
+ expect(output).to eq(output)
159
159
  end
160
160
 
161
161
  it "should encode multiple objects into a single stream, to an IO" do
@@ -167,7 +167,7 @@ describe "Yajl JSON encoder" do
167
167
  end
168
168
  io.rewind
169
169
  output = "{\"foo\":1234}{\"foo\":1234}{\"foo\":1234}{\"foo\":1234}{\"foo\":1234}"
170
- io.read.should == output
170
+ expect(io.read).to eq(output)
171
171
  end
172
172
 
173
173
  it "should encode multiple objects into a single stream, and return a String" do
@@ -178,37 +178,37 @@ describe "Yajl JSON encoder" do
178
178
  json_output << encoder.encode(obj)
179
179
  end
180
180
  output = "{\"foo\":1234}{\"foo\":1234}{\"foo\":1234}{\"foo\":1234}{\"foo\":1234}"
181
- json_output.should == output
181
+ expect(json_output).to eq(output)
182
182
  end
183
183
 
184
184
  it "should encode all map keys as strings" do
185
- Yajl::Encoder.encode({1=>1}).should eql("{\"1\":1}")
185
+ expect(Yajl::Encoder.encode({1=>1})).to eql("{\"1\":1}")
186
186
  end
187
187
 
188
188
  it "should check for and call #to_json if it exists on custom objects" do
189
189
  d = Dummy2.new
190
- Yajl::Encoder.encode({:foo => d}).should eql('{"foo":{"hawtness":true}}')
190
+ expect(Yajl::Encoder.encode({:foo => d})).to eql('{"foo":{"hawtness":true}}')
191
191
  end
192
192
 
193
193
  it "should encode a hash where the key and value can be symbols" do
194
- Yajl::Encoder.encode({:foo => :bar}).should eql('{"foo":"bar"}')
194
+ expect(Yajl::Encoder.encode({:foo => :bar})).to eql('{"foo":"bar"}')
195
195
  end
196
196
 
197
197
  it "should encode using a newline or nil terminator" do
198
- Yajl::Encoder.new(:terminator => "\n").encode({:foo => :bar}).should eql("{\"foo\":\"bar\"}\n")
199
- Yajl::Encoder.new(:terminator => nil).encode({:foo => :bar}).should eql("{\"foo\":\"bar\"}")
198
+ expect(Yajl::Encoder.new(:terminator => "\n").encode({:foo => :bar})).to eql("{\"foo\":\"bar\"}\n")
199
+ expect(Yajl::Encoder.new(:terminator => nil).encode({:foo => :bar})).to eql("{\"foo\":\"bar\"}")
200
200
  end
201
201
 
202
202
  it "should encode using a newline or nil terminator, to an IO" do
203
203
  s = StringIO.new
204
204
  Yajl::Encoder.new(:terminator => "\n").encode({:foo => :bar}, s)
205
205
  s.rewind
206
- s.read.should eql("{\"foo\":\"bar\"}\n")
206
+ expect(s.read).to eql("{\"foo\":\"bar\"}\n")
207
207
 
208
208
  s = StringIO.new
209
209
  Yajl::Encoder.new(:terminator => nil).encode({:foo => :bar}, s)
210
210
  s.rewind
211
- s.read.should eql("{\"foo\":\"bar\"}")
211
+ expect(s.read).to eql("{\"foo\":\"bar\"}")
212
212
  end
213
213
 
214
214
  it "should encode using a newline or nil terminator, using a block" do
@@ -217,7 +217,7 @@ describe "Yajl JSON encoder" do
217
217
  s << chunk
218
218
  end
219
219
  s.rewind
220
- s.read.should eql("{\"foo\":\"bar\"}\n")
220
+ expect(s.read).to eql("{\"foo\":\"bar\"}\n")
221
221
 
222
222
  s = StringIO.new
223
223
  nilpassed = false
@@ -225,45 +225,45 @@ describe "Yajl JSON encoder" do
225
225
  nilpassed = true if chunk.nil?
226
226
  s << chunk
227
227
  end
228
- nilpassed.should be_true
228
+ expect(nilpassed).to be_truthy
229
229
  s.rewind
230
- s.read.should eql("{\"foo\":\"bar\"}")
230
+ expect(s.read).to eql("{\"foo\":\"bar\"}")
231
231
  end
232
232
 
233
233
  it "should not encode NaN" do
234
- lambda {
234
+ expect {
235
235
  Yajl::Encoder.encode(0.0/0.0)
236
- }.should raise_error(Yajl::EncodeError)
236
+ }.to raise_error(Yajl::EncodeError)
237
237
  end
238
238
 
239
239
  it "should not encode Infinity or -Infinity" do
240
- lambda {
240
+ expect {
241
241
  Yajl::Encoder.encode(1.0/0.0)
242
- }.should raise_error(Yajl::EncodeError)
243
- lambda {
242
+ }.to raise_error(Yajl::EncodeError)
243
+ expect {
244
244
  Yajl::Encoder.encode(-1.0/0.0)
245
- }.should raise_error(Yajl::EncodeError)
245
+ }.to raise_error(Yajl::EncodeError)
246
246
  end
247
247
 
248
248
  it "should encode with unicode chars in the key" do
249
249
  hash = {"浅草" => "<- those are unicode"}
250
- Yajl::Encoder.encode(hash).should eql("{\"浅草\":\"<- those are unicode\"}")
250
+ expect(Yajl::Encoder.encode(hash)).to eql("{\"浅草\":\"<- those are unicode\"}")
251
251
  end
252
252
 
253
253
  if RUBY_VERSION =~ /^1.9/
254
254
  it "should return a string encoded in utf-8 if Encoding.default_internal is nil" do
255
255
  Encoding.default_internal = nil
256
256
  hash = {"浅草" => "<- those are unicode"}
257
- Yajl::Encoder.encode(hash).encoding.should eql(Encoding.find('utf-8'))
257
+ expect(Yajl::Encoder.encode(hash).encoding).to eql(Encoding.find('utf-8'))
258
258
  end
259
259
 
260
260
  it "should return a string encoded in utf-8 even if Encoding.default_internal *is* set" do
261
261
  Encoding.default_internal = Encoding.find('utf-8')
262
262
  hash = {"浅草" => "<- those are unicode"}
263
- Yajl::Encoder.encode(hash).encoding.should eql(Encoding.default_internal)
263
+ expect(Yajl::Encoder.encode(hash).encoding).to eql(Encoding.default_internal)
264
264
  Encoding.default_internal = Encoding.find('us-ascii')
265
265
  hash = {"浅草" => "<- those are unicode"}
266
- Yajl::Encoder.encode(hash).encoding.should eql(Encoding.find('utf-8'))
266
+ expect(Yajl::Encoder.encode(hash).encoding).to eql(Encoding.find('utf-8'))
267
267
  end
268
268
  end
269
269
 
@@ -271,45 +271,45 @@ describe "Yajl JSON encoder" do
271
271
  unsafe_encoder = Yajl::Encoder.new(:html_safe => false)
272
272
  safe_encoder = Yajl::Encoder.new(:html_safe => true)
273
273
 
274
- unsafe_encoder.encode("</script>").should_not eql("\"<\\/script>\"")
275
- safe_encoder.encode("</script>").should eql("\"<\\/script>\"")
274
+ expect(unsafe_encoder.encode("</script>")).not_to eql("\"<\\/script>\"")
275
+ expect(safe_encoder.encode("</script>")).to eql("\"<\\/script>\"")
276
276
  end
277
277
 
278
278
  it "should default to *not* escaping / characters" do
279
279
  unsafe_encoder = Yajl::Encoder.new
280
- unsafe_encoder.encode("</script>").should_not eql("\"<\\/script>\"")
280
+ expect(unsafe_encoder.encode("</script>")).not_to eql("\"<\\/script>\"")
281
281
  end
282
282
 
283
283
  it "return value of #to_json must be a string" do
284
- lambda {
284
+ expect {
285
285
  Yajl::Encoder.encode(TheMindKiller.new)
286
- }.should raise_error(TypeError)
286
+ }.to raise_error(TypeError)
287
287
  end
288
288
 
289
289
  it "return value of #to_s must be a string" do
290
- lambda {
290
+ expect {
291
291
  if TheMindKillerDuce.send(:method_defined?, :to_json)
292
292
  TheMindKillerDuce.send(:undef_method, :to_json)
293
293
  end
294
294
  Yajl::Encoder.encode(TheMindKillerDuce.new)
295
- }.should raise_error(TypeError)
295
+ }.to raise_error(TypeError)
296
296
  end
297
297
 
298
298
  it "should raise an exception for deeply nested arrays" do
299
299
  root = []
300
300
  a = root
301
301
  (Yajl::MAX_DEPTH + 1).times { |_| a << []; a = a[0] }
302
- lambda {
302
+ expect {
303
303
  Yajl::Encoder.encode(root)
304
- }.should raise_error(Yajl::EncodeError)
304
+ }.to raise_error(Yajl::EncodeError)
305
305
  end
306
306
 
307
307
  it "should raise an exception for deeply nested hashes" do
308
308
  root = {}
309
309
  a = root
310
310
  (Yajl::MAX_DEPTH + 1).times { |_| a["a"] = {}; a = a["a"] }
311
- lambda {
311
+ expect {
312
312
  Yajl::Encoder.encode(root)
313
- }.should raise_error(Yajl::EncodeError)
313
+ }.to raise_error(Yajl::EncodeError)
314
314
  end
315
- end
315
+ end