smart_initializer 0.9.1 → 0.10.0
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 -2
- data/Gemfile.lock +49 -54
- data/gemfiles/with_external_deps.gemfile.lock +51 -55
- data/gemfiles/without_external_deps.gemfile.lock +51 -53
- data/lib/smart_core/initializer/attribute/list.rb +19 -20
- data/lib/smart_core/initializer/constructor/definer.rb +13 -19
- data/lib/smart_core/initializer/dsl.rb +4 -3
- data/lib/smart_core/initializer/extensions/list.rb +11 -14
- data/lib/smart_core/initializer/plugins/abstract.rb +3 -1
- data/lib/smart_core/initializer/plugins/registry.rb +13 -14
- data/lib/smart_core/initializer/plugins/registry_interface.rb +11 -19
- data/lib/smart_core/initializer/settings/auto_cast.rb +5 -11
- data/lib/smart_core/initializer/settings/base.rb +5 -13
- data/lib/smart_core/initializer/settings/strict_options.rb +5 -11
- data/lib/smart_core/initializer/settings/type_system.rb +7 -16
- data/lib/smart_core/initializer/type_system/interop/aliasing/alias_list.rb +18 -21
- data/lib/smart_core/initializer/type_system/registry.rb +22 -24
- data/lib/smart_core/initializer/type_system/registry_interface.rb +15 -22
- data/lib/smart_core/initializer/version.rb +2 -2
- data/smart_initializer.gemspec +5 -5
- metadata +13 -13
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# @api private
|
4
4
|
# @since 0.1.0
|
5
|
+
# @version 0.10.0
|
5
6
|
class SmartCore::Initializer::TypeSystem::Registry
|
6
7
|
# @since 0.1.0
|
7
8
|
include Enumerable
|
@@ -10,9 +11,10 @@ class SmartCore::Initializer::TypeSystem::Registry
|
|
10
11
|
#
|
11
12
|
# @api private
|
12
13
|
# @since 0.1.0
|
14
|
+
# @version 0.10.0
|
13
15
|
def initialize
|
14
16
|
@systems = {}
|
15
|
-
@lock = SmartCore::Engine::
|
17
|
+
@lock = SmartCore::Engine::ReadWriteLock.new
|
16
18
|
end
|
17
19
|
|
18
20
|
# @param system_identifier [String, Symbol]
|
@@ -21,8 +23,9 @@ class SmartCore::Initializer::TypeSystem::Registry
|
|
21
23
|
#
|
22
24
|
# @api private
|
23
25
|
# @since 0.1.0
|
26
|
+
# @version 0.10.0
|
24
27
|
def register(system_identifier, interop_klass)
|
25
|
-
|
28
|
+
@lock.write_sync { apply(system_identifier, interop_klass) }
|
26
29
|
end
|
27
30
|
|
28
31
|
# @param system_identifier [String, Symbol]
|
@@ -30,24 +33,27 @@ class SmartCore::Initializer::TypeSystem::Registry
|
|
30
33
|
#
|
31
34
|
# @api private
|
32
35
|
# @since 0.1.0
|
36
|
+
# @version 0.10.0
|
33
37
|
def resolve(system_identifier)
|
34
|
-
|
38
|
+
@lock.read_sync { fetch(system_identifier) }
|
35
39
|
end
|
36
40
|
|
37
41
|
# @return [Array<String>]
|
38
42
|
#
|
39
43
|
# @api private
|
40
44
|
# @since 0.1.0
|
45
|
+
# @version 0.10.0
|
41
46
|
def names
|
42
|
-
|
47
|
+
@lock.read_sync { system_names }
|
43
48
|
end
|
44
49
|
|
45
50
|
# @return [Array<Class<SmartCore::Initializer::TypeSystem::Interop>>]
|
46
51
|
#
|
47
52
|
# @api private
|
48
53
|
# @since 0.1.0
|
54
|
+
# @version 0.10.0
|
49
55
|
def interops
|
50
|
-
|
56
|
+
@lock.read_sync { system_interops }
|
51
57
|
end
|
52
58
|
|
53
59
|
# @param block [Block]
|
@@ -58,16 +64,18 @@ class SmartCore::Initializer::TypeSystem::Registry
|
|
58
64
|
#
|
59
65
|
# @api private
|
60
66
|
# @since 0.1.0
|
67
|
+
# @version 0.10.0
|
61
68
|
def each(&block)
|
62
|
-
|
69
|
+
@lock.read_sync { iterate(&block) }
|
63
70
|
end
|
64
71
|
|
65
72
|
# @return [Hash<String,Class<SmartCore::Initializer::TypeSystem::Interop>]
|
66
73
|
#
|
67
74
|
# @api private
|
68
75
|
# @since 0.1.0
|
76
|
+
# @version 0.10.0
|
69
77
|
def to_h
|
70
|
-
|
78
|
+
@lock.write_sync { systems.dup }
|
71
79
|
end
|
72
80
|
alias_method :to_hash, :to_h
|
73
81
|
|
@@ -126,17 +134,16 @@ class SmartCore::Initializer::TypeSystem::Registry
|
|
126
134
|
#
|
127
135
|
# @api private
|
128
136
|
# @since 0.1.0
|
129
|
-
# @version 0.
|
137
|
+
# @version 0.10.0
|
130
138
|
def fetch(system_identifier)
|
131
139
|
identifier = indifferently_accessible_identifier(system_identifier)
|
132
140
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
end
|
141
|
+
raise(
|
142
|
+
SmartCore::Initializer::UnsupportedTypeSystemError,
|
143
|
+
"`#{identifier}` type system is not supported."
|
144
|
+
) unless systems.key?(identifier)
|
145
|
+
|
146
|
+
systems.fetch(identifier)
|
140
147
|
end
|
141
148
|
|
142
149
|
# @param interop_klass [Class<SMartCore::Initializer::TypeSystem::Interop>]
|
@@ -163,13 +170,4 @@ class SmartCore::Initializer::TypeSystem::Registry
|
|
163
170
|
def indifferently_accessible_identifier(system_identifier)
|
164
171
|
system_identifier.to_s.clone.tap(&:freeze)
|
165
172
|
end
|
166
|
-
|
167
|
-
# @param block [Block]
|
168
|
-
# @return [Any]
|
169
|
-
#
|
170
|
-
# @api private
|
171
|
-
# @since 0.1.0
|
172
|
-
def thread_safe(&block)
|
173
|
-
@lock.synchronize(&block)
|
174
|
-
end
|
175
173
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# @api private
|
4
4
|
# @since 0.1.0
|
5
|
+
# @version 0.10.0
|
5
6
|
module SmartCore::Initializer::TypeSystem::RegistryInterface
|
6
7
|
class << self
|
7
8
|
# @param base_module [Class, Module]
|
@@ -9,12 +10,13 @@ module SmartCore::Initializer::TypeSystem::RegistryInterface
|
|
9
10
|
#
|
10
11
|
# @api private
|
11
12
|
# @since 0.1.0
|
13
|
+
# @version 0.10.0
|
12
14
|
def extended(base_module)
|
13
15
|
base_module.instance_variable_set(
|
14
16
|
:@registry, SmartCore::Initializer::TypeSystem::Registry.new
|
15
17
|
)
|
16
18
|
base_module.instance_variable_set(
|
17
|
-
:@access_lock, SmartCore::Engine::
|
19
|
+
:@access_lock, SmartCore::Engine::ReadWriteLock.new
|
18
20
|
)
|
19
21
|
end
|
20
22
|
end
|
@@ -25,8 +27,9 @@ module SmartCore::Initializer::TypeSystem::RegistryInterface
|
|
25
27
|
#
|
26
28
|
# @api private
|
27
29
|
# @since 0.1.0
|
30
|
+
# @version 0.10.0
|
28
31
|
def build_interop(system: system_identifier, type: type_object)
|
29
|
-
|
32
|
+
@access_lock.read_sync { registry.resolve(system_identifier).create(type_object) }
|
30
33
|
end
|
31
34
|
|
32
35
|
# @param identifier [String, Symbol]
|
@@ -35,8 +38,9 @@ module SmartCore::Initializer::TypeSystem::RegistryInterface
|
|
35
38
|
#
|
36
39
|
# @api private
|
37
40
|
# @since 0.1.0
|
41
|
+
# @version 0.10.0
|
38
42
|
def register(identifier, interop_klass)
|
39
|
-
|
43
|
+
@access_lock.write_sync { registry.register(identifier, interop_klass) }
|
40
44
|
end
|
41
45
|
|
42
46
|
# @param identifier [String, Symbol]
|
@@ -44,8 +48,9 @@ module SmartCore::Initializer::TypeSystem::RegistryInterface
|
|
44
48
|
#
|
45
49
|
# @api private
|
46
50
|
# @since 0.1.0
|
51
|
+
# @version 0.10.0
|
47
52
|
def resolve(identifier)
|
48
|
-
|
53
|
+
@access_lock.read_sync { registry.resolve(identifier) }
|
49
54
|
end
|
50
55
|
alias_method :[], :resolve
|
51
56
|
|
@@ -53,16 +58,18 @@ module SmartCore::Initializer::TypeSystem::RegistryInterface
|
|
53
58
|
#
|
54
59
|
# @api public
|
55
60
|
# @since 0.1.0
|
61
|
+
# @version 0.10.0
|
56
62
|
def names
|
57
|
-
|
63
|
+
@access_lock.read_sync { registry.names }
|
58
64
|
end
|
59
65
|
|
60
66
|
# @return [Array<Class<SmartCore::Initializer::TypeSystem::Interop>>]
|
61
67
|
#
|
62
68
|
# @api public
|
63
69
|
# @since 0.1.0
|
70
|
+
# @version 0.10.0
|
64
71
|
def systems
|
65
|
-
|
72
|
+
@access_lock.read_sync { registry.to_h }
|
66
73
|
end
|
67
74
|
|
68
75
|
# @param block [Block]
|
@@ -73,8 +80,9 @@ module SmartCore::Initializer::TypeSystem::RegistryInterface
|
|
73
80
|
#
|
74
81
|
# @api public
|
75
82
|
# @since 0.1.0
|
83
|
+
# @version 0.10.0
|
76
84
|
def each(&block)
|
77
|
-
|
85
|
+
@access_lock.read_sync { registry.each(&block) }
|
78
86
|
end
|
79
87
|
|
80
88
|
private
|
@@ -84,19 +92,4 @@ module SmartCore::Initializer::TypeSystem::RegistryInterface
|
|
84
92
|
# @api private
|
85
93
|
# @since 0.1.0
|
86
94
|
attr_reader :registry
|
87
|
-
|
88
|
-
# @return [SmartCore::Engine::Lock]
|
89
|
-
#
|
90
|
-
# @api private
|
91
|
-
# @since 0.1.0
|
92
|
-
attr_reader :access_lock
|
93
|
-
|
94
|
-
# @param block [Block]
|
95
|
-
# @return [Any]
|
96
|
-
#
|
97
|
-
# @api pribate
|
98
|
-
# @since 0.1.0
|
99
|
-
def thread_safe(&block)
|
100
|
-
access_lock.synchronize(&block)
|
101
|
-
end
|
102
95
|
end
|
data/smart_initializer.gemspec
CHANGED
@@ -30,14 +30,14 @@ 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.
|
34
|
-
spec.add_dependency 'smart_types', '~> 0.
|
33
|
+
spec.add_dependency 'smart_engine', '~> 0.16'
|
34
|
+
spec.add_dependency 'smart_types', '~> 0.7'
|
35
35
|
spec.add_dependency 'qonfig', '~> 0.24'
|
36
36
|
|
37
|
-
spec.add_development_dependency 'bundler', '~> 2.
|
37
|
+
spec.add_development_dependency 'bundler', '~> 2.3'
|
38
38
|
spec.add_development_dependency 'rake', '~> 13.0'
|
39
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
40
|
-
spec.add_development_dependency 'armitage-rubocop', '~> 1.
|
39
|
+
spec.add_development_dependency 'rspec', '~> 3.11'
|
40
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 1.30'
|
41
41
|
spec.add_development_dependency 'simplecov', '~> 0.21'
|
42
42
|
spec.add_development_dependency 'pry', '~> 0.14'
|
43
43
|
end
|
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.
|
4
|
+
version: 0.10.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-03
|
11
|
+
date: 2022-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smart_engine
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.16'
|
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.
|
26
|
+
version: '0.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: smart_types
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.7'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: qonfig
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '2.
|
61
|
+
version: '2.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '2.
|
68
|
+
version: '2.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
89
|
+
version: '3.11'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.11'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: armitage-rubocop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
103
|
+
version: '1.30'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
110
|
+
version: '1.30'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.3.
|
249
|
+
rubygems_version: 3.3.11
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: Initializer DSL
|