yajl-ruby 1.2.0 → 1.2.1

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: 123d047ce44bacef2d09aab8b2f51bf4a0d456d6
4
- data.tar.gz: 2d8622c124a07ea78ca3678a8042baed033407ef
3
+ metadata.gz: 17f8ce761c82a4625e4b55c33f7047c096912762
4
+ data.tar.gz: 14c6fa5ed9a57dda37e8e2191f49a1fd6353d323
5
5
  SHA512:
6
- metadata.gz: 3d68e9873ee4ea9173adc6d46a20c9157b64d4b613e3ea9d5bcff6becc32bc130a26637565b1a6aa3a5c98ddad824e09edae2f83995974da754ba9dfd8e0e444
7
- data.tar.gz: a47eb3ca4f465e3cc931e492cb18083ce00e2f7b81d307c1232409dff5509f2138d904877e1397ef3ffd7f3f22f779f1857c0092701716bc650f983ad4e1c61b
6
+ metadata.gz: 37a13ef5aad63d7b2ceff3a7db250eb03556f3ef3de4d12d5eabf67698c063b89e3964a062bbc25de0c88e5b7e4d25a6f5e3ed7b44bfe6c2bc864389e433375d
7
+ data.tar.gz: 3038b8ca0f7a587b8ddc20e7130f078b24fad9b3066d53e1aead28ef91d883c13996e5beaca3dd8b0c52b6ae9a12e116c5be89b3fac374ba62eb4a26869344da
@@ -3,12 +3,15 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
- - rbx
6
+ - 2.0.0
7
+ - 2.1.0
8
+ - 2.1.1
7
9
  - ree
8
10
  - ruby-head
9
11
  - rbx-18mode
10
12
  - rbx-19mode
11
13
  matrix:
12
14
  allow_failures:
15
+ - rvm: rbx
13
16
  - rvm: rbx-18mode
14
- - rvm: rbx-19mode
17
+ - rvm: rbx-19mode
data/README.md CHANGED
@@ -25,6 +25,12 @@ Go ahead and install it as usual:
25
25
  gem install yajl-ruby
26
26
  ```
27
27
 
28
+ Or use your Gemfile:
29
+
30
+ ``` ruby
31
+ gem 'yajl-ruby', require: 'yajl'
32
+ ```
33
+
28
34
  ## Example of use
29
35
 
30
36
  NOTE: I'm building up a collection of small examples in the examples (http://github.com/brianmario/yajl-ruby/tree/master/examples) folder.
@@ -2,6 +2,6 @@ require 'mkmf'
2
2
  require 'rbconfig'
3
3
 
4
4
  $CFLAGS << ' -Wall -funroll-loops'
5
- $CFLAGS << ' -Wextra -O0 -ggdb3' if ENV['DEBUG']
5
+ $CFLAGS << ' -Werror-implicit-function-declaration -Wextra -O0 -ggdb3' if ENV['DEBUG']
6
6
 
7
7
  create_makefile('yajl/yajl')
@@ -275,7 +275,7 @@ static int yajl_found_boolean(void * ctx, int boolean) {
275
275
  }
276
276
 
277
277
  static int yajl_found_number(void * ctx, const char * numberVal, unsigned int numberLen) {
278
- char buf[numberLen+1];
278
+ char* buf = (char*)malloc(numberLen + 1);
279
279
  buf[numberLen] = 0;
280
280
  memcpy(buf, numberVal, numberLen);
281
281
 
@@ -286,6 +286,7 @@ static int yajl_found_number(void * ctx, const char * numberVal, unsigned int nu
286
286
  } else {
287
287
  yajl_set_static_value(ctx, rb_cstr2inum(buf, 10));
288
288
  }
289
+ free(buf);
289
290
  return 1;
290
291
  }
291
292
 
@@ -315,15 +316,13 @@ static int yajl_found_hash_key(void * ctx, const unsigned char * stringVal, unsi
315
316
  #endif
316
317
 
317
318
  if (wrapper->symbolizeKeys) {
318
- char buf[stringLen+1];
319
- memcpy(buf, stringVal, stringLen);
320
- buf[stringLen] = 0;
321
- VALUE stringEncoded = rb_str_new2(buf);
322
319
  #ifdef HAVE_RUBY_ENCODING_H
323
- rb_enc_associate(stringEncoded, rb_utf8_encoding());
320
+ ID id = rb_intern3((const char *)stringVal, stringLen, utf8Encoding);
321
+ keyStr = ID2SYM(id);
322
+ #else
323
+ VALUE str = rb_str_new((const char *)stringVal, stringLen);
324
+ keyStr = rb_str_intern(str);
324
325
  #endif
325
-
326
- yajl_set_static_value(ctx, ID2SYM(rb_to_id(stringEncoded)));
327
326
  } else {
328
327
  keyStr = rb_str_new((const char *)stringVal, stringLen);
329
328
  #ifdef HAVE_RUBY_ENCODING_H
@@ -332,8 +331,8 @@ static int yajl_found_hash_key(void * ctx, const unsigned char * stringVal, unsi
332
331
  keyStr = rb_str_export_to_enc(keyStr, default_internal_enc);
333
332
  }
334
333
  #endif
335
- yajl_set_static_value(ctx, keyStr);
336
334
  }
335
+ yajl_set_static_value(ctx, keyStr);
337
336
  yajl_check_and_fire_callback(ctx);
338
337
  return 1;
339
338
  }
@@ -1,3 +1,3 @@
1
1
  module Yajl
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -192,7 +192,7 @@ describe "JSON Gem compatability API" do
192
192
  it "should be able to parse #{File.basename(name)} as an IO" do
193
193
  lambda {
194
194
  JSON.parse(StringIO.new(source))
195
- }.should_not raise_error(JSON::ParserError)
195
+ }.should_not raise_error
196
196
  end
197
197
  end
198
198
 
@@ -200,7 +200,7 @@ describe "JSON Gem compatability API" do
200
200
  it "should be able to parse #{File.basename(name)} as a string" do
201
201
  lambda {
202
202
  JSON.parse(source)
203
- }.should_not raise_error(JSON::ParserError)
203
+ }.should_not raise_error
204
204
  end
205
205
  end
206
206
  end
@@ -38,7 +38,7 @@ describe "ActiveSupport test cases" do
38
38
  it "should be able to parse #{json} as an IO" do
39
39
  lambda {
40
40
  Yajl::Parser.parse(StringIO.new(json)).should == expected
41
- }.should_not raise_error(Yajl::ParseError)
41
+ }.should_not raise_error
42
42
  end
43
43
  end
44
44
 
@@ -46,7 +46,7 @@ describe "ActiveSupport test cases" do
46
46
  it "should be able to parse #{json} as a string" do
47
47
  lambda {
48
48
  Yajl::Parser.parse(json).should == expected
49
- }.should_not raise_error(Yajl::ParseError)
49
+ }.should_not raise_error
50
50
  end
51
51
  end
52
52
 
@@ -67,7 +67,7 @@ describe "Chunked parser" do
67
67
  @callback.should_receive(:call).exactly(430).times
68
68
  lambda {
69
69
  @parser.parse(json)
70
- }.should_not raise_error(Yajl::ParseError)
70
+ }.should_not 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
@@ -81,7 +81,7 @@ describe "Chunked parser" do
81
81
  times += 1
82
82
  end
83
83
  times.should eql(430)
84
- }.should_not raise_error(Yajl::ParseError)
84
+ }.should_not 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
@@ -93,4 +93,4 @@ describe "Chunked parser" do
93
93
  @parser.parse(json)
94
94
  }.should raise_error(Yajl::ParseError)
95
95
  end
96
- end
96
+ end
@@ -26,7 +26,7 @@ describe "Parsing JSON Fixtures" do
26
26
  it "should be able to parse #{File.basename(name)} as an IO" do
27
27
  lambda {
28
28
  Yajl::Parser.parse(StringIO.new(source))
29
- }.should_not raise_error(Yajl::ParseError)
29
+ }.should_not raise_error
30
30
  end
31
31
  end
32
32
 
@@ -34,7 +34,7 @@ describe "Parsing JSON Fixtures" do
34
34
  it "should be able to parse #{File.basename(name)} as a string" do
35
35
  lambda {
36
36
  Yajl::Parser.parse(source)
37
- }.should_not raise_error(Yajl::ParseError)
37
+ }.should_not raise_error
38
38
  end
39
39
  end
40
- end
40
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Parsing very long text' do
4
+ shared_examples 'running script successfully' do |script|
5
+ def dup_pipe(parent_half, child_half, new_io)
6
+ parent_half.close
7
+ new_io.reopen(child_half)
8
+ child_half.close
9
+ end
10
+
11
+ def capture(cmd, stdin_data)
12
+ child_in, child_out, child_err = IO::pipe, IO::pipe, IO::pipe
13
+
14
+ child_pid = fork do
15
+ dup_pipe(child_in[1], child_in[0], STDIN)
16
+ dup_pipe(child_out[0], child_out[1], STDOUT)
17
+ dup_pipe(child_err[0], child_err[1], STDERR)
18
+
19
+ exec(cmd)
20
+ end
21
+
22
+ [
23
+ child_in[0],
24
+ child_out[1],
25
+ child_err[1],
26
+ ].each(&:close)
27
+
28
+ child_in[1].write(stdin_data)
29
+ child_in[1].close
30
+ _, status = Process.waitpid2(child_pid)
31
+
32
+ return child_out[0].read, child_err[0].read, status
33
+ ensure
34
+ [
35
+ child_in[1],
36
+ child_out[0],
37
+ child_err[0],
38
+ ].reject(&:closed?).each(&:close)
39
+ end
40
+
41
+ it 'runs successfully' do
42
+ out, err, status = capture('ruby', script)
43
+ [err, status.exitstatus].should eq(['', 0])
44
+ end
45
+ end
46
+
47
+ context 'when parseing big floats' do
48
+ include_examples('running script successfully', <<-EOS)
49
+ require "yajl"
50
+ Yajl::Parser.parse('[0.' + '1' * 2**23 + ']')
51
+ EOS
52
+ end
53
+
54
+ context 'when parseing long hash key with symbolize_keys option' do
55
+ include_examples('running script successfully', <<-EOS)
56
+ require "yajl"
57
+ Yajl::Parser.parse('{"' + 'a' * 2**23 + '": 0}', :symbolize_keys => true)
58
+ EOS
59
+ end
60
+ end
@@ -20,7 +20,7 @@ describe "One-off JSON examples" do
20
20
  json = StringIO.new('{"key": /* this is a comment */ "value"}')
21
21
  lambda {
22
22
  Yajl::Parser.parse(json, :allow_comments => true)
23
- }.should_not raise_error(Yajl::ParseError)
23
+ }.should_not raise_error
24
24
  end
25
25
 
26
26
  it "should not parse invalid UTF8 with :check_utf8 set to true" do
@@ -67,6 +67,11 @@ describe "One-off JSON examples" do
67
67
  end
68
68
 
69
69
  if RUBY_VERSION =~ /^1.9/
70
+ it "should encode non-ascii symbols in utf-8" do
71
+ parsed = Yajl::Parser.parse('{"曦": 1234}', :symbolize_keys => true)
72
+ parsed.keys.fetch(0).encoding.should eq(Encoding::UTF_8)
73
+ end
74
+
70
75
  it "should return strings and hash keys in utf-8 if Encoding.default_internal is nil" do
71
76
  Encoding.default_internal = nil
72
77
  Yajl::Parser.parse('{"key": "value"}').keys.first.encoding.should eql(Encoding.find('utf-8'))
@@ -1,6 +1,3 @@
1
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
-
4
1
  require 'rspec'
5
2
  require 'yajl'
6
3
  require 'date'
@@ -3,6 +3,7 @@ require './lib/yajl/version'
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{yajl-ruby}
5
5
  s.version = Yajl::VERSION
6
+ s.license = "MIT"
6
7
  s.authors = ["Brian Lopez", "Lloyd Hilaiel"]
7
8
  s.date = Time.now.utc.strftime("%Y-%m-%d")
8
9
  s.email = %q{seniorlopez@gmail.com}
@@ -17,9 +18,9 @@ Gem::Specification.new do |s|
17
18
 
18
19
  # tests
19
20
  s.add_development_dependency 'rake-compiler', ">= 0.7.5"
20
- s.add_development_dependency 'rspec', ">= 2.0.0"
21
+ s.add_development_dependency 'rspec', "~> 2.14"
21
22
  # benchmarks
22
- s.add_development_dependency 'activesupport'
23
+ s.add_development_dependency 'activesupport', '~> 3.1.2'
23
24
  s.add_development_dependency 'json'
24
25
  end
25
26
 
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.2.0
4
+ version: 1.2.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: 2013-12-17 00:00:00.000000000 Z
12
+ date: 2014-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -29,30 +29,30 @@ dependencies:
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: 2.0.0
34
+ version: '2.14'
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: 2.0.0
41
+ version: '2.14'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: activesupport
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: 3.1.2
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: 3.1.2
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: json
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -218,6 +218,7 @@ files:
218
218
  - spec/parsing/fixtures/pass2.json
219
219
  - spec/parsing/fixtures/pass3.json
220
220
  - spec/parsing/fixtures_spec.rb
221
+ - spec/parsing/large_number_spec.rb
221
222
  - spec/parsing/one_off_spec.rb
222
223
  - spec/rcov.opts
223
224
  - spec/spec_helper.rb
@@ -225,7 +226,8 @@ files:
225
226
  - tasks/rspec.rake
226
227
  - yajl-ruby.gemspec
227
228
  homepage: http://github.com/brianmario/yajl-ruby
228
- licenses: []
229
+ licenses:
230
+ - MIT
229
231
  metadata: {}
230
232
  post_install_message:
231
233
  rdoc_options: []
@@ -332,6 +334,7 @@ test_files:
332
334
  - spec/parsing/fixtures/pass2.json
333
335
  - spec/parsing/fixtures/pass3.json
334
336
  - spec/parsing/fixtures_spec.rb
337
+ - spec/parsing/large_number_spec.rb
335
338
  - spec/parsing/one_off_spec.rb
336
339
  - spec/rcov.opts
337
340
  - spec/spec_helper.rb