wankel 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6c72e99e43dc80c261cb7de98acfe8a2722eaeb
4
- data.tar.gz: 9c1ca0c3bed80cd83815309d8bd8f98743c67a4c
3
+ metadata.gz: 7d94fdd92adc8e8f4a7b48d9bdb9a4e05546ef4e
4
+ data.tar.gz: 201ed3086cb984205371a6fff8c68b8c258a2641
5
5
  SHA512:
6
- metadata.gz: 955623a08d6970492669a8fe10d15e1417bf1d42e097742ce2807b9110dc51bd185e86ad9b46dba49bb5d19008cb96b90567fa396d93c11645356f289b7caea0
7
- data.tar.gz: 6e66f495681a0501fc9fd56efaf117687c7ce8c3e3940e184f7db184b89f72e6b1153cfd12bd3c79ad76df1dcbd374689993f68ee50780cb4f6ea43675a2006d
6
+ metadata.gz: f0c9e3edbbd0d5050d7ccf4ec9c262f32753fe3d200cd450eaeb293ecf34490f9c158b8b4f6ee7272e6ee549948d540791c8c9c698aeb5ad013e8ba316566c30
7
+ data.tar.gz: 452d761a043b0030d4e01d5613e3b8eb38b70e9e36a62d83ec49f45693e8608ec7a07326a81cdd0d0dbee7ad628ac1855522f5a1487a3572177cb94145a91c2b
@@ -101,6 +101,33 @@ static VALUE sax_parser_parse(int argc, VALUE * argv, VALUE self) {
101
101
  return Qnil;
102
102
  }
103
103
 
104
+ static VALUE sax_parser_write(VALUE self, VALUE input) {
105
+ const char * cptr;
106
+ size_t len;
107
+ yajl_status status;
108
+ sax_parser * p;
109
+ Data_Get_Struct(self, sax_parser, p);
110
+
111
+ Check_Type(input, T_STRING);
112
+ cptr = RSTRING_PTR(input);
113
+ len = RSTRING_LEN(input);
114
+ status = yajl_parse(p->h, (const unsigned char*)cptr, len);
115
+ yajl_helper_check_status(p->h, status, 1, (const unsigned char*)cptr, len);
116
+
117
+ return Qnil;
118
+ }
119
+
120
+ static VALUE sax_parser_complete(VALUE self) {
121
+ yajl_status status;
122
+ sax_parser * p;
123
+ Data_Get_Struct(self, sax_parser, p);
124
+
125
+ status = yajl_complete_parse(p->h);
126
+ yajl_helper_check_status(p->h, status, 0, NULL, 0);
127
+
128
+ return Qnil;
129
+ }
130
+
104
131
  void Init_wankel_sax_parser() {
105
132
  c_wankel = rb_const_get(rb_cObject, rb_intern("Wankel"));
106
133
  c_wankelParser = rb_const_get(c_wankel, rb_intern("Parser"));
@@ -111,6 +138,10 @@ void Init_wankel_sax_parser() {
111
138
  rb_define_alloc_func(c_saxParser, sax_parser_alloc);
112
139
  rb_define_method(c_saxParser, "initialize", sax_parser_initialize, -1);
113
140
  rb_define_method(c_saxParser, "parse", sax_parser_parse, -1);
141
+ rb_define_method(c_saxParser, "write", sax_parser_write, 1);
142
+ rb_define_method(c_saxParser, "complete", sax_parser_complete, 0);
143
+
144
+ rb_define_alias(c_saxParser, "<<", "write");
114
145
 
115
146
  intern_merge = rb_intern("merge");
116
147
  intern_clone = rb_intern("clone");
@@ -49,6 +49,27 @@ class Wankel::SaxParserTest < Minitest::Test
49
49
  parser.instance_variable_get("@options") == Wankel::DEFAULTS.merge({:hello => true, :metoo => false})
50
50
  end
51
51
 
52
+ test "#parse(STRING)" do
53
+ parser = TestParser.new
54
+ parser.parse("{\"id\": 2147483649,\"key\": [1,null,1.0,{}, true]}")
55
+ end
56
+
57
+ test "#parse(IO)" do
58
+ #TODO
59
+ # parser = TestParser.new
60
+ # parser.parse(StringIO.new("{\"id\": 2147483649,\"key\": [1,null,1.0,{}, true]}"))
61
+ end
62
+
63
+ test "#write(STRING) && #complete() instead of #parse(DATA)" do
64
+ parser = TestParser.new
65
+ parser.expects(:on_map_start).twice
66
+
67
+ parser.write("{\"id\":")
68
+ parser << " 2147483649,\"ke"
69
+ parser.write("y\": [1,null,1.0,{}, true]}")
70
+ parser.complete
71
+ end
72
+
52
73
  test "on_map_start callback" do
53
74
  parser = TestParser.new
54
75
  parser.expects(:on_map_start).twice
data/wankel.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'wankel'
3
- s.version = '0.1.1'
3
+ s.version = '0.2.0'
4
4
  s.licenses = ['MIT']
5
5
  s.authors = ['Jon Bracy']
6
6
  s.email = ['jonbracy@gmail.com']
@@ -19,4 +19,11 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency 'minitest', '~> 5.3'
20
20
  s.add_development_dependency 'minitest-reporters', '~> 1.0'
21
21
  s.add_development_dependency 'mocha', '~> 1.1'
22
- end
22
+ end
23
+
24
+ # spec.requirements << 'libmagick, v6.0'
25
+ # spec.extra_rdoc_files = ['README', 'doc/user-guide.txt']
26
+ # s.metadata = { "issue_tracker" => "https://example/issues" }
27
+ # spec.rdoc_options << '--title' << 'Rake -- Ruby Make' <<
28
+ # '--main' << 'README' <<
29
+ # '--line-numbers'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wankel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler