ree_lib 1.0.65 → 1.0.67

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6a080727db9b2998d5e983aa2e024fd73833e6b98deb2f75eb8ac8309af1c6b
4
- data.tar.gz: b96cc24d1df8586e8159e96c7545017ecab7009a01bd5b9a2b9c759fb1beeddd
3
+ metadata.gz: adfdcee3c81364ab7af1c22fb56bd6b2d2f823b78f67264effce6b7e2af35852
4
+ data.tar.gz: 2991aa1e88c979c3b714bbf1da5facc68b52582a84001d43b8e1b304768125fb
5
5
  SHA512:
6
- metadata.gz: c1a8e3c1d0471a58cb3dd4602a83a8da2f30498e4af39f9ade709a256592d8f3a6ef6c58a14a8fff1c3f865d9508c49e5673d4bbbe8d0ddbe95fa5dd37074695
7
- data.tar.gz: 34e1a0221ad4040a469082111c63687903e6e5d6a89d25c8ada10f742efbd6774e0e8bc729c251670a5ef293b4917dfebe3c701be6155f84241a4a651d952b9c
6
+ metadata.gz: e9d848d9321212758be3e7051b408eedef55bcfb3d712e647f598f9e82510ea1b09275e4944fe89e8e83bce4650b36c2f02b59fdfe01e37bf7e8703911102ac3
7
+ data.tar.gz: 3c62a965cd9c5aeb588b984d3e2b9d93ef80698fe24fc7dafa0595a214443ec5d29e2ba91d7f8a424ee6410f3921dda339eefbeb2a4510c3999bc13532662f5f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.65)
4
+ ree_lib (1.0.67)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -38,9 +38,9 @@ GEM
38
38
  crass (~> 1.0.2)
39
39
  nokogiri (>= 1.5.9)
40
40
  msgpack (1.6.0)
41
- nokogiri (1.15.3-x86_64-darwin)
41
+ nokogiri (1.15.4-x86_64-darwin)
42
42
  racc (~> 1.4)
43
- nokogiri (1.15.3-x86_64-linux)
43
+ nokogiri (1.15.4-x86_64-linux)
44
44
  racc (~> 1.4)
45
45
  oj (3.13.23)
46
46
  pg (1.4.6)
@@ -68,7 +68,7 @@ class ReeDao::BuildConnection
68
68
  end
69
69
 
70
70
  if opts[:sql_log_level]
71
- connection.sql_log_level = opts[:sql_log_level]
71
+ connection.sql_log_level = opts[:sql_log_level]
72
72
  end
73
73
 
74
74
  Timeout::timeout(timeout) do
@@ -5,8 +5,8 @@ module ReeHttp
5
5
  DEFAULT_TIMEOUT = 60
6
6
  DEFAULT_WRITE_TIMEOUT = 30
7
7
  DEFAULT_FORCE_SSL = false
8
- HTTPS = 'https'
9
- HTTP = 'http'
8
+ HTTPS_STR = 'https'
9
+ HTTP_STR = 'http'
10
10
  HTTPS_PORT = 443
11
11
  HTTP_PORT = 80
12
12
  end
@@ -7,7 +7,7 @@ class ReeHttp::BuildRequest
7
7
  link :not_blank, from: :ree_object
8
8
  link :to_json, from: :ree_json
9
9
  link 'ree_http/constants', -> {
10
- HTTPS & HTTP & HTTPS_PORT & HTTP_PORT & DEFAULT_FORCE_SSL
10
+ HTTPS_STR & HTTP_STR & HTTPS_PORT & HTTP_PORT & DEFAULT_FORCE_SSL
11
11
  }
12
12
  end
13
13
 
@@ -49,7 +49,7 @@ class ReeHttp::BuildRequest
49
49
  opts = DEFAULTS.merge(opts)
50
50
  uri = URI(url)
51
51
 
52
- uri.scheme = opts[:force_ssl] ? HTTPS : uri.scheme
52
+ uri.scheme = opts[:force_ssl] ? HTTPS_STR : uri.scheme
53
53
 
54
54
  if DEFAULT_PROTOCOL_PORTS.include?(uri.port)
55
55
  uri.port = opts[:force_ssl] ? HTTPS_PORT : uri.port
@@ -5,7 +5,7 @@ class ReeHttp::BuildRequestExecutor
5
5
 
6
6
  fn :build_request_executor do
7
7
  link 'ree_http/constants', -> {
8
- HTTPS & DEFAULT_TIMEOUT & DEFAULT_WRITE_TIMEOUT & DEFAULT_FORCE_SSL
8
+ HTTPS_STR & DEFAULT_TIMEOUT & DEFAULT_WRITE_TIMEOUT & DEFAULT_FORCE_SSL
9
9
  }
10
10
  end
11
11
 
@@ -47,7 +47,7 @@ class ReeHttp::BuildRequestExecutor
47
47
  request_executor.write_timeout = opts[:write_timeout]
48
48
  request_executor.read_timeout = opts[:timeout]
49
49
 
50
- request_executor.use_ssl = opts[:force_ssl] || uri.scheme == HTTPS
50
+ request_executor.use_ssl = opts[:force_ssl] || uri.scheme == HTTPS_STR
51
51
 
52
52
 
53
53
  if opts[:ca_certs?]
@@ -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 & ESCAPE_MODES & TIME_FORMATS
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
- ] => Hash
18
+ ] => Any
21
19
  ).throws(ParseJsonError)
22
- def call(object, mode: :rails, **opts)
20
+ def call(object, **opts)
23
21
  options = DEFAULT_OPTIONS
24
- .dup
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
- ).throws(ArgumentError)
35
- def call(object, mode: :rails, **opts)
32
+ ).throws(ArgumentError, TypeError)
33
+ def call(object, **opts)
36
34
  options = DEFAULT_OPTIONS
37
- .dup
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": "Hash",
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.65"
4
+ VERSION = "1.0.67"
5
5
  end
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.65
4
+ version: 1.0.67
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-01 00:00:00.000000000 Z
11
+ date: 2023-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ree