smart_initializer 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +3 -2
- data/README.md +5 -0
- data/gemfiles/with_external_deps.gemfile.lock +5 -4
- data/gemfiles/without_external_deps.gemfile.lock +3 -2
- data/lib/smart_core/initializer/attribute/factory/base.rb +12 -3
- data/lib/smart_core/initializer/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0298953ea16ae53d51961bc46a26eefcba667f4a7d07d9d09e7d59b33f68760e'
|
4
|
+
data.tar.gz: 1cdd0cde6871dcccc17641ad2870d71da26e4385f8e2df93affb96577d67f6b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c3cf5f55e9d79003a48d655eac65470029d2b7b2565e19dee0114168585c32a4b101405635492d5431e8e8041b2d09f7a805574ea356561d12470d321878a9a
|
7
|
+
data.tar.gz: 558a0037b339802ee10a9a4a60b2841cc8f6256bfa3d8576e65351d531c393cbd9542e988a5c49ecb7d30e3cae27a7b57b6f1dbb643cd56771fa3cdbb6e17315
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.9.1] - 2022-03-06
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- `finalize` now accepts lambdas with arity `-2`. For example `->(a, *b) {}` or `:freeze.to_proc`
|
9
|
+
which in `Ruby >= 3` returns lambda with arity equal to `-2`.
|
10
|
+
|
4
11
|
## [0.9.0] - 2021-12-19
|
5
12
|
### Changed
|
6
13
|
- `:finalize` block is not invoked on the `option` with `optional: true` flag;
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
smart_initializer (0.9.
|
4
|
+
smart_initializer (0.9.1)
|
5
5
|
qonfig (~> 0.24)
|
6
6
|
smart_engine (~> 0.11)
|
7
7
|
smart_types (~> 0.4)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
pry (0.14.1)
|
37
37
|
coderay (~> 1.1)
|
38
38
|
method_source (~> 1.0)
|
39
|
-
qonfig (0.
|
39
|
+
qonfig (0.27.0)
|
40
40
|
rack (2.2.3)
|
41
41
|
rainbow (3.0.0)
|
42
42
|
rake (13.0.6)
|
@@ -96,6 +96,7 @@ PLATFORMS
|
|
96
96
|
x86_64-darwin-19
|
97
97
|
x86_64-darwin-20
|
98
98
|
x86_64-darwin-21
|
99
|
+
x86_64-linux
|
99
100
|
|
100
101
|
DEPENDENCIES
|
101
102
|
armitage-rubocop (~> 1.23)
|
data/README.md
CHANGED
@@ -71,6 +71,9 @@ in order to guarantee the validity of the SmartCore::Initializer's functionality
|
|
71
71
|
2. *(if defined)*: `default value` (default value is used when `original value` is not defined)
|
72
72
|
3. *(if defined)*: `finalize`;
|
73
73
|
|
74
|
+
- if `default`-object is a proc-object - this proc-object will be invoked in the `outer scope` of block definition;
|
75
|
+
- if `finalize`-object is a proc-object - this proc-object will be invoked in the `isntance` context (class instance);
|
76
|
+
|
74
77
|
**NOTE**: `:finalize` block are not invoked on omitted `optional: true` attributes
|
75
78
|
which has no `:default` definition bock and which are not passed to the constructor. Example:
|
76
79
|
|
@@ -96,6 +99,8 @@ end
|
|
96
99
|
User.new.age # => '0_years'
|
97
100
|
```
|
98
101
|
|
102
|
+
---
|
103
|
+
|
99
104
|
### Constructor definition DSL
|
100
105
|
|
101
106
|
**NOTE**: last `Hash` argument will be treated as `kwarg`s;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
smart_initializer (0.
|
4
|
+
smart_initializer (0.9.1)
|
5
5
|
qonfig (~> 0.24)
|
6
6
|
smart_engine (~> 0.11)
|
7
7
|
smart_types (~> 0.4)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
pry (0.14.1)
|
37
37
|
coderay (~> 1.1)
|
38
38
|
method_source (~> 1.0)
|
39
|
-
qonfig (0.
|
39
|
+
qonfig (0.27.0)
|
40
40
|
rack (2.2.3)
|
41
41
|
rainbow (3.0.0)
|
42
42
|
rake (13.0.3)
|
@@ -84,7 +84,7 @@ GEM
|
|
84
84
|
simplecov_json_formatter (~> 0.1)
|
85
85
|
simplecov-html (0.12.3)
|
86
86
|
simplecov_json_formatter (0.1.2)
|
87
|
-
smart_engine (0.
|
87
|
+
smart_engine (0.12.0)
|
88
88
|
smart_types (0.7.0)
|
89
89
|
smart_engine (~> 0.11)
|
90
90
|
thy (0.1.4)
|
@@ -96,6 +96,7 @@ GEM
|
|
96
96
|
PLATFORMS
|
97
97
|
x86_64-darwin-20
|
98
98
|
x86_64-darwin-21
|
99
|
+
x86_64-linux
|
99
100
|
|
100
101
|
DEPENDENCIES
|
101
102
|
armitage-rubocop (~> 1.23)
|
@@ -108,4 +109,4 @@ DEPENDENCIES
|
|
108
109
|
thy (~> 0.1.4)
|
109
110
|
|
110
111
|
BUNDLED WITH
|
111
|
-
2.2.
|
112
|
+
2.2.32
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
smart_initializer (0.
|
4
|
+
smart_initializer (0.9.1)
|
5
5
|
qonfig (~> 0.24)
|
6
6
|
smart_engine (~> 0.11)
|
7
7
|
smart_types (~> 0.4)
|
@@ -35,7 +35,7 @@ GEM
|
|
35
35
|
pry (0.14.1)
|
36
36
|
coderay (~> 1.1)
|
37
37
|
method_source (~> 1.0)
|
38
|
-
qonfig (0.
|
38
|
+
qonfig (0.27.0)
|
39
39
|
rack (2.2.3)
|
40
40
|
rainbow (3.0.0)
|
41
41
|
rake (13.0.3)
|
@@ -93,6 +93,7 @@ GEM
|
|
93
93
|
PLATFORMS
|
94
94
|
x86_64-darwin-20
|
95
95
|
x86_64-darwin-21
|
96
|
+
x86_64-linux
|
96
97
|
|
97
98
|
DEPENDENCIES
|
98
99
|
armitage-rubocop (~> 1.23)
|
@@ -81,6 +81,7 @@ class SmartCore::Initializer::Attribute::Factory::Base
|
|
81
81
|
#
|
82
82
|
# @api private
|
83
83
|
# @since 0.8.0
|
84
|
+
# @version 0.9.1
|
84
85
|
def prepare_finalize_param(finalize)
|
85
86
|
unless finalize.is_a?(::String) || finalize.is_a?(::Symbol) || finalize.is_a?(::Proc)
|
86
87
|
raise(SmartCore::Initializer::ArgumentError, <<~ERROR_MESSAGE)
|
@@ -90,11 +91,12 @@ class SmartCore::Initializer::Attribute::Factory::Base
|
|
90
91
|
|
91
92
|
# rubocop:disable Style/SoleNestedConditional
|
92
93
|
if finalize.is_a?(::Proc) && finalize.lambda?
|
93
|
-
unless
|
94
|
+
unless allowed_lambda_arity.bsearch { |element| finalize.arity <=> element }
|
94
95
|
raise(
|
95
96
|
SmartCore::Initializer::ArgumentError,
|
96
|
-
|
97
|
-
|
97
|
+
"Lambda-based finalizer should have arity " \
|
98
|
+
"equal to #{allowed_lambda_arity.join(', ')} " \
|
99
|
+
"(your lambda object should require one attribute)"
|
98
100
|
) # TODO: show the name of attribute in error message (if the name is a valid, of course)
|
99
101
|
end
|
100
102
|
end
|
@@ -103,6 +105,13 @@ class SmartCore::Initializer::Attribute::Factory::Base
|
|
103
105
|
SmartCore::Initializer::Attribute::Finalizer.create(finalize)
|
104
106
|
end
|
105
107
|
|
108
|
+
# return [Array<Integer>]
|
109
|
+
# @api private
|
110
|
+
# @since 0.9.1
|
111
|
+
def allowed_lambda_arity
|
112
|
+
@allowed_lambda_arity ||= [-2, -1, 1].freeze
|
113
|
+
end
|
114
|
+
|
106
115
|
# @param mutable [Boolean]
|
107
116
|
# @return [Boolean]
|
108
117
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_initializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smart_engine
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
246
|
- !ruby/object:Gem::Version
|
247
247
|
version: '0'
|
248
248
|
requirements: []
|
249
|
-
rubygems_version: 3.
|
249
|
+
rubygems_version: 3.3.0.dev
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: Initializer DSL
|