json-jruby 1.1.2-universal-java-1.6 → 1.1.3-universal-java-1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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' => 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
- args << Rational(of_a.to_i, of_b.to_i)
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' => 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 like parse the string and return the parsed result
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 later delete them.
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 like object, an IO like object, or an object responding
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 like parse the string and return the parsed result as
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:
Binary file
Binary file
@@ -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]/) { |c| MAP[c] }
43
+ string = string.gsub(/["\\\/\x0-\x1f]/) { MAP[$&] }
44
44
  string.gsub!(/(
45
45
  (?:
46
46
  [\xc2-\xdf][\x80-\xbf] |
@@ -123,7 +123,7 @@ module JSON
123
123
  if scan(STRING)
124
124
  return '' if self[1].empty?
125
125
  self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
126
- if u = UNESCAPE_MAP[c[1]]
126
+ if u = UNESCAPE_MAP[$&[1]]
127
127
  u
128
128
  else # \uXXXX
129
129
  bytes = ''
data/lib/json/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.1.2'
3
+ VERSION = '1.1.3'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/tests/runner.rb CHANGED
@@ -23,4 +23,3 @@ class TS_AllTests
23
23
  end
24
24
  end
25
25
  Test::Unit::UI::Console::TestRunner.run(TS_AllTests)
26
- # vim: set et sw=2 ts=2:
data/tests/test_json.rb CHANGED
@@ -291,4 +291,3 @@ EOT
291
291
  assert_equal too_deep, output.string
292
292
  end
293
293
  end
294
- # vim: set et sw=2 ts=2:
@@ -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 test_extended_json_fail
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({ 'json_class' => B.name }, JSON.parse(json))
89
+ assert_equal({ "json_class"=>"TC_JSONAddition::B" }, JSON.parse(json))
86
90
  end
87
91
 
88
- def test_extended_json_fail
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
- struct = Struct.new 'MyJsonStruct', :foo, :bar
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 /foo/, JSON(JSON(/foo/))
142
- assert_equal /foo/i, JSON(JSON(/foo/i))
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
File without changes
File without changes
@@ -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 test_extended_json_fail
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 test_extended_json_fail
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)
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: !str 0
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: !str 0
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
83
87
  version:
84
88
  extensions: []
85
- rubygems_version: 1.0.1
89
+
90
+ rubygems_version: 1.3.1
86
91
  requirements: []
92
+
87
93
  authors:
88
94
  - Daniel Luz
89
- date: 2008-04-06 03:00:00 +00:00
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.2
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