json-jruby 1.1.2-universal-java-1.6 → 1.1.3-universal-java-1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/json/add/core.rb +11 -3
- data/lib/json/common.rb +5 -5
- data/lib/json/ext/generator.jar +0 -0
- data/lib/json/ext/parser.jar +0 -0
- data/lib/json/pure/generator.rb +1 -1
- data/lib/json/pure/parser.rb +1 -1
- data/lib/json/version.rb +1 -1
- data/tests/runner.rb +0 -1
- data/tests/test_json.rb +0 -1
- data/tests/test_json_addition.rb +24 -7
- data/tests/test_json_fixtures.rb +0 -0
- data/tests/test_json_generate.rb +0 -0
- data/tests/test_json_rails.rb +6 -2
- data/tests/test_json_unicode.rb +0 -0
- metadata +19 -12
data/lib/json/add/core.rb
CHANGED
@@ -33,13 +33,15 @@ class Date
|
|
33
33
|
civil(*object.values_at('y', 'm', 'd', 'sg'))
|
34
34
|
end
|
35
35
|
|
36
|
+
alias start sg unless method_defined?(:start)
|
37
|
+
|
36
38
|
def to_json(*args)
|
37
39
|
{
|
38
40
|
'json_class' => self.class.name,
|
39
41
|
'y' => year,
|
40
42
|
'm' => month,
|
41
43
|
'd' => day,
|
42
|
-
'sg' =>
|
44
|
+
'sg' => start,
|
43
45
|
}.to_json(*args)
|
44
46
|
end
|
45
47
|
end
|
@@ -48,11 +50,17 @@ class DateTime
|
|
48
50
|
def self.json_create(object)
|
49
51
|
args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
|
50
52
|
of_a, of_b = object['of'].split('/')
|
51
|
-
|
53
|
+
if of_b and of_b != '0'
|
54
|
+
args << Rational(of_a.to_i, of_b.to_i)
|
55
|
+
else
|
56
|
+
args << of_a
|
57
|
+
end
|
52
58
|
args << object['sg']
|
53
59
|
civil(*args)
|
54
60
|
end
|
55
61
|
|
62
|
+
alias start sg unless method_defined?(:start)
|
63
|
+
|
56
64
|
def to_json(*args)
|
57
65
|
{
|
58
66
|
'json_class' => self.class.name,
|
@@ -63,7 +71,7 @@ class DateTime
|
|
63
71
|
'M' => min,
|
64
72
|
'S' => sec,
|
65
73
|
'of' => offset.to_s,
|
66
|
-
'sg' =>
|
74
|
+
'sg' => start,
|
67
75
|
}.to_json(*args)
|
68
76
|
end
|
69
77
|
end
|
data/lib/json/common.rb
CHANGED
@@ -2,7 +2,7 @@ require 'json/version'
|
|
2
2
|
|
3
3
|
module JSON
|
4
4
|
class << self
|
5
|
-
# If _object_ is string
|
5
|
+
# If _object_ is string-like parse the string and return the parsed result
|
6
6
|
# as a Ruby data structure. Otherwise generate a JSON text from the Ruby
|
7
7
|
# data structure object and return it.
|
8
8
|
#
|
@@ -184,7 +184,8 @@ module JSON
|
|
184
184
|
end
|
185
185
|
|
186
186
|
# :stopdoc:
|
187
|
-
# I want to deprecate these later, so I'll first be silent about them, and
|
187
|
+
# I want to deprecate these later, so I'll first be silent about them, and
|
188
|
+
# later delete them.
|
188
189
|
alias unparse generate
|
189
190
|
module_function :unparse
|
190
191
|
# :startdoc:
|
@@ -238,7 +239,7 @@ module JSON
|
|
238
239
|
# :startdoc:
|
239
240
|
|
240
241
|
# Load a ruby data structure from a JSON _source_ and return it. A source can
|
241
|
-
# either be a string
|
242
|
+
# either be a string-like object, an IO like object, or an object responding
|
242
243
|
# to the read method. If _proc_ was given, it will be called with any nested
|
243
244
|
# Ruby object as an argument recursively in depth first order.
|
244
245
|
#
|
@@ -327,7 +328,7 @@ module ::Kernel
|
|
327
328
|
nil
|
328
329
|
end
|
329
330
|
|
330
|
-
# If _object_ is string
|
331
|
+
# If _object_ is string-like parse the string and return the parsed result as
|
331
332
|
# a Ruby data structure. Otherwise generate a JSON text from the Ruby data
|
332
333
|
# structure object and return it.
|
333
334
|
#
|
@@ -351,4 +352,3 @@ class ::Class
|
|
351
352
|
respond_to?(:json_create)
|
352
353
|
end
|
353
354
|
end
|
354
|
-
# vim: set et sw=2 ts=2:
|
data/lib/json/ext/generator.jar
CHANGED
Binary file
|
data/lib/json/ext/parser.jar
CHANGED
Binary file
|
data/lib/json/pure/generator.rb
CHANGED
@@ -40,7 +40,7 @@ module JSON
|
|
40
40
|
# Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
|
41
41
|
# UTF16 big endian characters as \u????, and return it.
|
42
42
|
def utf8_to_json(string) # :nodoc:
|
43
|
-
string = string.gsub(/["\\\/\x0-\x1f]/) {
|
43
|
+
string = string.gsub(/["\\\/\x0-\x1f]/) { MAP[$&] }
|
44
44
|
string.gsub!(/(
|
45
45
|
(?:
|
46
46
|
[\xc2-\xdf][\x80-\xbf] |
|
data/lib/json/pure/parser.rb
CHANGED
data/lib/json/version.rb
CHANGED
data/tests/runner.rb
CHANGED
data/tests/test_json.rb
CHANGED
data/tests/test_json_addition.rb
CHANGED
@@ -31,6 +31,10 @@ class TC_JSONAddition < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
class B
|
34
|
+
def self.json_creatable?
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
34
38
|
def to_json(*args)
|
35
39
|
{
|
36
40
|
'json_class' => self.class.name,
|
@@ -78,14 +82,14 @@ class TC_JSONAddition < Test::Unit::TestCase
|
|
78
82
|
)
|
79
83
|
end
|
80
84
|
|
81
|
-
def
|
85
|
+
def test_extended_json_fail1
|
82
86
|
b = B.new
|
83
87
|
assert !B.json_creatable?
|
84
88
|
json = generate(b)
|
85
|
-
assert_equal({
|
89
|
+
assert_equal({ "json_class"=>"TC_JSONAddition::B" }, JSON.parse(json))
|
86
90
|
end
|
87
91
|
|
88
|
-
def
|
92
|
+
def test_extended_json_fail2
|
89
93
|
c = C.new
|
90
94
|
assert !C.json_creatable?
|
91
95
|
json = generate(c)
|
@@ -112,6 +116,8 @@ EOT
|
|
112
116
|
assert_equal raw, raw_again
|
113
117
|
end
|
114
118
|
|
119
|
+
MyJsonStruct = Struct.new 'MyJsonStruct', :foo, :bar
|
120
|
+
|
115
121
|
def test_core
|
116
122
|
t = Time.now
|
117
123
|
assert_equal t, JSON(JSON(t))
|
@@ -123,8 +129,7 @@ EOT
|
|
123
129
|
assert_equal 1...10, JSON(JSON(1...10))
|
124
130
|
assert_equal "a".."c", JSON(JSON("a".."c"))
|
125
131
|
assert_equal "a"..."c", JSON(JSON("a"..."c"))
|
126
|
-
|
127
|
-
s = struct.new 4711, 'foot'
|
132
|
+
s = MyJsonStruct.new 4711, 'foot'
|
128
133
|
assert_equal s, JSON(JSON(s))
|
129
134
|
struct = Struct.new :foo, :bar
|
130
135
|
s = struct.new 4711, 'foot'
|
@@ -138,7 +143,19 @@ EOT
|
|
138
143
|
assert_equal e.message, e_again.message
|
139
144
|
assert_equal e.backtrace, e_again.backtrace
|
140
145
|
end
|
141
|
-
assert_equal
|
142
|
-
assert_equal
|
146
|
+
assert_equal(/foo/, JSON(JSON(/foo/)))
|
147
|
+
assert_equal(/foo/i, JSON(JSON(/foo/i)))
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_utc_datetime
|
151
|
+
now = Time.now
|
152
|
+
d = DateTime.parse(now.to_s) # usual case
|
153
|
+
assert d, JSON.parse(d.to_json)
|
154
|
+
d = DateTime.parse(now.utc.to_s) # of = 0
|
155
|
+
assert d, JSON.parse(d.to_json)
|
156
|
+
d = DateTime.civil(2008, 6, 17, 11, 48, 32, 1) # of = 1 / 12 => 1/12
|
157
|
+
assert d, JSON.parse(d.to_json)
|
158
|
+
d = DateTime.civil(2008, 6, 17, 11, 48, 32, 12) # of = 12 / 12 => 12
|
159
|
+
assert d, JSON.parse(d.to_json)
|
143
160
|
end
|
144
161
|
end
|
data/tests/test_json_fixtures.rb
CHANGED
File without changes
|
data/tests/test_json_generate.rb
CHANGED
File without changes
|
data/tests/test_json_rails.rb
CHANGED
@@ -31,6 +31,10 @@ class TC_JSONRails < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
class B
|
34
|
+
def self.json_creatable?
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
34
38
|
def to_json(*args)
|
35
39
|
{
|
36
40
|
'json_class' => self.class.name,
|
@@ -74,14 +78,14 @@ class TC_JSONRails < Test::Unit::TestCase
|
|
74
78
|
)
|
75
79
|
end
|
76
80
|
|
77
|
-
def
|
81
|
+
def test_extended_json_fail1
|
78
82
|
b = B.new
|
79
83
|
assert !B.json_creatable?
|
80
84
|
json = generate(b)
|
81
85
|
assert_equal({ 'json_class' => B.name }, JSON.parse(json))
|
82
86
|
end
|
83
87
|
|
84
|
-
def
|
88
|
+
def test_extended_json_fail2
|
85
89
|
c = C.new # with rails addition all objects are theoretically creatable
|
86
90
|
assert C.json_creatable?
|
87
91
|
json = generate(c)
|
data/tests/test_json_unicode.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
2
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
3
3
|
requirements:
|
4
4
|
- - '>='
|
5
|
-
- !ruby/object:Gem::Version
|
6
|
-
version:
|
5
|
+
- !ruby/object:Gem::Version
|
6
|
+
version: "0"
|
7
7
|
version:
|
8
|
-
email: mernen@gmail.com
|
8
|
+
email: mernen+rubyforge@gmail.com
|
9
9
|
cert_chain: []
|
10
|
+
|
10
11
|
summary: A JSON implementation as a JRuby extension
|
11
12
|
post_install_message:
|
12
13
|
extra_rdoc_files: []
|
14
|
+
|
13
15
|
homepage: http://rubyforge.org/projects/json-jruby/
|
14
16
|
signing_key:
|
15
17
|
name: json-jruby
|
16
18
|
rdoc_options: []
|
19
|
+
|
17
20
|
autorequire:
|
18
21
|
rubyforge_project: json-jruby
|
19
22
|
executables: []
|
23
|
+
|
20
24
|
description:
|
21
25
|
specification_version: 2
|
22
26
|
default_executable:
|
@@ -75,25 +79,28 @@ files:
|
|
75
79
|
- tests/fixtures/fail28.json
|
76
80
|
- tests/fixtures/pass2.json
|
77
81
|
- tests/fixtures/pass16.json
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
83
|
requirements:
|
80
84
|
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version:
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
83
87
|
version:
|
84
88
|
extensions: []
|
85
|
-
|
89
|
+
|
90
|
+
rubygems_version: 1.3.1
|
86
91
|
requirements: []
|
92
|
+
|
87
93
|
authors:
|
88
94
|
- Daniel Luz
|
89
|
-
date:
|
95
|
+
date: 2009-01-04 02:00:00 +00:00
|
90
96
|
platform: universal-java-1.6
|
91
97
|
test_files:
|
92
98
|
- tests/runner.rb
|
93
|
-
version: !ruby/object:Gem::Version
|
94
|
-
version: 1.1.
|
99
|
+
version: !ruby/object:Gem::Version
|
100
|
+
version: 1.1.3
|
95
101
|
require_paths:
|
96
102
|
- lib
|
97
103
|
dependencies: []
|
104
|
+
|
98
105
|
bindir: bin
|
99
106
|
has_rdoc: false
|