smart_schema 0.7.0 → 0.8.0

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: 027d45dbb44df86b67e3ddc73b11f045630f54d7b9e02cb797ef58afd1bead0f
4
- data.tar.gz: 35a7394123713a17fa5ef021a7f17ad6fe9667daf88780a981e89a5470bcaefc
3
+ metadata.gz: 9b77c587cbf99773471fe28e8113fe603dd9fc8eba4fd6509d87695976affaef
4
+ data.tar.gz: dfbc216a7537c38b3dd2bb2dec9d7ce1a66f3c8b37528e903372a0519a44319a
5
5
  SHA512:
6
- metadata.gz: 0d214fb0bd2cfca61d373c48a426ae55d027ef1955a0f718f74303f209bf7aea6a164ab79b4718bdca1bb5d18aa2ad00f8e6fe8f7ec107284dfe753931915df1
7
- data.tar.gz: 80be7069b581290cf95223272662c17f5b2058defe11d5d2ff09d13952af0fd36006ca383ccda7c2dbc163533076d34a3c6c1693699740299d38eb466dc9bfd0
6
+ metadata.gz: 130dbacff8c5765ad68f19dec163111d5e498f8464f1d3f8c954e15b45c6f278b5981373c9619964db316bc57c34d0b11a2b2782dde1eec5d777d672c918cf35
7
+ data.tar.gz: 36cde9131e10e969a7470b26d6a3a8ea6044d27c11e61f50e320073293026f5259ab52b51cbf69c3d72b739e54220258b44da56a98223f0dc63cd8e5813072eb
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ # [0.8.0] - 2022-09-30
5
+ ## Changed
6
+ - Decreased object allocations and mutex usage
7
+ - the one mutex of `SmartCore::Schema::Checker` is enough cuz this mutex covers the entire validation process);
8
+ - more retained objects in `SmartCore::Schema::Checker::Rules` (cache layer for rule names);
9
+ - Updated development dependencies;
10
+ - Updated `smart_engine` dependency (`0.7` -> `0.8`);
11
+
4
12
  # [0.7.0] - 2022-09-28
5
13
  ## Changed
6
14
  - Started the total code refactoring in order to decrease object and memory allocations:
data/Gemfile.lock CHANGED
@@ -1,98 +1,95 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_schema (0.7.0)
5
- smart_engine (~> 0.11)
4
+ smart_schema (0.8.0)
5
+ smart_engine (~> 0.13)
6
6
  smart_types (~> 0.4)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.1.1)
11
+ activesupport (7.0.4)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
15
15
  tzinfo (~> 2.0)
16
- zeitwerk (~> 2.3)
17
- armitage-rubocop (1.7.0.1)
18
- rubocop (= 1.7.0)
19
- rubocop-performance (= 1.9.1)
20
- rubocop-rails (= 2.9.1)
21
- rubocop-rake (= 0.5.1)
22
- rubocop-rspec (= 2.1.0)
23
- ast (2.4.1)
16
+ armitage-rubocop (1.30.1.1)
17
+ rubocop (= 1.30.1)
18
+ rubocop-performance (= 1.14.2)
19
+ rubocop-rails (= 2.15.0)
20
+ rubocop-rake (= 0.6.0)
21
+ rubocop-rspec (= 2.11.1)
22
+ ast (2.4.2)
24
23
  coderay (1.1.3)
25
- concurrent-ruby (1.1.7)
26
- diff-lcs (1.4.4)
27
- docile (1.3.5)
28
- i18n (1.8.7)
24
+ concurrent-ruby (1.1.10)
25
+ diff-lcs (1.5.0)
26
+ docile (1.4.0)
27
+ i18n (1.12.0)
29
28
  concurrent-ruby (~> 1.0)
30
29
  method_source (1.0.0)
31
- minitest (5.14.3)
32
- parallel (1.20.1)
33
- parser (3.0.0.0)
30
+ minitest (5.16.3)
31
+ parallel (1.22.1)
32
+ parser (3.1.2.1)
34
33
  ast (~> 2.4.1)
35
- pry (0.13.1)
34
+ pry (0.14.1)
36
35
  coderay (~> 1.1)
37
36
  method_source (~> 1.0)
38
- rack (2.2.3)
39
- rainbow (3.0.0)
40
- rake (13.0.3)
41
- regexp_parser (2.0.3)
42
- rexml (3.2.4)
43
- rspec (3.10.0)
44
- rspec-core (~> 3.10.0)
45
- rspec-expectations (~> 3.10.0)
46
- rspec-mocks (~> 3.10.0)
47
- rspec-core (3.10.1)
48
- rspec-support (~> 3.10.0)
49
- rspec-expectations (3.10.1)
37
+ rack (3.0.0)
38
+ rainbow (3.1.1)
39
+ rake (13.0.6)
40
+ regexp_parser (2.6.0)
41
+ rexml (3.2.5)
42
+ rspec (3.11.0)
43
+ rspec-core (~> 3.11.0)
44
+ rspec-expectations (~> 3.11.0)
45
+ rspec-mocks (~> 3.11.0)
46
+ rspec-core (3.11.0)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-expectations (3.11.1)
50
49
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.10.0)
52
- rspec-mocks (3.10.1)
50
+ rspec-support (~> 3.11.0)
51
+ rspec-mocks (3.11.1)
53
52
  diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.10.0)
55
- rspec-support (3.10.1)
56
- rubocop (1.7.0)
53
+ rspec-support (~> 3.11.0)
54
+ rspec-support (3.11.1)
55
+ rubocop (1.30.1)
57
56
  parallel (~> 1.10)
58
- parser (>= 2.7.1.5)
57
+ parser (>= 3.1.0.0)
59
58
  rainbow (>= 2.2.2, < 4.0)
60
59
  regexp_parser (>= 1.8, < 3.0)
61
- rexml
62
- rubocop-ast (>= 1.2.0, < 2.0)
60
+ rexml (>= 3.2.5, < 4.0)
61
+ rubocop-ast (>= 1.18.0, < 2.0)
63
62
  ruby-progressbar (~> 1.7)
64
- unicode-display_width (>= 1.4.0, < 2.0)
65
- rubocop-ast (1.4.0)
66
- parser (>= 2.7.1.5)
67
- rubocop-performance (1.9.1)
68
- rubocop (>= 0.90.0, < 2.0)
63
+ unicode-display_width (>= 1.4.0, < 3.0)
64
+ rubocop-ast (1.21.0)
65
+ parser (>= 3.1.1.0)
66
+ rubocop-performance (1.14.2)
67
+ rubocop (>= 1.7.0, < 2.0)
69
68
  rubocop-ast (>= 0.4.0)
70
- rubocop-rails (2.9.1)
69
+ rubocop-rails (2.15.0)
71
70
  activesupport (>= 4.2.0)
72
71
  rack (>= 1.1)
73
- rubocop (>= 0.90.0, < 2.0)
74
- rubocop-rake (0.5.1)
75
- rubocop
76
- rubocop-rspec (2.1.0)
72
+ rubocop (>= 1.7.0, < 2.0)
73
+ rubocop-rake (0.6.0)
77
74
  rubocop (~> 1.0)
78
- rubocop-ast (>= 1.1.0)
75
+ rubocop-rspec (2.11.1)
76
+ rubocop (~> 1.19)
79
77
  ruby-progressbar (1.11.0)
80
78
  simplecov (0.21.2)
81
79
  docile (~> 1.1)
82
80
  simplecov-html (~> 0.11)
83
81
  simplecov_json_formatter (~> 0.1)
84
82
  simplecov-html (0.12.3)
85
- simplecov_json_formatter (0.1.2)
86
- smart_engine (0.12.0)
83
+ simplecov_json_formatter (0.1.4)
84
+ smart_engine (0.13.0)
87
85
  smart_types (0.7.1)
88
86
  smart_engine (~> 0.11)
89
- tzinfo (2.0.4)
87
+ tzinfo (2.0.5)
90
88
  concurrent-ruby (~> 1.0)
91
- unicode-display_width (1.7.0)
92
- zeitwerk (2.4.2)
89
+ unicode-display_width (2.3.0)
93
90
 
94
91
  PLATFORMS
95
- ruby
92
+ arm64-darwin-21
96
93
 
97
94
  DEPENDENCIES
98
95
  armitage-rubocop (~> 1.7)
@@ -104,4 +101,4 @@ DEPENDENCIES
104
101
  smart_schema!
105
102
 
106
103
  BUNDLED WITH
107
- 2.3.0.dev
104
+ 2.3.17
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
+ # @version 0.8.0
5
6
  class SmartCore::Schema::Checker::Reconciler::Matcher::Result
6
7
  # @return [Hash<String|Symbol,Any>]
7
8
  #
@@ -28,9 +29,9 @@ class SmartCore::Schema::Checker::Reconciler::Matcher::Result
28
29
  #
29
30
  # @api private
30
31
  # @since 0.1.0
32
+ # @version 0.8.0
31
33
  def initialize(verifiable_hash)
32
34
  @verifiable_hash = verifiable_hash
33
- @lock = SmartCore::Engine::Lock.new
34
35
  @contract_keys_results = []
35
36
  @extra_keys_results = []
36
37
  end
@@ -46,11 +47,10 @@ class SmartCore::Schema::Checker::Reconciler::Matcher::Result
46
47
  #
47
48
  # @api private
48
49
  # @since 0.1.0
50
+ # @version 0.8.0
49
51
  def each_result(&block)
50
- @lock.synchronize do
51
- contract_keys_results.each(&block)
52
- extra_keys_results.each(&block)
53
- end
52
+ contract_keys_results.each(&block)
53
+ extra_keys_results.each(&block)
54
54
  end
55
55
 
56
56
  # @param result [SmartCore::Schema::Checker::Rules::Verifier::Result]
@@ -58,8 +58,9 @@ class SmartCore::Schema::Checker::Reconciler::Matcher::Result
58
58
  #
59
59
  # @api private
60
60
  # @since 0.1.0
61
+ # @version 0.8.0
61
62
  def contract_key_result(result)
62
- @lock.synchronize { contract_keys_results << result }
63
+ contract_keys_results << result
63
64
  end
64
65
 
65
66
  # @param result [
@@ -70,17 +71,17 @@ class SmartCore::Schema::Checker::Reconciler::Matcher::Result
70
71
  #
71
72
  # @api private
72
73
  # @since 0.1.0
74
+ # @version 0.8.0
73
75
  def extra_keys_result(result)
74
- @lock.synchronize { extra_keys_results << result }
76
+ extra_keys_results << result
75
77
  end
76
78
 
77
79
  # @return [SmartCore::Schema::Result]
78
80
  #
79
81
  # @api private
80
82
  # @since 0.1.0
83
+ # @version 0.8.0
81
84
  def complete!
82
- @lock.synchronize do
83
- SmartCore::Schema::Checker::Reconciler::Matcher::ResultFinalizer.finalize(self)
84
- end
85
+ SmartCore::Schema::Checker::Reconciler::Matcher::ResultFinalizer.finalize(self)
85
86
  end
86
87
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
- # @version 0.3.0
5
+ # @version 0.8.0
6
6
  class SmartCore::Schema::Checker::Reconciler
7
7
  require_relative 'reconciler/constructor'
8
8
  require_relative 'reconciler/matcher'
@@ -15,7 +15,6 @@ class SmartCore::Schema::Checker::Reconciler
15
15
  def initialize
16
16
  @rules = SmartCore::Schema::Checker::Rules.new
17
17
  @strict = Constructor::DEFAULT_STRICT_BEHAVIOR
18
- @lock = SmartCore::Engine::Lock.new
19
18
  end
20
19
 
21
20
  # @param verifiable_hash [SmartCore::Schema::Checker::VerifiableHash]
@@ -23,8 +22,9 @@ class SmartCore::Schema::Checker::Reconciler
23
22
  #
24
23
  # @api private
25
24
  # @since 0.1.0
25
+ # @version 0.8.0
26
26
  def __match!(verifiable_hash)
27
- thread_safe { SmartCore::Schema::Checker::Reconciler::Matcher.match(self, verifiable_hash) }
27
+ SmartCore::Schema::Checker::Reconciler::Matcher.match(self, verifiable_hash)
28
28
  end
29
29
 
30
30
  # @return [SmartCore::Schema::Checker::Rules::ExtraKeys]
@@ -39,16 +39,18 @@ class SmartCore::Schema::Checker::Reconciler
39
39
  #
40
40
  # @api private
41
41
  # @since 0.1.0
42
+ # @version 0.8.0
42
43
  def __contract_rules
43
- thread_safe { rules }
44
+ rules
44
45
  end
45
46
 
46
47
  # @return [Boolean]
47
48
  #
48
49
  # @api private
49
50
  # @since 0.3.0
51
+ # @version 0.8.0
50
52
  def __strict?
51
- thread_safe { @strict }
53
+ @strict
52
54
  end
53
55
 
54
56
  # @param schema_key [String, Symbol]
@@ -57,12 +59,10 @@ class SmartCore::Schema::Checker::Reconciler
57
59
  #
58
60
  # @api public
59
61
  # @since 0.1.0
60
- # @version 0.3.0
62
+ # @version 0.8.0
61
63
  def required(schema_key, &nested_definitions)
62
- thread_safe do
63
- rule = SmartCore::Schema::Checker::Rules::Required.new(self, schema_key, &nested_definitions)
64
- rule.tap { rules[rule.schema_key] = rule }
65
- end
64
+ rule = SmartCore::Schema::Checker::Rules::Required.new(self, schema_key, &nested_definitions)
65
+ rule.tap { rules[rule.schema_key] = rule }
66
66
  end
67
67
 
68
68
  # @param schema_key [String, Symbol]
@@ -71,12 +71,10 @@ class SmartCore::Schema::Checker::Reconciler
71
71
  #
72
72
  # @api public
73
73
  # @since 0.1.0
74
- # @version 0.3.0
74
+ # @version 0.8.0
75
75
  def optional(schema_key, &nested_definitions)
76
- thread_safe do
77
- rule = SmartCore::Schema::Checker::Rules::Optional.new(self, schema_key, &nested_definitions)
78
- rule.tap { rules[rule.schema_key] = rule }
79
- end
76
+ rule = SmartCore::Schema::Checker::Rules::Optional.new(self, schema_key, &nested_definitions)
77
+ rule.tap { rules[rule.schema_key] = rule }
80
78
  end
81
79
 
82
80
  # @param is_strict [Boolean]
@@ -84,16 +82,18 @@ class SmartCore::Schema::Checker::Reconciler
84
82
  #
85
83
  # @api public
86
84
  # @since 0.3.0
85
+ # @version 0.8.0
87
86
  def strict!(is_strict = Constructor::DEFAULT_STRICT_BEHAVIOR)
88
- thread_safe { @strict = is_strict }
87
+ @strict = is_strict
89
88
  end
90
89
 
91
90
  # @return [void]
92
91
  #
93
92
  # @api public
94
93
  # @since 0.3.0
94
+ # @version 0.8.0
95
95
  def non_strict!
96
- thread_safe { strict!(Constructor::STRICT_MODES[:non_strict]) }
96
+ strict!(Constructor::STRICT_MODES[:non_strict])
97
97
  end
98
98
 
99
99
  private
@@ -103,13 +103,4 @@ class SmartCore::Schema::Checker::Reconciler
103
103
  # @api private
104
104
  # @since 0.1.0
105
105
  attr_reader :rules
106
-
107
- # @param block [Block]
108
- # @return [Any]
109
- #
110
- # @api private
111
- # @since 0.1.0
112
- def thread_safe(&block)
113
- @lock.synchronize(&block)
114
- end
115
106
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
- # @version 0.3.0
5
+ # @version 0.8.0
6
6
  class SmartCore::Schema::Checker::Rules::Base
7
7
  # @return [String]
8
8
  #
@@ -35,9 +35,8 @@ class SmartCore::Schema::Checker::Rules::Base
35
35
  #
36
36
  # @api private
37
37
  # @since 0.1.0
38
- # @version 0.3.0
38
+ # @version 0.8.0
39
39
  def initialize(root_reconciler, schema_key, &nested_definitions)
40
- @lock = SmartCore::Engine::Lock.new
41
40
  @root_reconciler = root_reconciler
42
41
  @schema_key = SmartCore::Schema::KeyControl.normalize(schema_key)
43
42
  @options = SmartCore::Schema::Checker::Rules::Options.new(self)
@@ -68,12 +67,11 @@ class SmartCore::Schema::Checker::Rules::Base
68
67
  #
69
68
  # @api public
70
69
  # @since 0.1.0
70
+ # @version 0.8.0
71
71
  def type(required_type, &nested_definitions)
72
- thread_safe do
73
- tap do
74
- options.type = SmartCore::Schema::Checker::Rules::Options::Type.new(self, required_type)
75
- define_nested_reconciler(&nested_definitions)
76
- end
72
+ tap do
73
+ options.type = SmartCore::Schema::Checker::Rules::Options::Type.new(self, required_type)
74
+ define_nested_reconciler(&nested_definitions)
77
75
  end
78
76
  end
79
77
 
@@ -82,12 +80,11 @@ class SmartCore::Schema::Checker::Rules::Base
82
80
  #
83
81
  # @api public
84
82
  # @since 0.1.0
83
+ # @version 0.8.0
85
84
  def filled(&nested_definitions)
86
- thread_safe do
87
- tap do
88
- options.filled = SmartCore::Schema::Checker::Rules::Options::Filled.new(self)
89
- define_nested_reconciler(&nested_definitions)
90
- end
85
+ tap do
86
+ options.filled = SmartCore::Schema::Checker::Rules::Options::Filled.new(self)
87
+ define_nested_reconciler(&nested_definitions)
91
88
  end
92
89
  end
93
90
 
@@ -110,12 +107,4 @@ class SmartCore::Schema::Checker::Rules::Base
110
107
 
111
108
  type(:hash).filled
112
109
  end
113
-
114
- # @return [Any]
115
- #
116
- # @api private
117
- # @since 0.1.0
118
- def thread_safe(&block)
119
- @lock.synchronize(&block)
120
- end
121
110
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
+ # @version 0.8.0
5
6
  class SmartCore::Schema::Checker::Rules::Options
6
7
  require_relative 'options/empty'
7
8
  require_relative 'options/type'
@@ -15,7 +16,6 @@ class SmartCore::Schema::Checker::Rules::Options
15
16
  def initialize(rule)
16
17
  @type = Empty.new(rule)
17
18
  @filled = Empty.new(rule)
18
- @lock = SmartCore::Engine::Lock.new
19
19
  end
20
20
 
21
21
  # @return [SmartCore::Schema::Checker::Rules::Options::Type]
@@ -23,8 +23,9 @@ class SmartCore::Schema::Checker::Rules::Options
23
23
  #
24
24
  # @api private
25
25
  # @since 0.1.0
26
+ # @version 0.8.0
26
27
  def type
27
- @lock.synchronize { @type }
28
+ @type
28
29
  end
29
30
 
30
31
  # @param option [SmartCore::Schema::Checker::Rules::Options::Type]
@@ -32,8 +33,9 @@ class SmartCore::Schema::Checker::Rules::Options
32
33
  #
33
34
  # @api private
34
35
  # @since 0.1.0
36
+ # @version 0.8.0
35
37
  def type=(option)
36
- @lock.synchronize { @type = option }
38
+ @type = option
37
39
  end
38
40
 
39
41
  # @return [SmartCore::Schema::Checker::Rules::Options::Filled]
@@ -41,8 +43,9 @@ class SmartCore::Schema::Checker::Rules::Options
41
43
  #
42
44
  # @api private
43
45
  # @since 0.1.0
46
+ # @version 0.8.0
44
47
  def filled
45
- @lock.synchronize { @filled }
48
+ @filled
46
49
  end
47
50
 
48
51
  # @param option [SmartCore::Schema::Checker::Rules::Options::Filled]
@@ -50,7 +53,8 @@ class SmartCore::Schema::Checker::Rules::Options
50
53
  #
51
54
  # @api private
52
55
  # @since 0.1.0
56
+ # @version 0.8.0
53
57
  def filled=(option)
54
- @lock.synchronize { @filled = option }
58
+ @filled = option
55
59
  end
56
60
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
+ # @version 0.8.0
5
6
  class SmartCore::Schema::Checker::Rules
6
7
  require_relative 'rules/type_aliases'
7
8
  require_relative 'rules/base'
@@ -20,9 +21,10 @@ class SmartCore::Schema::Checker::Rules
20
21
  #
21
22
  # @api private
22
23
  # @since 0.1.0
24
+ # @version 0.8.0
23
25
  def initialize
24
26
  @rules = {}
25
- @lock = SmartCore::Engine::Lock.new
27
+ @cache = SmartCore::Engine::Cache.new
26
28
  end
27
29
 
28
30
  # @param schema_key [String]
@@ -31,8 +33,10 @@ class SmartCore::Schema::Checker::Rules
31
33
  #
32
34
  # @api private
33
35
  # @since 0.1.0
36
+ # @version 0.8..0
34
37
  def []=(schema_key, rule)
35
- thread_safe { rules[schema_key] = rule }
38
+ cache.clear
39
+ rules[schema_key] = rule
36
40
  end
37
41
 
38
42
  # @param block [Block]
@@ -43,8 +47,9 @@ class SmartCore::Schema::Checker::Rules
43
47
  #
44
48
  # @api private
45
49
  # @since 0.1.0
50
+ # @version 0.8.0
46
51
  def each(&block)
47
- thread_safe { block_given? ? rules.each_pair(&block) : rules.each_pair }
52
+ block_given? ? rules.each_pair(&block) : rules.each_pair
48
53
  end
49
54
 
50
55
  # @param block [Block]
@@ -54,16 +59,18 @@ class SmartCore::Schema::Checker::Rules
54
59
  #
55
60
  # @api private
56
61
  # @since 0.1.0
62
+ # @version 0.8.0
57
63
  def each_rule(&block)
58
- thread_safe { block_given? ? rules.each_value(&block) : rules.each_value }
64
+ block_given? ? rules.each_value(&block) : rules.each_value
59
65
  end
60
66
 
61
67
  # @return [Array<String>]
62
68
  #
63
69
  # @api private
64
70
  # @since 0.1.0
71
+ # @version 0.8.0
65
72
  def keys
66
- thread_safe { rules.keys }
73
+ cache.read(:keys) { rules.keys }
67
74
  end
68
75
 
69
76
  private
@@ -74,12 +81,9 @@ class SmartCore::Schema::Checker::Rules
74
81
  # @since 0.1.0
75
82
  attr_reader :rules
76
83
 
77
- # @param block [Block]
78
- # @return [Any]
84
+ # @return [SmartCore::Engine::Cache]
79
85
  #
80
86
  # @api private
81
- # @since 0.1.0
82
- def thread_safe(&block)
83
- @lock.synchronize(&block)
84
- end
87
+ # @since 0.8.0
88
+ attr_reader :cache
85
89
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
- # @version 0.7.0
5
+ # @version 0.8.0
6
6
  class SmartCore::Schema::Checker::VerifiableHash
7
7
  # @return [Hash<String|Symbol,Any>]
8
8
  #
@@ -17,24 +17,24 @@ class SmartCore::Schema::Checker::VerifiableHash
17
17
  # @since 0.1.0
18
18
  def initialize(source)
19
19
  @source = source
20
- @lock = SmartCore::Engine::Lock.new
21
20
  end
22
21
 
23
22
  # @param key [String]
24
23
  # @return [SmartCore::Schema::Checker::VerifiableHash]
25
24
  #
26
25
  # @api private
27
- # @since 0.1.0
26
+ # @since 0.8.0
28
27
  def extract(key)
29
- @lock.synchronize { SmartCore::Schema::Checker::VerifiableHash.new(fetch(key)) }
28
+ SmartCore::Schema::Checker::VerifiableHash.new(fetch(key))
30
29
  end
31
30
 
32
31
  # @return [Array<String>]
33
32
  #
34
33
  # @api private
35
34
  # @since 0.1.0
35
+ # @version 0.8.0
36
36
  def keys
37
- @lock.synchronize { SmartCore::Schema::KeyControl.normalize_list(source.keys) }
37
+ SmartCore::Schema::KeyControl.normalize_list(source.keys)
38
38
  end
39
39
 
40
40
  # @param key [String]
@@ -42,8 +42,9 @@ class SmartCore::Schema::Checker::VerifiableHash
42
42
  #
43
43
  # @api private
44
44
  # @since 0.1.0
45
+ # @version 0.8.0
45
46
  def key?(key)
46
- @lock.synchronize { source.key?(key) || source.key?(key.to_sym) }
47
+ source.key?(key) || source.key?(key.to_sym)
47
48
  end
48
49
 
49
50
  # @param key [String]
@@ -51,18 +52,14 @@ class SmartCore::Schema::Checker::VerifiableHash
51
52
  #
52
53
  # @api private
53
54
  # @since 0.1.0
54
- # @version 0.7.0
55
+ # @version 0.8.0
55
56
  def fetch(key)
56
- # rubocop:disable Style/RedundantBegin
57
- @lock.synchronize do
58
- # @note
59
- # Previously we used exceptional flow "hash.fetch(key) rescue hash.fetch(key.to_sym)".
60
- # This flow can generate a lot of useless objects during rescuable `KeyError` exception
61
- # (useless error messages, backtraces, etc, object that was silently suppressed).
62
- # So, the "if"-#key?-oriented flow is better (generates fewer number of objects statistically).
63
- source.key?(key) ? source.fetch(key) : source.fetch(key.to_sym)
64
- end
65
- # rubocop:enable Style/RedundantBegin
57
+ # @note
58
+ # Previously we used exceptional flow "hash.fetch(key) rescue hash.fetch(key.to_sym)".
59
+ # This flow can generate a lot of useless objects during rescuable `KeyError` exception
60
+ # (useless error messages, backtraces, etc, object that was silently suppressed).
61
+ # So, the "if"-#key?-oriented flow is better (generates fewer number of objects statistically)
62
+ source.key?(key) ? source.fetch(key) : source.fetch(key.to_sym)
66
63
  end
67
64
  alias_method :[], :fetch
68
65
  end
@@ -7,8 +7,8 @@ module SmartCore
7
7
  #
8
8
  # @api public
9
9
  # @since 0.1.0
10
- # @version 0.7.0
11
- VERSION = '0.7.0'
10
+ # @version 0.8.0
11
+ VERSION = '0.8.0'
12
12
  end
13
13
  # rubocop:enable Style/StaticClass
14
14
  end
data/smart_schema.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
32
 
33
- spec.add_dependency 'smart_engine', '~> 0.11'
33
+ spec.add_dependency 'smart_engine', '~> 0.13'
34
34
  spec.add_dependency 'smart_types', '~> 0.4'
35
35
 
36
36
  spec.add_development_dependency 'pry', '~> 0.13'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-28 00:00:00.000000000 Z
11
+ date: 2022-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_engine
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.11'
19
+ version: '0.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.11'
26
+ version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: smart_types
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []
204
- rubygems_version: 3.3.0.dev
204
+ rubygems_version: 3.3.11
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: SmartCore::Schema is a schema validator for Hash-like data structures