ed-precompiled_json 2.15.1-arm64-darwin
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.
- checksums.yaml +7 -0
- data/BSDL +22 -0
- data/CHANGES.md +693 -0
- data/COPYING +56 -0
- data/LEGAL +8 -0
- data/README.md +283 -0
- data/ext/json/ext/fbuffer/fbuffer.h +296 -0
- data/ext/json/ext/generator/extconf.rb +16 -0
- data/ext/json/ext/generator/generator.c +2169 -0
- data/ext/json/ext/parser/extconf.rb +15 -0
- data/ext/json/ext/parser/parser.c +1557 -0
- data/ext/json/ext/simd/conf.rb +24 -0
- data/ext/json/ext/simd/simd.h +188 -0
- data/ext/json/ext/vendor/fpconv.c +480 -0
- data/ext/json/ext/vendor/jeaiii-ltoa.h +267 -0
- data/json.gemspec +62 -0
- data/lib/json/add/bigdecimal.rb +58 -0
- data/lib/json/add/complex.rb +51 -0
- data/lib/json/add/core.rb +13 -0
- data/lib/json/add/date.rb +54 -0
- data/lib/json/add/date_time.rb +67 -0
- data/lib/json/add/exception.rb +49 -0
- data/lib/json/add/ostruct.rb +54 -0
- data/lib/json/add/range.rb +54 -0
- data/lib/json/add/rational.rb +49 -0
- data/lib/json/add/regexp.rb +48 -0
- data/lib/json/add/set.rb +48 -0
- data/lib/json/add/string.rb +35 -0
- data/lib/json/add/struct.rb +52 -0
- data/lib/json/add/symbol.rb +52 -0
- data/lib/json/add/time.rb +52 -0
- data/lib/json/common.rb +1130 -0
- data/lib/json/ext/3.0/generator.bundle +0 -0
- data/lib/json/ext/3.0/parser.bundle +0 -0
- data/lib/json/ext/3.1/generator.bundle +0 -0
- data/lib/json/ext/3.1/parser.bundle +0 -0
- data/lib/json/ext/3.2/generator.bundle +0 -0
- data/lib/json/ext/3.2/parser.bundle +0 -0
- data/lib/json/ext/3.3/generator.bundle +0 -0
- data/lib/json/ext/3.3/parser.bundle +0 -0
- data/lib/json/ext/3.4/generator.bundle +0 -0
- data/lib/json/ext/3.4/parser.bundle +0 -0
- data/lib/json/ext/generator/state.rb +99 -0
- data/lib/json/ext.rb +57 -0
- data/lib/json/generic_object.rb +67 -0
- data/lib/json/truffle_ruby/generator.rb +708 -0
- data/lib/json/version.rb +5 -0
- data/lib/json.rb +642 -0
- metadata +99 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module JSON
|
|
4
|
+
module Ext
|
|
5
|
+
module Generator
|
|
6
|
+
class State
|
|
7
|
+
# call-seq: new(opts = {})
|
|
8
|
+
#
|
|
9
|
+
# Instantiates a new State object, configured by _opts_.
|
|
10
|
+
#
|
|
11
|
+
# Argument +opts+, if given, contains a \Hash of options for the generation.
|
|
12
|
+
# See {Generating Options}[#module-JSON-label-Generating+Options].
|
|
13
|
+
def initialize(opts = nil)
|
|
14
|
+
if opts && !opts.empty?
|
|
15
|
+
configure(opts)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# call-seq: configure(opts)
|
|
20
|
+
#
|
|
21
|
+
# Configure this State instance with the Hash _opts_, and return
|
|
22
|
+
# itself.
|
|
23
|
+
def configure(opts)
|
|
24
|
+
unless opts.is_a?(Hash)
|
|
25
|
+
if opts.respond_to?(:to_hash)
|
|
26
|
+
opts = opts.to_hash
|
|
27
|
+
elsif opts.respond_to?(:to_h)
|
|
28
|
+
opts = opts.to_h
|
|
29
|
+
else
|
|
30
|
+
raise TypeError, "can't convert #{opts.class} into Hash"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
_configure(opts)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
alias_method :merge, :configure
|
|
37
|
+
|
|
38
|
+
# call-seq: to_h
|
|
39
|
+
#
|
|
40
|
+
# Returns the configuration instance variables as a hash, that can be
|
|
41
|
+
# passed to the configure method.
|
|
42
|
+
def to_h
|
|
43
|
+
result = {
|
|
44
|
+
indent: indent,
|
|
45
|
+
space: space,
|
|
46
|
+
space_before: space_before,
|
|
47
|
+
object_nl: object_nl,
|
|
48
|
+
array_nl: array_nl,
|
|
49
|
+
as_json: as_json,
|
|
50
|
+
allow_nan: allow_nan?,
|
|
51
|
+
ascii_only: ascii_only?,
|
|
52
|
+
max_nesting: max_nesting,
|
|
53
|
+
script_safe: script_safe?,
|
|
54
|
+
strict: strict?,
|
|
55
|
+
depth: depth,
|
|
56
|
+
buffer_initial_length: buffer_initial_length,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
allow_duplicate_key = allow_duplicate_key?
|
|
60
|
+
unless allow_duplicate_key.nil?
|
|
61
|
+
result[:allow_duplicate_key] = allow_duplicate_key
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
instance_variables.each do |iv|
|
|
65
|
+
iv = iv.to_s[1..-1]
|
|
66
|
+
result[iv.to_sym] = self[iv]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
result
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
alias_method :to_hash, :to_h
|
|
73
|
+
|
|
74
|
+
# call-seq: [](name)
|
|
75
|
+
#
|
|
76
|
+
# Returns the value returned by method +name+.
|
|
77
|
+
def [](name)
|
|
78
|
+
if respond_to?(name)
|
|
79
|
+
__send__(name)
|
|
80
|
+
else
|
|
81
|
+
instance_variable_get("@#{name}") if
|
|
82
|
+
instance_variables.include?("@#{name}".to_sym) # avoid warning
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# call-seq: []=(name, value)
|
|
87
|
+
#
|
|
88
|
+
# Sets the attribute name to value.
|
|
89
|
+
def []=(name, value)
|
|
90
|
+
if respond_to?(name_writer = "#{name}=")
|
|
91
|
+
__send__ name_writer, value
|
|
92
|
+
else
|
|
93
|
+
instance_variable_set "@#{name}", value
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
data/lib/json/ext.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json/common'
|
|
4
|
+
|
|
5
|
+
module JSON
|
|
6
|
+
# This module holds all the modules/classes that implement JSON's
|
|
7
|
+
# functionality as C extensions.
|
|
8
|
+
module Ext
|
|
9
|
+
class Parser
|
|
10
|
+
class << self
|
|
11
|
+
def parse(...)
|
|
12
|
+
new(...).parse
|
|
13
|
+
end
|
|
14
|
+
alias_method :parse, :parse # Allow redefinition by extensions
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize(source, opts = nil)
|
|
18
|
+
@source = source
|
|
19
|
+
@config = Config.new(opts)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def source
|
|
23
|
+
@source.dup
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def parse
|
|
27
|
+
@config.parse(@source)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
ruby_version = /(\d+\.\d+)/.match(::RUBY_VERSION)
|
|
32
|
+
|
|
33
|
+
begin
|
|
34
|
+
require "json/ext/#{ruby_version}/parser"
|
|
35
|
+
rescue LoadError
|
|
36
|
+
require 'json/ext/parser'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
Ext::Parser::Config = Ext::ParserConfig
|
|
40
|
+
JSON.parser = Ext::Parser
|
|
41
|
+
|
|
42
|
+
if RUBY_ENGINE == 'truffleruby'
|
|
43
|
+
require 'json/truffle_ruby/generator'
|
|
44
|
+
JSON.generator = JSON::TruffleRuby::Generator
|
|
45
|
+
else
|
|
46
|
+
begin
|
|
47
|
+
require "json/ext/#{ruby_version}/generator"
|
|
48
|
+
rescue LoadError
|
|
49
|
+
require 'json/ext/generator'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
JSON.generator = Generator
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
JSON_LOADED = true unless defined?(JSON::JSON_LOADED)
|
|
57
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
begin
|
|
3
|
+
require 'ostruct'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
warn "JSON::GenericObject requires 'ostruct'. Please install it with `gem install ostruct`."
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module JSON
|
|
9
|
+
class GenericObject < OpenStruct
|
|
10
|
+
class << self
|
|
11
|
+
alias [] new
|
|
12
|
+
|
|
13
|
+
def json_creatable?
|
|
14
|
+
@json_creatable
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
attr_writer :json_creatable
|
|
18
|
+
|
|
19
|
+
def json_create(data)
|
|
20
|
+
data = data.dup
|
|
21
|
+
data.delete JSON.create_id
|
|
22
|
+
self[data]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def from_hash(object)
|
|
26
|
+
case
|
|
27
|
+
when object.respond_to?(:to_hash)
|
|
28
|
+
result = new
|
|
29
|
+
object.to_hash.each do |key, value|
|
|
30
|
+
result[key] = from_hash(value)
|
|
31
|
+
end
|
|
32
|
+
result
|
|
33
|
+
when object.respond_to?(:to_ary)
|
|
34
|
+
object.to_ary.map { |a| from_hash(a) }
|
|
35
|
+
else
|
|
36
|
+
object
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def load(source, proc = nil, opts = {})
|
|
41
|
+
result = ::JSON.load(source, proc, opts.merge(:object_class => self))
|
|
42
|
+
result.nil? ? new : result
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def dump(obj, *args)
|
|
46
|
+
::JSON.dump(obj, *args)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
self.json_creatable = false
|
|
50
|
+
|
|
51
|
+
def to_hash
|
|
52
|
+
table
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def |(other)
|
|
56
|
+
self.class[other.to_hash.merge(to_hash)]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def as_json(*)
|
|
60
|
+
{ JSON.create_id => self.class.name }.merge to_hash
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def to_json(*a)
|
|
64
|
+
as_json.to_json(*a)
|
|
65
|
+
end
|
|
66
|
+
end if defined?(::OpenStruct)
|
|
67
|
+
end
|