smart_types 0.1.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -1
- data/CHANGELOG.md +57 -0
- data/Gemfile.lock +71 -58
- data/LICENSE.txt +1 -1
- data/README.md +363 -34
- data/Rakefile +0 -1
- data/bin/console +2 -2
- data/lib/smart_core/types/errors.rb +12 -0
- data/lib/smart_core/types/primitive/caster.rb +5 -2
- data/lib/smart_core/types/primitive/checker.rb +5 -2
- data/lib/smart_core/types/primitive/factory/definition_context.rb +140 -4
- data/lib/smart_core/types/primitive/factory/runtime_type_builder.rb +53 -0
- data/lib/smart_core/types/primitive/factory.rb +104 -7
- data/lib/smart_core/types/primitive/invariant_control/chain/result.rb +64 -0
- data/lib/smart_core/types/primitive/invariant_control/chain.rb +61 -0
- data/lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb +39 -0
- data/lib/smart_core/types/primitive/invariant_control/factory.rb +54 -0
- data/lib/smart_core/types/primitive/invariant_control/result.rb +104 -0
- data/lib/smart_core/types/primitive/invariant_control/single/result.rb +63 -0
- data/lib/smart_core/types/primitive/invariant_control/single.rb +57 -0
- data/lib/smart_core/types/primitive/invariant_control.rb +67 -0
- data/lib/smart_core/types/primitive/mult_factory/definition_context.rb +26 -2
- data/lib/smart_core/types/primitive/mult_factory.rb +59 -10
- data/lib/smart_core/types/primitive/mult_validator/result.rb +8 -0
- data/lib/smart_core/types/primitive/mult_validator.rb +42 -0
- data/lib/smart_core/types/primitive/nilable_factory.rb +31 -9
- data/lib/smart_core/types/primitive/nilable_validator/result.rb +78 -0
- data/lib/smart_core/types/primitive/nilable_validator.rb +83 -0
- data/lib/smart_core/types/primitive/runtime_attributes_checker.rb +77 -0
- data/lib/smart_core/types/primitive/sum_factory/definition_context.rb +25 -1
- data/lib/smart_core/types/primitive/sum_factory.rb +59 -10
- data/lib/smart_core/types/primitive/sum_validator/result.rb +100 -0
- data/lib/smart_core/types/primitive/sum_validator.rb +117 -0
- data/lib/smart_core/types/primitive/undefined_caster.rb +4 -1
- data/lib/smart_core/types/primitive/validator/result.rb +78 -0
- data/lib/smart_core/types/primitive/validator.rb +93 -0
- data/lib/smart_core/types/primitive.rb +99 -15
- data/lib/smart_core/types/protocol/instance_of.rb +19 -0
- data/lib/smart_core/types/protocol.rb +7 -0
- data/lib/smart_core/types/value/array.rb +3 -0
- data/lib/smart_core/types/value/big_decimal.rb +4 -1
- data/lib/smart_core/types/value/boolean.rb +3 -0
- data/lib/smart_core/types/value/class.rb +3 -0
- data/lib/smart_core/types/value/date.rb +3 -0
- data/lib/smart_core/types/value/date_time.rb +3 -0
- data/lib/smart_core/types/value/enumerable.rb +1 -1
- data/lib/smart_core/types/value/enumerator.rb +13 -0
- data/lib/smart_core/types/value/enumerator_chain.rb +13 -0
- data/lib/smart_core/types/value/float.rb +3 -0
- data/lib/smart_core/types/value/hash.rb +3 -0
- data/lib/smart_core/types/value/integer.rb +3 -0
- data/lib/smart_core/types/value/io.rb +13 -0
- data/lib/smart_core/types/value/method.rb +9 -0
- data/lib/smart_core/types/value/module.rb +3 -0
- data/lib/smart_core/types/value/nil.rb +0 -2
- data/lib/smart_core/types/value/numeric.rb +3 -0
- data/lib/smart_core/types/value/proc.rb +3 -0
- data/lib/smart_core/types/value/range.rb +9 -0
- data/lib/smart_core/types/value/rational.rb +13 -0
- data/lib/smart_core/types/value/set.rb +21 -0
- data/lib/smart_core/types/value/string.rb +3 -0
- data/lib/smart_core/types/value/string_io.rb +15 -0
- data/lib/smart_core/types/value/symbol.rb +3 -0
- data/lib/smart_core/types/value/text.rb +6 -4
- data/lib/smart_core/types/value/time.rb +3 -0
- data/lib/smart_core/types/value/time_based.rb +8 -5
- data/lib/smart_core/types/value/unbound_method.rb +9 -0
- data/lib/smart_core/types/value.rb +9 -0
- data/lib/smart_core/types/variadic/array_of.rb +23 -0
- data/lib/smart_core/types/variadic/enum.rb +11 -0
- data/lib/smart_core/types/variadic/tuple.rb +23 -0
- data/lib/smart_core/types/variadic.rb +10 -0
- data/lib/smart_core/types/version.rb +2 -1
- data/lib/smart_core/types.rb +2 -0
- data/smart_types.gemspec +5 -4
- metadata +61 -18
- data/.travis.yml +0 -21
- data/lib/smart_core/types/primitive/mult_checker.rb +0 -31
- data/lib/smart_core/types/primitive/nilable_checker.rb +0 -37
- data/lib/smart_core/types/primitive/sum_checker.rb +0 -31
data/lib/smart_core/types.rb
CHANGED
data/smart_types.gemspec
CHANGED
@@ -32,11 +32,12 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
33
|
spec.require_paths = ['lib']
|
34
34
|
|
35
|
-
spec.add_dependency 'smart_engine', '~> 0.
|
35
|
+
spec.add_dependency 'smart_engine', '~> 0.11'
|
36
36
|
|
37
37
|
spec.add_development_dependency 'bundler', '~> 2.1'
|
38
38
|
spec.add_development_dependency 'rake', '~> 13.0'
|
39
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
40
|
-
spec.add_development_dependency 'armitage-rubocop', '~>
|
41
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
39
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
40
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 1.7'
|
41
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
42
|
+
spec.add_development_dependency 'pry', '~> 0.13'
|
42
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-06 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.
|
19
|
+
version: '0.11'
|
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.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,42 +58,56 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.10'
|
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: '3.
|
68
|
+
version: '3.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: armitage-rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.7'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.7'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.21'
|
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: '0.
|
96
|
+
version: '0.21'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.13'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.13'
|
97
111
|
description: |
|
98
112
|
Full-featured type system for any ruby project. Supports custom type definitioning,
|
99
113
|
type validation, type casting and type categorizing. Provides a set of commonly used type
|
@@ -107,7 +121,6 @@ files:
|
|
107
121
|
- ".gitignore"
|
108
122
|
- ".rspec"
|
109
123
|
- ".rubocop.yml"
|
110
|
-
- ".travis.yml"
|
111
124
|
- CHANGELOG.md
|
112
125
|
- CODE_OF_CONDUCT.md
|
113
126
|
- Gemfile
|
@@ -124,15 +137,32 @@ files:
|
|
124
137
|
- lib/smart_core/types/primitive/checker.rb
|
125
138
|
- lib/smart_core/types/primitive/factory.rb
|
126
139
|
- lib/smart_core/types/primitive/factory/definition_context.rb
|
127
|
-
- lib/smart_core/types/primitive/
|
140
|
+
- lib/smart_core/types/primitive/factory/runtime_type_builder.rb
|
141
|
+
- lib/smart_core/types/primitive/invariant_control.rb
|
142
|
+
- lib/smart_core/types/primitive/invariant_control/chain.rb
|
143
|
+
- lib/smart_core/types/primitive/invariant_control/chain/result.rb
|
144
|
+
- lib/smart_core/types/primitive/invariant_control/factory.rb
|
145
|
+
- lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb
|
146
|
+
- lib/smart_core/types/primitive/invariant_control/result.rb
|
147
|
+
- lib/smart_core/types/primitive/invariant_control/single.rb
|
148
|
+
- lib/smart_core/types/primitive/invariant_control/single/result.rb
|
128
149
|
- lib/smart_core/types/primitive/mult_factory.rb
|
129
150
|
- lib/smart_core/types/primitive/mult_factory/definition_context.rb
|
130
|
-
- lib/smart_core/types/primitive/
|
151
|
+
- lib/smart_core/types/primitive/mult_validator.rb
|
152
|
+
- lib/smart_core/types/primitive/mult_validator/result.rb
|
131
153
|
- lib/smart_core/types/primitive/nilable_factory.rb
|
132
|
-
- lib/smart_core/types/primitive/
|
154
|
+
- lib/smart_core/types/primitive/nilable_validator.rb
|
155
|
+
- lib/smart_core/types/primitive/nilable_validator/result.rb
|
156
|
+
- lib/smart_core/types/primitive/runtime_attributes_checker.rb
|
133
157
|
- lib/smart_core/types/primitive/sum_factory.rb
|
134
158
|
- lib/smart_core/types/primitive/sum_factory/definition_context.rb
|
159
|
+
- lib/smart_core/types/primitive/sum_validator.rb
|
160
|
+
- lib/smart_core/types/primitive/sum_validator/result.rb
|
135
161
|
- lib/smart_core/types/primitive/undefined_caster.rb
|
162
|
+
- lib/smart_core/types/primitive/validator.rb
|
163
|
+
- lib/smart_core/types/primitive/validator/result.rb
|
164
|
+
- lib/smart_core/types/protocol.rb
|
165
|
+
- lib/smart_core/types/protocol/instance_of.rb
|
136
166
|
- lib/smart_core/types/struct.rb
|
137
167
|
- lib/smart_core/types/system.rb
|
138
168
|
- lib/smart_core/types/value.rb
|
@@ -145,18 +175,31 @@ files:
|
|
145
175
|
- lib/smart_core/types/value/date.rb
|
146
176
|
- lib/smart_core/types/value/date_time.rb
|
147
177
|
- lib/smart_core/types/value/enumerable.rb
|
178
|
+
- lib/smart_core/types/value/enumerator.rb
|
179
|
+
- lib/smart_core/types/value/enumerator_chain.rb
|
148
180
|
- lib/smart_core/types/value/float.rb
|
149
181
|
- lib/smart_core/types/value/hash.rb
|
150
182
|
- lib/smart_core/types/value/integer.rb
|
183
|
+
- lib/smart_core/types/value/io.rb
|
184
|
+
- lib/smart_core/types/value/method.rb
|
151
185
|
- lib/smart_core/types/value/module.rb
|
152
186
|
- lib/smart_core/types/value/nil.rb
|
153
187
|
- lib/smart_core/types/value/numeric.rb
|
154
188
|
- lib/smart_core/types/value/proc.rb
|
189
|
+
- lib/smart_core/types/value/range.rb
|
190
|
+
- lib/smart_core/types/value/rational.rb
|
191
|
+
- lib/smart_core/types/value/set.rb
|
155
192
|
- lib/smart_core/types/value/string.rb
|
193
|
+
- lib/smart_core/types/value/string_io.rb
|
156
194
|
- lib/smart_core/types/value/symbol.rb
|
157
195
|
- lib/smart_core/types/value/text.rb
|
158
196
|
- lib/smart_core/types/value/time.rb
|
159
197
|
- lib/smart_core/types/value/time_based.rb
|
198
|
+
- lib/smart_core/types/value/unbound_method.rb
|
199
|
+
- lib/smart_core/types/variadic.rb
|
200
|
+
- lib/smart_core/types/variadic/array_of.rb
|
201
|
+
- lib/smart_core/types/variadic/enum.rb
|
202
|
+
- lib/smart_core/types/variadic/tuple.rb
|
160
203
|
- lib/smart_core/types/version.rb
|
161
204
|
- smart_types.gemspec
|
162
205
|
homepage: https://github.com/smart-rb/smart_types
|
@@ -166,7 +209,7 @@ metadata:
|
|
166
209
|
homepage_uri: https://github.com/smart-rb/smart_types
|
167
210
|
source_code_uri: https://github.com/smart-rb/smart_types
|
168
211
|
changelog_uri: https://github.com/smart-rb/smart_types/blob/master/CHANGELOG.md
|
169
|
-
post_install_message:
|
212
|
+
post_install_message:
|
170
213
|
rdoc_options: []
|
171
214
|
require_paths:
|
172
215
|
- lib
|
@@ -181,8 +224,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
224
|
- !ruby/object:Gem::Version
|
182
225
|
version: '0'
|
183
226
|
requirements: []
|
184
|
-
rubygems_version: 3.
|
185
|
-
signing_key:
|
227
|
+
rubygems_version: 3.2.3
|
228
|
+
signing_key:
|
186
229
|
specification_version: 4
|
187
230
|
summary: Full-featured type system for any ruby project.
|
188
231
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
---
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
os: linux
|
5
|
-
dist: xenial
|
6
|
-
before_install: gem install bundler
|
7
|
-
script:
|
8
|
-
- bundle exec rake rubocop
|
9
|
-
- bundle exec rake rspec
|
10
|
-
jobs:
|
11
|
-
fast_finish: true
|
12
|
-
include:
|
13
|
-
- rvm: 2.4.10
|
14
|
-
- rvm: 2.5.8
|
15
|
-
- rvm: 2.6.6
|
16
|
-
- rvm: 2.7.1
|
17
|
-
- rvm: ruby-head
|
18
|
-
- rvm: jruby-head
|
19
|
-
allow_failures:
|
20
|
-
- rvm: ruby-head
|
21
|
-
- rvm: jruby-head
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# @api private
|
4
|
-
# @since 0.1.0
|
5
|
-
class SmartCore::Types::Primitive::MultChecker
|
6
|
-
# @param [Array<SmartCore::Types::Primitive::Checker>]
|
7
|
-
# @return [void]
|
8
|
-
#
|
9
|
-
# @api private
|
10
|
-
# @since 0.1.0
|
11
|
-
def initialize(*checkers)
|
12
|
-
@checkers = checkers
|
13
|
-
end
|
14
|
-
|
15
|
-
# @param value [Any]
|
16
|
-
# @return [Boolean]
|
17
|
-
#
|
18
|
-
# @api private
|
19
|
-
# @since 0.1.0
|
20
|
-
def call(value)
|
21
|
-
checkers.all? { |checker| checker.call(value) }
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
# @return [Array<SmartCore::Types::Primitive::Checker>]
|
27
|
-
#
|
28
|
-
# @api private
|
29
|
-
# @since 0.1.0
|
30
|
-
attr_reader :checkers
|
31
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# @api private
|
4
|
-
# @since 0.1.0
|
5
|
-
class SmartCore::Types::Primitive::NilableChecker
|
6
|
-
# @param checker [Checker, SumChecker, MultChecker, NilableChecker]
|
7
|
-
# @return [void]
|
8
|
-
#
|
9
|
-
# @api private
|
10
|
-
# @since 0.1.0
|
11
|
-
def initialize(checker)
|
12
|
-
@checker = checker
|
13
|
-
end
|
14
|
-
|
15
|
-
# @param value [Any]
|
16
|
-
# @return [Boolean]
|
17
|
-
#
|
18
|
-
# @api private
|
19
|
-
# @since 0.1.0
|
20
|
-
def call(value)
|
21
|
-
# rubocop:disable Style/NilComparison
|
22
|
-
# NOTE: #nil? is not used cuz BasicObject has no #nil? method
|
23
|
-
(value == nil) ? true : checker.call(value)
|
24
|
-
# rubocop:enable Style/NilComparison
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
# @return [SmartCore::Types::Primitive::Checker]
|
30
|
-
# @return [SmartCore::Types::Primitive::MultChecker]
|
31
|
-
# @return [SmartCore::Types::Primitive::SumChecker]
|
32
|
-
# @return [SmartCore::Types::Primitive::NilableChecker]
|
33
|
-
#
|
34
|
-
# @api private
|
35
|
-
# @since 0.1.0
|
36
|
-
attr_reader :checker
|
37
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# @api private
|
4
|
-
# @since 0.1.0
|
5
|
-
class SmartCore::Types::Primitive::SumChecker
|
6
|
-
# @param [Array<SmartCore::Types::Primitive::Checker>]
|
7
|
-
# @return [void]
|
8
|
-
#
|
9
|
-
# @api private
|
10
|
-
# @since 0.1.0
|
11
|
-
def initialize(*checkers)
|
12
|
-
@checkers = checkers
|
13
|
-
end
|
14
|
-
|
15
|
-
# @param value [Any]
|
16
|
-
# @return [Boolean]
|
17
|
-
#
|
18
|
-
# @api private
|
19
|
-
# @since 0.1.0
|
20
|
-
def call(value)
|
21
|
-
checkers.any? { |checker| checker.call(value) }
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
# @return [Array<SmartCore::Types::Primitive::Checker>]
|
27
|
-
#
|
28
|
-
# @api private
|
29
|
-
# @since 0.1.0
|
30
|
-
attr_reader :checkers
|
31
|
-
end
|