diff options
author | Florian Frank <flori@ping.de> | 2016-09-23 18:37:50 +0300 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2016-09-23 21:43:38 +0300 |
commit | 7e240ed5765867bfbdd166435f941a4cebed8cd8 (patch) | |
tree | 31e381d00a2c47a513143ba723847140fd27b7da /lib | |
parent | 8c7eb9e93916f2d863fc9ead9422427e243a5956 (diff) | |
download | json-7e240ed5765867bfbdd166435f941a4cebed8cd8.tar.gz |
Merge decimal_class patch by Michael Jaschob
Also:
- Avoid some issues with bundler
- Avoid some issues with jruby
Diffstat (limited to 'lib')
-rw-r--r-- | lib/json/pure/parser.rb | 6 | ||||
-rw-r--r-- | lib/json/version.rb | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb index b907236..3a6343b 100644 --- a/lib/json/pure/parser.rb +++ b/lib/json/pure/parser.rb @@ -70,6 +70,9 @@ module JSON # option defaults to false. # * *object_class*: Defaults to Hash # * *array_class*: Defaults to Array + # * *decimal_class*: Specifies which class to use instead of the default + # (Float) when parsing decimal numbers. This class must accept a single + # string argument in its constructor. def initialize(source, opts = {}) opts ||= {} source = convert_encoding source @@ -94,6 +97,7 @@ module JSON @create_id = @create_additions ? JSON.create_id : nil @object_class = opts[:object_class] || Hash @array_class = opts[:array_class] || Array + @decimal_class = opts[:decimal_class] @match_string = opts[:match_string] end @@ -193,7 +197,7 @@ module JSON def parse_value case when scan(FLOAT) - Float(self[1]) + @decimal_class && @decimal_class.new(self[1]) || Float(self[1]) when scan(INTEGER) Integer(self[1]) when scan(TRUE) diff --git a/lib/json/version.rb b/lib/json/version.rb index 8997def..b65ed87 100644 --- a/lib/json/version.rb +++ b/lib/json/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module JSON # JSON version - VERSION = '2.0.2' + VERSION = '2.1.0' VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: |