yaji 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.5 / 2011-08-22
2
+
3
+ * Don't fail on empty input
4
+
1
5
  === 0.0.4 / 2011-08-22
2
6
 
3
7
  * Pass multiple filter explicitly as an array
@@ -227,6 +227,7 @@ static VALUE rb_yaji_parser_init(int argc, VALUE *argv, VALUE self)
227
227
  return self;
228
228
  }
229
229
 
230
+
230
231
  static VALUE rb_yaji_parser_parse(int argc, VALUE* argv, VALUE self)
231
232
  {
232
233
  yajl_status rc;
@@ -251,7 +252,9 @@ static VALUE rb_yaji_parser_parse(int argc, VALUE* argv, VALUE self)
251
252
 
252
253
  p->events = rb_ary_new();
253
254
  rc = yajl_parse_complete(p->handle);
254
- if (rc == yajl_status_insufficient_data || rc == yajl_status_error) {
255
+
256
+ if (rc == yajl_status_error ||
257
+ (rc == yajl_status_insufficient_data && RSTRING_LEN(rb_funcall(p->chunk, id_strip, 0)) != 0)) {
255
258
  RERAISE_PARSER_ERROR(p);
256
259
  }
257
260
  for (i=0; i<RARRAY_LEN(p->events); i++) {
@@ -389,6 +392,7 @@ void Init_parser_ext() {
389
392
  id_call = rb_intern("call");
390
393
  id_read = rb_intern("read");
391
394
  id_parse = rb_intern("parse");
395
+ id_strip = rb_intern("strip");
392
396
  id_perform = rb_intern("perform");
393
397
  id_on_body = rb_intern("on_body");
394
398
  id_bytesize = rb_intern("bytesize");
@@ -41,7 +41,7 @@ static rb_encoding *utf8_encoding;
41
41
 
42
42
  static VALUE m_yaji, c_yaji_parser, c_parse_error, c_stringio;
43
43
 
44
- static ID id_call, id_read, id_parse, id_perform, id_on_body, id_bytesize;
44
+ static ID id_call, id_read, id_parse, id_perform, id_on_body, id_bytesize, id_strip;
45
45
  static ID sym_allow_comments, sym_check_utf8, sym_symbolize_keys,
46
46
  sym_read_buffer_size, sym_null, sym_boolean, sym_number, sym_string,
47
47
  sym_hash_key, sym_start_hash, sym_end_hash, sym_start_array,
data/lib/yaji/version.rb CHANGED
@@ -18,5 +18,5 @@
18
18
  #
19
19
 
20
20
  module YAJI
21
- VERSION = "0.0.4"
21
+ VERSION = "0.0.5"
22
22
  end
data/test/test_parser.rb CHANGED
@@ -165,6 +165,13 @@ class TestParser < MiniTest::Unit::TestCase
165
165
  assert_equal expected, objects
166
166
  end
167
167
 
168
+ def test_it_doesnt_raise_exception_on_empty_input
169
+ YAJI::Parser.new("").parse
170
+ YAJI::Parser.new(" ").parse
171
+ YAJI::Parser.new("\n").parse
172
+ YAJI::Parser.new(" \n\n ").parse
173
+ end
174
+
168
175
  protected
169
176
 
170
177
  def toys_json_str
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-08-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
16
- requirement: &12788740 !ruby/object:Gem::Requirement
16
+ requirement: &14016000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *12788740
24
+ version_requirements: *14016000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &12788240 !ruby/object:Gem::Requirement
27
+ requirement: &14015480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *12788240
35
+ version_requirements: *14015480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: curb
38
- requirement: &12787780 !ruby/object:Gem::Requirement
38
+ requirement: &14015020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *12787780
46
+ version_requirements: *14015020
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ruby-debug19
49
- requirement: &12787300 !ruby/object:Gem::Requirement
49
+ requirement: &14014500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *12787300
57
+ version_requirements: *14014500
58
58
  description: YAJI is a ruby wrapper to YAJL providing iterator interface to streaming
59
59
  JSON parser
60
60
  email: info@couchbase.com
@@ -105,4 +105,6 @@ rubygems_version: 1.8.7
105
105
  signing_key:
106
106
  specification_version: 3
107
107
  summary: Yet another JSON iterator
108
- test_files: []
108
+ test_files:
109
+ - test/fixture.json
110
+ - test/test_parser.rb