ree_lib 1.0.65 → 1.0.66
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ree_lib/packages/ree_json/package/ree_json/constants.rb +5 -4
- data/lib/ree_lib/packages/ree_json/package/ree_json/functions/from_json.rb +6 -11
- data/lib/ree_lib/packages/ree_json/package/ree_json/functions/to_json.rb +4 -9
- data/lib/ree_lib/packages/ree_json/schemas/ree_json/functions/from_json.schema.json +2 -7
- data/lib/ree_lib/packages/ree_json/schemas/ree_json/functions/to_json.schema.json +3 -7
- data/lib/ree_lib/packages/ree_json/spec/ree_json/functions/from_json_spec.rb +32 -0
- data/lib/ree_lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4afa1450a6827106e39ef7e907de9ce4f490a2cc323bbc59eca1c5cf7386b69
|
4
|
+
data.tar.gz: 2a7e3858a80590ad65ce462f77d61f1e5d87435fdf9b5528c626ed41a573cb5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a2d3070cbe58af3289dd89da27004955d4689a2b32758b7dd123288e6fabcc1915571ee6b353cd8edd0beaef8402f9668bf8034742a7ab30359d26b1f7828a3
|
7
|
+
data.tar.gz: 3eb4943530aa4e658f091ce8d8314032b9b5381828ec04e82686ecea3ec2a6481d56783eb19a8d86a943d3108a846632ff0903ec2a28b164734792f9e20322ae
|
data/Gemfile.lock
CHANGED
@@ -11,7 +11,7 @@ class ReeJson::Constants
|
|
11
11
|
:object,
|
12
12
|
:custom,
|
13
13
|
:wab,
|
14
|
-
]
|
14
|
+
].freeze
|
15
15
|
|
16
16
|
ESCAPE_MODES = [
|
17
17
|
:newline, # allows unescaped newlines in the output.
|
@@ -19,12 +19,13 @@ class ReeJson::Constants
|
|
19
19
|
:xss_safe, # escapes HTML and XML characters such as & and <.
|
20
20
|
:ascii, # escapes all non-ascii or characters with the hi-bit set.
|
21
21
|
:unicode_xss, # escapes a special unicodes and is xss safe.
|
22
|
-
]
|
22
|
+
].freeze
|
23
23
|
|
24
|
-
TIME_FORMATS = []
|
24
|
+
TIME_FORMATS = [].freeze
|
25
25
|
|
26
26
|
DEFAULT_OPTIONS = {
|
27
27
|
time_format: :xmlschema,
|
28
|
-
use_as_json: true
|
28
|
+
use_as_json: true,
|
29
|
+
mode: :rails,
|
29
30
|
}.freeze
|
30
31
|
end
|
@@ -3,7 +3,7 @@ class ReeJson::FromJson
|
|
3
3
|
|
4
4
|
fn :from_json do
|
5
5
|
link 'ree_json/constants', -> {
|
6
|
-
DEFAULT_OPTIONS & MODES
|
6
|
+
DEFAULT_OPTIONS & MODES & ESCAPE_MODES & TIME_FORMATS
|
7
7
|
}
|
8
8
|
end
|
9
9
|
|
@@ -11,23 +11,18 @@ class ReeJson::FromJson
|
|
11
11
|
|
12
12
|
contract(
|
13
13
|
Any,
|
14
|
-
Kwargs[
|
15
|
-
mode: Or[*MODES]
|
16
|
-
],
|
17
14
|
Ksplat[
|
15
|
+
mode?: Or[*MODES],
|
18
16
|
symbol_keys?: Bool,
|
19
17
|
RestKeys => Any
|
20
|
-
] =>
|
18
|
+
] => Any
|
21
19
|
).throws(ParseJsonError)
|
22
|
-
def call(object,
|
20
|
+
def call(object, **opts)
|
23
21
|
options = DEFAULT_OPTIONS
|
24
|
-
.
|
25
|
-
.merge(
|
26
|
-
opts.merge(mode: mode)
|
27
|
-
)
|
22
|
+
.merge(opts)
|
28
23
|
|
29
24
|
Oj.load(object, options)
|
30
|
-
rescue ArgumentError, EncodingError
|
25
|
+
rescue ArgumentError, EncodingError, TypeError
|
31
26
|
raise ParseJsonError.new
|
32
27
|
end
|
33
28
|
end
|
@@ -18,10 +18,8 @@ class ReeJson::ToJson
|
|
18
18
|
|
19
19
|
contract(
|
20
20
|
Any,
|
21
|
-
Kwargs[
|
22
|
-
mode: Or[*MODES]
|
23
|
-
],
|
24
21
|
Ksplat[
|
22
|
+
mode?: Or[*MODES],
|
25
23
|
escape_mode?: Or[*ESCAPE_MODES],
|
26
24
|
float_precision?: Integer,
|
27
25
|
time_format?: Or[*TIME_FORMATS],
|
@@ -31,13 +29,10 @@ class ReeJson::ToJson
|
|
31
29
|
use_to_json?: Bool,
|
32
30
|
RestKeys => Any
|
33
31
|
] => String
|
34
|
-
|
35
|
-
def call(object,
|
32
|
+
).throws(ArgumentError, TypeError)
|
33
|
+
def call(object, **opts)
|
36
34
|
options = DEFAULT_OPTIONS
|
37
|
-
.
|
38
|
-
.merge(
|
39
|
-
opts.merge(mode: mode)
|
40
|
-
)
|
35
|
+
.merge(opts)
|
41
36
|
|
42
37
|
Oj.dump(object, options)
|
43
38
|
end
|
@@ -12,22 +12,17 @@
|
|
12
12
|
"throws": [
|
13
13
|
"ReeJson::FromJson::ParseJsonError"
|
14
14
|
],
|
15
|
-
"return": "
|
15
|
+
"return": "Any",
|
16
16
|
"args": [
|
17
17
|
{
|
18
18
|
"arg": "object",
|
19
19
|
"arg_type": "req",
|
20
20
|
"type": "Any"
|
21
21
|
},
|
22
|
-
{
|
23
|
-
"arg": "mode",
|
24
|
-
"arg_type": "key",
|
25
|
-
"type": "Or[strict, null, compat, json, rails, object, custom, wab]"
|
26
|
-
},
|
27
22
|
{
|
28
23
|
"arg": "opts",
|
29
24
|
"arg_type": "keyrest",
|
30
|
-
"type": "Ksplat[:symbol_keys? => Bool, \"RestKeys\" => Any]"
|
25
|
+
"type": "Ksplat[:mode? => Or[strict, null, compat, json, rails, object, custom, wab], :symbol_keys? => Bool, \"RestKeys\" => Any]"
|
31
26
|
}
|
32
27
|
]
|
33
28
|
}
|
@@ -10,7 +10,8 @@
|
|
10
10
|
{
|
11
11
|
"doc": "Dumps arbitrary object to json using specific dump mode.\n to_json({id: 1}) # => \"{\"id\":1}\"\n to_json({id: 1}, mode: :object) # => \"{\":id\":{\"^o\":\"Object\"}}\"\n\nList of all available Ksplat options could be found here:\nhttps://github.com/ohler55/oj/blob/develop/pages/Modes.md",
|
12
12
|
"throws": [
|
13
|
-
"ArgumentError"
|
13
|
+
"ArgumentError",
|
14
|
+
"TypeError"
|
14
15
|
],
|
15
16
|
"return": "String",
|
16
17
|
"args": [
|
@@ -19,15 +20,10 @@
|
|
19
20
|
"arg_type": "req",
|
20
21
|
"type": "Any"
|
21
22
|
},
|
22
|
-
{
|
23
|
-
"arg": "mode",
|
24
|
-
"arg_type": "key",
|
25
|
-
"type": "Or[strict, null, compat, json, rails, object, custom, wab]"
|
26
|
-
},
|
27
23
|
{
|
28
24
|
"arg": "opts",
|
29
25
|
"arg_type": "keyrest",
|
30
|
-
"type": "Ksplat[:escape_mode? => Or[newline, json, xss_safe, ascii, unicode_xss...], :float_precision? => Integer, :time_format? => Or[], :use_as_json? => Bool, :use_raw_json? => Bool, :use_to_hash? => Bool, :use_to_json? => Bool, \"RestKeys\" => Any]"
|
26
|
+
"type": "Ksplat[:mode? => Or[strict, null, compat, json, rails, object, custom, wab], :escape_mode? => Or[newline, json, xss_safe, ascii, unicode_xss...], :float_precision? => Integer, :time_format? => Or[], :use_as_json? => Bool, :use_raw_json? => Bool, :use_to_hash? => Bool, :use_to_json? => Bool, \"RestKeys\" => Any]"
|
31
27
|
}
|
32
28
|
]
|
33
29
|
}
|
@@ -12,7 +12,39 @@ RSpec.describe :from_json do
|
|
12
12
|
expect(result[:id]).to be_a(Object)
|
13
13
|
}
|
14
14
|
|
15
|
+
it {
|
16
|
+
expect(from_json("null")).to eq(nil)
|
17
|
+
}
|
18
|
+
|
19
|
+
it {
|
20
|
+
expect(from_json("true")).to eq(true)
|
21
|
+
}
|
22
|
+
|
23
|
+
it {
|
24
|
+
expect(from_json('"hello"')).to eq("hello")
|
25
|
+
}
|
26
|
+
|
27
|
+
it {
|
28
|
+
expect(from_json("123")).to eq(123)
|
29
|
+
}
|
30
|
+
|
31
|
+
it {
|
32
|
+
expect(from_json("123.456")).to eq(123.456)
|
33
|
+
}
|
34
|
+
|
35
|
+
it {
|
36
|
+
expect(from_json("[1,true,\"hello\"]")).to eq([1, true, "hello"])
|
37
|
+
}
|
38
|
+
|
39
|
+
it {
|
40
|
+
expect(from_json("{\"^o\":\"Object\"}", mode: :object)).to be_a(Object)
|
41
|
+
}
|
42
|
+
|
15
43
|
it {
|
16
44
|
expect{from_json("{213: \"123\"}")}.to raise_error(ReeJson::FromJson::ParseJsonError)
|
17
45
|
}
|
46
|
+
|
47
|
+
it {
|
48
|
+
expect { from_json(nil, mode: :strict) }.to raise_error(ReeJson::FromJson::ParseJsonError)
|
49
|
+
}
|
18
50
|
end
|
data/lib/ree_lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ree_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.66
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Gatiyatov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ree
|