Skip to content

Commit ca0ffa5

Browse files
committed
Minor cleanup for ruby 2.7 warnings and failures.
1 parent 8d8e1aa commit ca0ffa5

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ rvm:
1212
- 2.4
1313
- 2.5
1414
- 2.6
15+
- 2.7.0-preview2
1516
- ruby-head
1617
- jruby
1718
matrix:

lib/json/pure/parser.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,15 @@ def parse_string
197197
def parse_value
198198
case
199199
when scan(FLOAT)
200-
@decimal_class && @decimal_class.new(self[1]) || Float(self[1])
200+
if @decimal_class then
201+
if @decimal_class == BigDecimal then
202+
BigDecimal(self[1])
203+
else
204+
@decimal_class.new(self[1]) || Float(self[1])
205+
end
206+
else
207+
Float(self[1])
208+
end
201209
when scan(INTEGER)
202210
Integer(self[1])
203211
when scan(TRUE)

tests/json_parser_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_parse_numbers
111111

112112
def test_parse_bigdecimals
113113
assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class)
114-
assert_equal(BigDecimal.new("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] )
114+
assert_equal(BigDecimal("0.901234567890123456789E1"), JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] )
115115
end
116116

117117
if Array.method_defined?(:permutation)

0 commit comments

Comments
 (0)