smart_types 0.1.0.alpha → 0.1.0.alpha2

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: 984ff8c37feb29e6b3141b845c0f9f4266bdafc0c22fdf195ed9c4ab2036d7a9
4
- data.tar.gz: 689d1cc015483cea2ca32cbd3c2e93c0e5cf486c31dc016f37d267171ec6f23a
3
+ metadata.gz: dcb0ae0383bdc9445db3ea63c4aa54bb6bfb733ae0d092a35454eb1c5892849d
4
+ data.tar.gz: 5d15ac45b21a85e965feb00f45419d125638578941eee86a56cb9088f60249fe
5
5
  SHA512:
6
- metadata.gz: dc955ee3f9f07f82be3a0144d382f949cdfce0b2c274e4ca3f229d1d4ca935eaea44ffe54d0d60a461cce43ab27a9a0bc357bd2e5ebf4d637b9450aca1b78e19
7
- data.tar.gz: c0451f6106a9e7d59f10c187edcd9b9cc6a9bc8992df0b44fa3354d0456091cf479135e2ae7565f96922f0ddcef87b243c04b06ebefa35636a508c0a405fa659
6
+ metadata.gz: a9ac3108ef4bdc56cd6618312b56e78eb328461e54ef9bcd09ef9daf7f808b121dfb7d3e196596455eebcdaf69a4426fcfa5066d1f584c74138114cade5e8770
7
+ data.tar.gz: 6ca41544a3c80c8573971f63135224d67c21b72ba5c4cbd0137086a6a1f5edd5d736708178472dd009c4e648d37527e3e8416af008d17120dbd26d3a6b8c299c
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_types (0.1.0)
5
- smart_engine (~> 0.4)
4
+ smart_types (0.1.0.alpha)
5
+ smart_engine (~> 0.5)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -59,7 +59,7 @@ GEM
59
59
  json (>= 1.8, < 3)
60
60
  simplecov-html (~> 0.10.0)
61
61
  simplecov-html (0.10.2)
62
- smart_engine (0.4.0)
62
+ smart_engine (0.5.0)
63
63
  unicode-display_width (1.6.0)
64
64
 
65
65
  PLATFORMS
data/README.md CHANGED
@@ -32,6 +32,7 @@ require 'smart_core/types'
32
32
  # documentation is coming
33
33
 
34
34
  type.valid?(value)
35
+ type.validate!(value)
35
36
  type.cast(value)
36
37
  type.nilable
37
38
  type3 = type1 | type2
@@ -13,6 +13,10 @@ module SmartCore::Types
13
13
  # @since 0.1.0
14
14
  NameError = Class.new(SmartCore::NameError)
15
15
 
16
+ # @api public
17
+ # @since 0.1.0
18
+ TypeError = Class.new(SmartCore::TypeError)
19
+
16
20
  # @api public
17
21
  # @since 0.1.0
18
22
  TypeCastingError = Class.new(Error)
@@ -52,6 +52,18 @@ class SmartCore::Types::Primitive
52
52
  checker.call(value)
53
53
  end
54
54
 
55
+ # @return [void]
56
+ #
57
+ # @raise [SmartCore::TypeError]
58
+ #
59
+ # @api public
60
+ # @since 0.1.0
61
+ def validate!(value)
62
+ valid?(value) || raise(SmartCore::Types::TypeError, <<~ERROR_MESSAGE)
63
+ Invalid type (given #{value.class}, expects #{self}-related)
64
+ ERROR_MESSAGE
65
+ end
66
+
55
67
  # @param value [Any]
56
68
  # @return [Any]
57
69
  #
@@ -7,6 +7,6 @@ module SmartCore
7
7
  # @api public
8
8
  # @since 0.1.0
9
9
  # @version 0.1.0
10
- VERSION = '0.1.0.alpha'
10
+ VERSION = '0.1.0.alpha2'
11
11
  end
12
12
  end
data/smart_types.gemspec CHANGED
@@ -32,7 +32,7 @@ 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.4'
35
+ spec.add_dependency 'smart_engine', '~> 0.5'
36
36
 
37
37
  spec.add_development_dependency 'bundler', '~> 2.1'
38
38
  spec.add_development_dependency 'rake', '~> 13.0'
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.1.0.alpha
4
+ version: 0.1.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-20 00:00:00.000000000 Z
11
+ date: 2020-01-22 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.4'
19
+ version: '0.5'
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.4'
26
+ version: '0.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement