jsonify 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency 'multi_json', '~>1.0'
21
+ s.add_runtime_dependency 'multi_json', '~>1.3'
22
22
 
23
23
  s.add_development_dependency 'json' unless RUBY_VERSION =~ /^1.9/
24
24
  s.add_development_dependency 'bundler'
@@ -57,16 +57,16 @@ module Jsonify
57
57
  end
58
58
 
59
59
  # Compiles the JSON objects into a string representation.
60
- # If initialized with +:verify => true+, the compiled result will be verified by attempting to re-parse it using +MultiJson.decode+.
61
- # If initialized with +:format => :pretty+, the compiled result will be parsed and encoded via +MultiJson.encode(<json>, :pretty => true)+
60
+ # If initialized with +:verify => true+, the compiled result will be verified by attempting to re-parse it using +MultiJson.load+.
61
+ # If initialized with +:format => :pretty+, the compiled result will be parsed and encoded via +MultiJson.dump(<json>, :pretty => true)+
62
62
  # This method can be called without any side effects. You can call +compile!+ at any time, and multiple times if desired.
63
63
  #
64
64
  # @raise [TypeError] only if +:verify+ is set to true
65
65
  # @raise [JSON::ParseError] only if +:verify+ is set to true
66
66
  def compile!
67
67
  result = (@stack[0] || {}).encode_as_json
68
- MultiJson.decode(result) if @verify
69
- result = MultiJson.encode(MultiJson.decode(result), :pretty => true) if @pretty
68
+ MultiJson.load(result) if @verify
69
+ result = MultiJson.dump(MultiJson.load(result), :pretty => true) if @pretty
70
70
  result
71
71
  end
72
72
 
@@ -187,7 +187,7 @@ module Jsonify
187
187
  # @param [String] json_string a full JSON string (e.g. from a rendered partial)
188
188
  def ingest!(json_string)
189
189
  return if json_string.empty?
190
- res = Jsonify::Generate.value(MultiJson.decode(json_string))
190
+ res = Jsonify::Generate.value(MultiJson.load(json_string))
191
191
  current = @stack[@level]
192
192
  if current.nil?
193
193
  @stack[@level] = res
@@ -1,6 +1,6 @@
1
1
  class Object
2
2
  def encode_as_json
3
- MultiJson.encode self
3
+ MultiJson.dump self
4
4
  end
5
5
  end
6
6
 
@@ -1,3 +1,3 @@
1
1
  module Jsonify
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -108,7 +108,7 @@ PRETTY_JSON
108
108
  end
109
109
  it 'should support the store! message' do
110
110
  json.store!( "foo", "bar" ).store!( 'no', "whar" )
111
- MultiJson.decode(json.compile!).should == MultiJson.decode('{"foo":"bar","no":"whar"}')
111
+ MultiJson.load(json.compile!).should == MultiJson.load('{"foo":"bar","no":"whar"}')
112
112
  end
113
113
  end
114
114
  end
@@ -137,12 +137,12 @@ PRETTY_JSON
137
137
  json.foo :bar
138
138
  json.go :far
139
139
  expected = '{"foo":"bar","go":"far"}'
140
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
140
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
141
141
  end
142
142
  it 'should handle arrays' do
143
143
  json[1] = [2, 3]
144
144
  json[4] = 5
145
- MultiJson.decode(json.compile!).should == MultiJson.decode('{"1":[2,3],"4":5}')
145
+ MultiJson.load(json.compile!).should == MultiJson.load('{"1":[2,3],"4":5}')
146
146
  end
147
147
  end
148
148
 
@@ -155,7 +155,7 @@ PRETTY_JSON
155
155
  end
156
156
  end
157
157
  expected = '{"foo foo":{"bar bar":{"buzz buzz":"goo goo"}}}'
158
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
158
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
159
159
  end
160
160
 
161
161
  it 'complex hash' do
@@ -216,7 +216,7 @@ PRETTY_JSON
216
216
  end
217
217
  end
218
218
  expected = "{\"foo\":{\"bar\":{\"baz\":\"goo\",\"years\":[2011,2012]}}}"
219
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
219
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
220
220
  end
221
221
  end
222
222
 
@@ -226,7 +226,7 @@ PRETTY_JSON
226
226
  it 'should work' do
227
227
  json.bar [1,2,{:foo => 'goo'}]
228
228
  expected = "{\"bar\":[1,2,{\"foo\":\"goo\"}]}"
229
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
229
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
230
230
  end
231
231
  end
232
232
 
@@ -259,7 +259,7 @@ PRETTY_JSON
259
259
  end
260
260
  end
261
261
  expected = "{\"result\":{\"person\":{\"fname\":\"George\",\"lname\":\"Burdell\"},\"links\":[{\"href\":\"example.com\",\"rel\":\"self\"},{\"href\":\"foo.com\",\"rel\":\"parent\"}]}}"
262
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
262
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
263
263
  end
264
264
  end
265
265
 
@@ -269,20 +269,20 @@ PRETTY_JSON
269
269
  context 'into' do
270
270
  it 'nothing -- should replace it' do
271
271
  json.ingest! json_string
272
- MultiJson.decode(json.compile!).should == MultiJson.decode(json_string)
272
+ MultiJson.load(json.compile!).should == MultiJson.load(json_string)
273
273
  end
274
274
  it 'json object -- should merge' do
275
275
  json["my boy"] = "Monday"
276
276
  json["my girl"] = "Sunday"
277
277
  json.ingest! json_string
278
278
  expected = '{"my boy":"Monday","my girl":"Friday","my daughter":"Wednesday"}'
279
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
279
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
280
280
  end
281
281
  it 'json array -- should add' do
282
282
  json << 1 << 2
283
283
  json.ingest! json_string
284
284
  expected = '[1,2,{"my girl":"Friday","my daughter":"Wednesday"}]'
285
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
285
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
286
286
  end
287
287
  end
288
288
  end
@@ -291,7 +291,7 @@ PRETTY_JSON
291
291
  context 'into' do
292
292
  it 'nothing -- should replace it' do
293
293
  json.ingest! json_string
294
- MultiJson.decode(json.compile!).should == MultiJson.decode(json_string)
294
+ MultiJson.load(json.compile!).should == MultiJson.load(json_string)
295
295
  end
296
296
  it 'json object -- should raise error' do
297
297
  json["my boy"] = "Monday"
@@ -302,7 +302,7 @@ PRETTY_JSON
302
302
  json << 1 << 2
303
303
  json.ingest! json_string
304
304
  expected = '[1,2,[1,2,3]]'
305
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
305
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
306
306
  end
307
307
  end
308
308
  end
@@ -323,14 +323,14 @@ PRETTY_JSON
323
323
  end
324
324
 
325
325
  expected = '{"results":[{"id":1,"children":[{"id":"a"},{"id":"b"}]},{"id":2,"children":[{"id":"c"},{"id":"d"}]}]}'
326
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
326
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
327
327
  end
328
328
  it 'simple append' do
329
329
  json.letters('a'..'c') do |letter|
330
330
  json << letter.upcase
331
331
  end
332
332
  expected = '{"letters":["A","B","C"]}'
333
- MultiJson.decode(json.compile!).should == MultiJson.decode(expected)
333
+ MultiJson.load(json.compile!).should == MultiJson.load(expected)
334
334
  end
335
335
 
336
336
  end
@@ -13,7 +13,7 @@ describe Jsonify::Generate do
13
13
  json = Jsonify::Generate
14
14
  result = json.value links
15
15
  expected = '{"links":[{"rel":"foo","href":"goo"},{"rel":"bar","href":"baz"}]}'
16
- MultiJson.decode(result.encode_as_json).should == MultiJson.decode(expected)
16
+ MultiJson.load(result.encode_as_json).should == MultiJson.load(expected)
17
17
  end
18
18
 
19
19
  describe 'complex example' do
@@ -29,7 +29,7 @@ describe Jsonify::Generate do
29
29
  }
30
30
  )
31
31
  expected = "{\"links\":[{\"rel\":\"foo\",\"href\":\"goo\"},{\"rel\":\"bar\",\"href\":\"baz\"}]}"
32
- MultiJson.decode(json.encode_as_json).should == MultiJson.decode(expected)
32
+ MultiJson.load(json.encode_as_json).should == MultiJson.load(expected)
33
33
  end
34
34
  end
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-30 00:00:00.000000000Z
12
+ date: 2012-04-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &70241058026120 !ruby/object:Gem::Requirement
16
+ requirement: &70346540134460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '1.0'
21
+ version: '1.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70241058026120
24
+ version_requirements: *70346540134460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70241058013240 !ruby/object:Gem::Requirement
27
+ requirement: &70346540133240 !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: *70241058013240
35
+ version_requirements: *70346540133240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: tilt
38
- requirement: &70241058011740 !ruby/object:Gem::Requirement
38
+ requirement: &70346540130780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.3.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70241058011740
46
+ version_requirements: *70346540130780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70241058010960 !ruby/object:Gem::Requirement
49
+ requirement: &70346540076500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70241058010960
57
+ version_requirements: *70346540076500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70241058010220 !ruby/object:Gem::Requirement
60
+ requirement: &70346540069140 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70241058010220
68
+ version_requirements: *70346540069140
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &70241058009520 !ruby/object:Gem::Requirement
71
+ requirement: &70346540065620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70241058009520
79
+ version_requirements: *70346540065620
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rdiscount
82
- requirement: &70241058008820 !ruby/object:Gem::Requirement
82
+ requirement: &70346540059620 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70241058008820
90
+ version_requirements: *70346540059620
91
91
  description: Turn Ruby objects into JSON -- correctly!
92
92
  email:
93
93
  - bsiggelkow@me.com
@@ -133,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  segments:
135
135
  - 0
136
- hash: -3823914982470155210
136
+ hash: -3853900993041975354
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -3823914982470155210
145
+ hash: -3853900993041975354
146
146
  requirements: []
147
147
  rubyforge_project: jsonify
148
148
  rubygems_version: 1.8.6