fried-typings 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +130 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fried-typings.gemspec +35 -0
- data/lib/fried/typings.rb +17 -0
- data/lib/fried/typings/array_of.rb +32 -0
- data/lib/fried/typings/boolean.rb +7 -0
- data/lib/fried/typings/enumerator_of.rb +30 -0
- data/lib/fried/typings/hash_of.rb +35 -0
- data/lib/fried/typings/is.rb +27 -0
- data/lib/fried/typings/is_strictly.rb +27 -0
- data/lib/fried/typings/meta_type.rb +28 -0
- data/lib/fried/typings/one_of.rb +29 -0
- data/lib/fried/typings/strictly_one_of.rb +29 -0
- data/lib/fried/typings/tuple_of.rb +31 -0
- data/lib/fried/typings/type.rb +39 -0
- data/lib/fried/typings/version.rb +5 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 86853d9a07622e785db2dabbc2071db3715e0ff0
|
4
|
+
data.tar.gz: 63e0a1de55ef8e02517fc0fd886f3da14a9cf75c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6ebdffc3ddb599eb4830eae30de020cfae619ecfb8b20f0949702f6f6477a9bee0e63946b3b8b6b7b7a1bf2567514c06753906a4f5a88b2825f7c87bfc69ad3
|
7
|
+
data.tar.gz: 0a2cb1311a314d58bb3e9f9ea6eb1bd6f0ac3a47a9239d0c11fa6a376c5e2a9528d0b7d09391790dffc11ac4f5870d92fcb9368a6ed74a5674b562e048544457
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Francesco Belladonna
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# Fried::Typings [![Build Status][test-badge]][test-link]
|
2
|
+
|
3
|
+
Composable type-safety checks.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "fried-typings"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fried-typings
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Let's say you have a class `Hello` which accepts a name as argument, and you
|
24
|
+
want to ensure it's a `String`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require "fried/typings"
|
28
|
+
|
29
|
+
class Hello
|
30
|
+
include Fried::Typings
|
31
|
+
|
32
|
+
def call(name)
|
33
|
+
Is[String].(name)
|
34
|
+
|
35
|
+
"Hello, #{name}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
hello = Hello.new
|
40
|
+
|
41
|
+
hello.("Francesco") # => "Hello, Francesco"
|
42
|
+
hello.(123) # => raises TypeError
|
43
|
+
```
|
44
|
+
|
45
|
+
You can nest checks too:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
one_of = OneOf[Numeric, IsStrictly[StandardError]]
|
49
|
+
|
50
|
+
one_of.(123) # => 123
|
51
|
+
one_of.(StandardError.new) # => #<StandardError: StandardError>
|
52
|
+
one_of.(ArgumentError.new) # => raises TypeError
|
53
|
+
```
|
54
|
+
|
55
|
+
And if you don't want to raise error, just use `#valid?`
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
one_of = OneOf[Numeric, IsStrictly[StandardError]]
|
59
|
+
|
60
|
+
one_of.valid?(123) # => true
|
61
|
+
one_of.(ArgumentError.new) # => false
|
62
|
+
```
|
63
|
+
|
64
|
+
### Available types
|
65
|
+
|
66
|
+
- `Is[type]` checks that object `is_a?(type)`
|
67
|
+
- `IsStrictly[type]` check that `object.class == type`
|
68
|
+
- `OneOf[type1, type2, ...typeN]` checks that object pass `Is[typeN]` for
|
69
|
+
**any** of the types
|
70
|
+
- `StrictlyOneOf[type1, type2, ...typeN]` checks that object pass
|
71
|
+
`IsStrictly[typeN]` for **any** of the types
|
72
|
+
- `Boolean` checks that object is either `true` or `false`
|
73
|
+
- `ArrayOf[type]` checks that all element of the array pass `Is[type]`
|
74
|
+
- `HashOf[key_type, value_type]` checks that all pairs of hash pass
|
75
|
+
`Is[key_type]` and `Is[value_type]`
|
76
|
+
- `EnumeratorOf[type]` checks that all element of the enumerator pass
|
77
|
+
`Is[type]`
|
78
|
+
- `TupleOf[type1, type2, ...typeN]` checks that each object of the array
|
79
|
+
passes `Is[typeN]` the type at the same index in `[]`. If array size differ
|
80
|
+
from the amount of specified types, it doesn't pass. E.g.:
|
81
|
+
`TupleOf[String, Numeric].valid?(["test", 123]) # => true`. While
|
82
|
+
`TupleOf[String, Numeric].valid?([nil, 123]) # => false`. Finally,
|
83
|
+
`TupleOf[String].valid?(["test", 123]) # => false` because array size don't
|
84
|
+
match
|
85
|
+
|
86
|
+
### Custom types
|
87
|
+
|
88
|
+
You can build easily your custom types:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
class Is
|
92
|
+
include MetaType
|
93
|
+
include Type
|
94
|
+
|
95
|
+
def initialize(type)
|
96
|
+
@type = type
|
97
|
+
end
|
98
|
+
|
99
|
+
def valid?(obj)
|
100
|
+
# If it's one of the `Type` from Fried::Typings, check with those, to
|
101
|
+
# allow chaining/nesting
|
102
|
+
return type.valid?(obj) if @type < Type
|
103
|
+
|
104
|
+
# Otherwise perform the check how we would do
|
105
|
+
obj.is_a?(@type)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
This will allow the following usage:
|
111
|
+
|
112
|
+
And yes this is _exactly_ how `Is` is implemented. However, it deserves some
|
113
|
+
explaination.
|
114
|
+
|
115
|
+
`Type` does all the heavy lifting. You would need only that. `MetaType` adds
|
116
|
+
a class method `[]` that delegates directly to `new`.
|
117
|
+
You don't need `MetaType`, it's just there to improve syntax.
|
118
|
+
|
119
|
+
## Development
|
120
|
+
|
121
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
122
|
+
|
123
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
124
|
+
|
125
|
+
## Contributing
|
126
|
+
|
127
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Fire-Dragon-DoL/fried-typings.
|
128
|
+
|
129
|
+
[test-badge]: https://travis-ci.org/Fire-Dragon-DoL/fried-typings.svg?branch=master
|
130
|
+
[test-link]: https://travis-ci.org/Fire-Dragon-DoL/fried-typings
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fried/typings"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "fried/typings/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fried-typings"
|
7
|
+
spec.version = Fried::Typings::VERSION
|
8
|
+
spec.authors = ["Fire-Dragon-DoL"]
|
9
|
+
spec.email = ["francesco.belladonna@gmail.com"]
|
10
|
+
spec.licenses = ["MIT"]
|
11
|
+
|
12
|
+
spec.summary = %q{Composable type-safety checks}
|
13
|
+
spec.description = %q{Composable type-safety checks}
|
14
|
+
spec.homepage = "https://github.com/Fire-Dragon-DoL/fried-typings"
|
15
|
+
spec.metadata = {
|
16
|
+
"source_code_uri" => "https://github.com/Fire-Dragon-DoL/fried-typings"
|
17
|
+
}
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "minitest"
|
28
|
+
spec.add_development_dependency "minitest-focus"
|
29
|
+
spec.add_development_dependency "minitest-reporters"
|
30
|
+
spec.add_development_dependency "pry-byebug"
|
31
|
+
spec.add_development_dependency "rake"
|
32
|
+
spec.add_development_dependency "fried-test"
|
33
|
+
|
34
|
+
spec.add_runtime_dependency "fried-core"
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "fried/typings/version"
|
2
|
+
require "fried/typings/array_of"
|
3
|
+
require "fried/typings/boolean"
|
4
|
+
require "fried/typings/enumerator_of"
|
5
|
+
require "fried/typings/hash_of"
|
6
|
+
require "fried/typings/is"
|
7
|
+
require "fried/typings/is_strictly"
|
8
|
+
require "fried/typings/meta_type"
|
9
|
+
require "fried/typings/one_of"
|
10
|
+
require "fried/typings/strictly_one_of"
|
11
|
+
require "fried/typings/tuple_of"
|
12
|
+
require "fried/typings/type"
|
13
|
+
|
14
|
+
module Fried
|
15
|
+
module Typings
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "fried/core"
|
2
|
+
require "fried/typings/is"
|
3
|
+
require "fried/typings/enumerator_of"
|
4
|
+
require "fried/typings/meta_type"
|
5
|
+
require "fried/typings/type"
|
6
|
+
|
7
|
+
module Fried::Typings
|
8
|
+
# Checks if all elements of the array match given type
|
9
|
+
class ArrayOf
|
10
|
+
include MetaType
|
11
|
+
include Type
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :type
|
16
|
+
|
17
|
+
public
|
18
|
+
|
19
|
+
def initialize(type)
|
20
|
+
@type = type
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param ary [Array]
|
24
|
+
def valid?(ary)
|
25
|
+
return false unless Is[Array].valid?(ary)
|
26
|
+
|
27
|
+
enumerator = ary.each
|
28
|
+
|
29
|
+
EnumeratorOf[type].valid?(enumerator)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "fried/core"
|
2
|
+
require "fried/typings/type"
|
3
|
+
require "fried/typings/meta_type"
|
4
|
+
require "fried/typings/is"
|
5
|
+
|
6
|
+
module Fried::Typings
|
7
|
+
# Checks if all enumerated objects {Is} of passed type
|
8
|
+
class EnumeratorOf
|
9
|
+
include MetaType
|
10
|
+
include Type
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :type
|
15
|
+
|
16
|
+
public
|
17
|
+
|
18
|
+
def initialize(type)
|
19
|
+
@type = type
|
20
|
+
end
|
21
|
+
|
22
|
+
# Notice that the method will actually iterate over the enumerator
|
23
|
+
# @param enumerator [Enumerator]
|
24
|
+
def valid?(enumerator)
|
25
|
+
return false unless Is[Enumerator].valid?(enumerator)
|
26
|
+
|
27
|
+
enumerator.all? { |obj| Is[type].valid?(obj) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "fried/core"
|
2
|
+
require "fried/typings/enumerator_of"
|
3
|
+
require "fried/typings/is"
|
4
|
+
require "fried/typings/meta_type"
|
5
|
+
require "fried/typings/tuple_of"
|
6
|
+
require "fried/typings/type"
|
7
|
+
|
8
|
+
module Fried::Typings
|
9
|
+
# Checks if all key => value elements of the hashmap match the types pair
|
10
|
+
class HashOf
|
11
|
+
include MetaType
|
12
|
+
include Type
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
attr_reader :key_type
|
17
|
+
attr_reader :value_type
|
18
|
+
|
19
|
+
public
|
20
|
+
|
21
|
+
def initialize(key_type, value_type)
|
22
|
+
@key_type = key_type
|
23
|
+
@value_type = value_type
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param hsh [Hash]
|
27
|
+
def valid?(hsh)
|
28
|
+
return false unless Is[Hash].valid?(hsh)
|
29
|
+
|
30
|
+
enumerator = hsh.each
|
31
|
+
|
32
|
+
EnumeratorOf[TupleOf[key_type, value_type]].valid?(enumerator)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "fried/core"
|
2
|
+
require "fried/typings/meta_type"
|
3
|
+
require "fried/typings/type"
|
4
|
+
|
5
|
+
module Fried::Typings
|
6
|
+
# Checks if the object {#is_a?} object of the passed type
|
7
|
+
class Is
|
8
|
+
include MetaType
|
9
|
+
include Type
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
attr_reader :type
|
14
|
+
|
15
|
+
public
|
16
|
+
|
17
|
+
def initialize(type)
|
18
|
+
@type = type
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?(obj)
|
22
|
+
return type.valid?(obj) if type < Type
|
23
|
+
|
24
|
+
obj.is_a?(type)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "fried/core"
|
2
|
+
require "fried/typings/meta_type"
|
3
|
+
require "fried/typings/type"
|
4
|
+
|
5
|
+
module Fried::Typings
|
6
|
+
# Checks if the object.class is exactly of the passed type
|
7
|
+
class IsStrictly
|
8
|
+
include MetaType
|
9
|
+
include Type
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
attr_reader :type
|
14
|
+
|
15
|
+
public
|
16
|
+
|
17
|
+
def initialize(type)
|
18
|
+
@type = type
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?(obj)
|
22
|
+
return type.valid?(obj) if type < Type
|
23
|
+
|
24
|
+
obj.class == type
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
require "fried/core"
|
3
|
+
|
4
|
+
module Fried::Typings
|
5
|
+
# Protocol to generate {Type}
|
6
|
+
module MetaType
|
7
|
+
MissingTypeError = Class.new(StandardError)
|
8
|
+
|
9
|
+
def self.included(klass)
|
10
|
+
klass.instance_eval do
|
11
|
+
class << self
|
12
|
+
extend Forwardable
|
13
|
+
|
14
|
+
# @!method []
|
15
|
+
# @param args [Array<Class, Module, Type>]
|
16
|
+
# @return [Type]
|
17
|
+
def_delegator :self, :new, :[]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def missing_type!
|
25
|
+
raise MissingTypeError, "No type(s) configured for the meta type"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "fried/core"
|
2
|
+
require "fried/typings/type"
|
3
|
+
require "fried/typings/meta_type"
|
4
|
+
require "fried/typings/is"
|
5
|
+
|
6
|
+
module Fried::Typings
|
7
|
+
# Checks if the object {#is_a?} object of the passed types
|
8
|
+
class OneOf
|
9
|
+
include MetaType
|
10
|
+
include Type
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :types
|
15
|
+
|
16
|
+
public
|
17
|
+
|
18
|
+
def initialize(*types)
|
19
|
+
@types = types
|
20
|
+
missing_type! if types.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
def valid?(obj)
|
24
|
+
types.any? do |type|
|
25
|
+
Is[type].valid?(obj)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "fried/core"
|
2
|
+
require "fried/typings/type"
|
3
|
+
require "fried/typings/meta_type"
|
4
|
+
require "fried/typings/is_strictly"
|
5
|
+
|
6
|
+
module Fried::Typings
|
7
|
+
# Checks if the object.class is exactly one of the passed types
|
8
|
+
class StrictlyOneOf
|
9
|
+
include MetaType
|
10
|
+
include Type
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :types
|
15
|
+
|
16
|
+
public
|
17
|
+
|
18
|
+
def initialize(*types)
|
19
|
+
@types = types
|
20
|
+
missing_type! if types.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
def valid?(obj)
|
24
|
+
types.any? do |type|
|
25
|
+
IsStrictly[type].valid?(obj)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "fried/core"
|
2
|
+
require "fried/typings/type"
|
3
|
+
require "fried/typings/meta_type"
|
4
|
+
require "fried/typings/is"
|
5
|
+
|
6
|
+
module Fried::Typings
|
7
|
+
# Checks if Array fields match types specified on a 1-to-1 relationship.
|
8
|
+
# So `[123, "test", nil]` matches `TupleOf[Numeric, String, NilClass]`
|
9
|
+
class TupleOf
|
10
|
+
include MetaType
|
11
|
+
include Type
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :types
|
16
|
+
|
17
|
+
public
|
18
|
+
|
19
|
+
def initialize(*types)
|
20
|
+
@types = types
|
21
|
+
end
|
22
|
+
|
23
|
+
def valid?(ary)
|
24
|
+
return false unless ary.size == types.size
|
25
|
+
|
26
|
+
types.each.with_index.all? do |type, index|
|
27
|
+
Is[type].valid?(ary[index])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
require "fried/core"
|
3
|
+
|
4
|
+
module Fried::Typings
|
5
|
+
# Protocol to validate object type
|
6
|
+
module Type
|
7
|
+
def self.included(klass)
|
8
|
+
klass.instance_eval do
|
9
|
+
include Comparable
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Compares own class with other object (which should be a class)
|
14
|
+
# @param other [Class,Module]
|
15
|
+
def <=>(other)
|
16
|
+
self.class <=> other
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param obj any object
|
20
|
+
# @return the passed object
|
21
|
+
# @raise [TypeError] should be raised if {#valid?} is false
|
22
|
+
def call(obj)
|
23
|
+
invalid_type!(obj) unless valid?(obj)
|
24
|
+
obj
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param obj any object
|
28
|
+
# @return [Boolean] true if object is of valid type
|
29
|
+
def valid?(obj)
|
30
|
+
raise NotImplementedError
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def invalid_type!(obj)
|
36
|
+
raise TypeError, "Type of `obj` is #{obj.class} - #{obj.inspect}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fried-typings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fire-Dragon-DoL
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest-focus
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-reporters
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: fried-test
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: fried-core
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Composable type-safety checks
|
126
|
+
email:
|
127
|
+
- francesco.belladonna@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".travis.yml"
|
134
|
+
- Gemfile
|
135
|
+
- LICENSE
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- bin/console
|
139
|
+
- bin/setup
|
140
|
+
- fried-typings.gemspec
|
141
|
+
- lib/fried/typings.rb
|
142
|
+
- lib/fried/typings/array_of.rb
|
143
|
+
- lib/fried/typings/boolean.rb
|
144
|
+
- lib/fried/typings/enumerator_of.rb
|
145
|
+
- lib/fried/typings/hash_of.rb
|
146
|
+
- lib/fried/typings/is.rb
|
147
|
+
- lib/fried/typings/is_strictly.rb
|
148
|
+
- lib/fried/typings/meta_type.rb
|
149
|
+
- lib/fried/typings/one_of.rb
|
150
|
+
- lib/fried/typings/strictly_one_of.rb
|
151
|
+
- lib/fried/typings/tuple_of.rb
|
152
|
+
- lib/fried/typings/type.rb
|
153
|
+
- lib/fried/typings/version.rb
|
154
|
+
homepage: https://github.com/Fire-Dragon-DoL/fried-typings
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
metadata:
|
158
|
+
source_code_uri: https://github.com/Fire-Dragon-DoL/fried-typings
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 2.6.14
|
176
|
+
signing_key:
|
177
|
+
specification_version: 4
|
178
|
+
summary: Composable type-safety checks
|
179
|
+
test_files: []
|