prolog-dry_types 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 +13 -0
- data/.rubocop.yml +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +219 -0
- data/Rakefile +47 -0
- data/bin/console +14 -0
- data/bin/setup +15 -0
- data/config.reek +8 -0
- data/lib/prolog/dry_types/error_array.rb +10 -0
- data/lib/prolog/dry_types/integer_range.rb +22 -0
- data/lib/prolog/dry_types/range.rb +9 -0
- data/lib/prolog/dry_types/time_or_now.rb +10 -0
- data/lib/prolog/dry_types/uuid.rb +14 -0
- data/lib/prolog/dry_types/version.rb +8 -0
- data/lib/prolog/dry_types.rb +16 -0
- data/lib/tasks/prolog_flog_task.rb +12 -0
- data/prolog-dry_types.gemspec +49 -0
- metadata +351 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fc1450e64dab48197eba2604e4c6797785743e12
|
4
|
+
data.tar.gz: 9922693a24d5af77a8cf7d3d4a132fe67c15102d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0b1c9be3f34988a54eb372db3e37732e5a643faea690f8e3a22a80552af9dbb4bdd9a3b291644d4d14159e5e326299f2a693f30e700e03de5ba880be56de6f9
|
7
|
+
data.tar.gz: 3d20c79b501a8c1c475425c64137ba10ef61c6974b941e4070dadf086b852d57a84f7c6e67463cda9c37f34949dd5d3b57097dbd3752d8a3591537db4334a972
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at jdickey@seven-sigma.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jeff Dickey
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
# Prolog::DryTypes
|
2
|
+
|
3
|
+
**NOTE:** This Gem **supersedes** the previous `prolog-dry-types` Gem, which suffered from two major problems:
|
4
|
+
|
5
|
+
1. It was tied to the now-obsolete `dry-types` Gem Release 0.7.2, in a bid to avoid (or at least defer) several breaking changes that were encountered by Prolog applications upgrading to Release 0.8.0. This bit us later when using this Gem in conjunction with other `dry-rb` Gems and finding that the current documentation and available support no longer matched the code we were using; and
|
6
|
+
2. It required that all uses of the root-level `Dry` or `Types` namespace modules, conventional in `dry-types`, be explicitly marked as root-level; e.g., that value objects subclass `::Dry::Types::Value` rather than simply `Dry::Types::Value`.
|
7
|
+
|
8
|
+
The document that follows is the README from `prolog-dry-types` Release 0.3.0, modified only as needed to reflect the change from `prolog-dry-types` to `prolog-dry_types`.
|
9
|
+
|
10
|
+
----
|
11
|
+
|
12
|
+
----
|
13
|
+
|
14
|
+
This Gem defines some fairly general-purpose types using the [`dry-types`](https://github.com/dry-rb/dry-types) Gem which, for those not familiar with it yet, is the successor to the venerable [Virtus](https://github.com/solnic/virtus) Gem, originally created by [Piotr Solnica](http://solnic.eu) and contributors. As part of the [`dry-rb`](http://dry-rb.org) collection of Gems, `dry-types` is an extremely useful tool that quickly becomes habit-forming. Side-effects may include more explicit, therefore more understandable code; increased developer happiness, and decreased baldness. (One of those has yet to be proven in actual use.)
|
15
|
+
|
16
|
+
`Prolog::DryTypes` leverages `dry-types`, defining several types in the `Dry::Types` module namespace as documented below under [Usage](#usage). They can be used individually by your code or all type definitions may be included by requiring `'prolog/dry_types'`,
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'prolog-dry_types'
|
24
|
+
```
|
25
|
+
|
26
|
+
And then execute:
|
27
|
+
|
28
|
+
$ bundle
|
29
|
+
|
30
|
+
Or install it yourself as:
|
31
|
+
|
32
|
+
$ gem install prolog-dry_types
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
This Gem uses `dry-types` to define (currently) four basic data types suitable for declaring attributes in a `Dry::Types::Struct` (mutable) data structure or a `Dry::Types::Value` immutable value object. These are `Types::Range` and its [`Strict`](http://dry-rb.org/gems/dry-types/strict/) equivalent, `Types::Strict::Range`; `Types::IntegerRange`, `Types::TimeOrNow`, and `Types::UUID`. Each of these is presented in greater detail below.
|
37
|
+
|
38
|
+
### `Types::Range` and `Types::Strict::Range`
|
39
|
+
|
40
|
+
**Declared in** `prolog/dry_types/range.rb`
|
41
|
+
|
42
|
+
#### Example usage
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
# in your `range_demo.rb` file
|
46
|
+
|
47
|
+
require 'prolog/dry_types/range' # or 'prolog/dry_types'
|
48
|
+
|
49
|
+
class RangeDemo < Dry::Types::Value
|
50
|
+
attribute :name, Types::Strict::String
|
51
|
+
attribute :range, Types::Strict::Range
|
52
|
+
end
|
53
|
+
|
54
|
+
# Let's be interactive...
|
55
|
+
|
56
|
+
$ pry
|
57
|
+
[1] pry(main)> require '/path/to/range_demo'
|
58
|
+
true
|
59
|
+
[2] pry(main)> range = RangeDemo.new name: 'Some Name', range: 2..5
|
60
|
+
{
|
61
|
+
:name => "Some Name",
|
62
|
+
:range => 2..5
|
63
|
+
}
|
64
|
+
[3] pry(main)> range.range.include? 5
|
65
|
+
true
|
66
|
+
[4] exit
|
67
|
+
$
|
68
|
+
```
|
69
|
+
|
70
|
+
#### Notes
|
71
|
+
|
72
|
+
The attribute value *is* a `Range` instance; it has all the quirks and behaviours that a `Range` instance declared more "conventionally" would have. In particular, a `Range` whose lower bound exceeds its upper bound (such as `(5..2)`) will always be empty. As one would reasonably expect, this attribute may be initialised by either an inclusive (e.g., `0..5`) or exclusive (`0...5`) `Range`, which respectively includes or excludes the upper bound.
|
73
|
+
|
74
|
+
### `Types::IntegerRange`
|
75
|
+
|
76
|
+
**Declared in** `prolog/dry_types/integer_range.rb`
|
77
|
+
|
78
|
+
#### Example usage
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# in your 'demo_range.rb' file
|
82
|
+
|
83
|
+
require 'prolog/dry_types/integer_range' # or 'prolog/dry_types'
|
84
|
+
|
85
|
+
class DemoRange < Dry::Types::Struct
|
86
|
+
attribute :name, Types::Strict::String
|
87
|
+
attribute range: Types::IntegerRange
|
88
|
+
end
|
89
|
+
|
90
|
+
# Let's be interactive...
|
91
|
+
$ pry
|
92
|
+
[1] pry(main)> require '/path/to/demo_range'
|
93
|
+
true
|
94
|
+
[2] pry(main)> range1 = DemoRange.new name: 'A Name', range: nil # defaults to 0..0
|
95
|
+
{
|
96
|
+
:name => "A Name",
|
97
|
+
:range => 0..0
|
98
|
+
}
|
99
|
+
[2] pry(main)> range2 = DemoRange.new name: 'Another Name', range: 8
|
100
|
+
{
|
101
|
+
:name => "Another Name",
|
102
|
+
:range => 0..8
|
103
|
+
}
|
104
|
+
[3] pry(main)> range3 = DemoRange.new name: 'One More', range: (-1..1)
|
105
|
+
{
|
106
|
+
:name => "One More",
|
107
|
+
:range => -1..1
|
108
|
+
}
|
109
|
+
[4] pry(main)> range3.range.to_a
|
110
|
+
[
|
111
|
+
[0] -1,
|
112
|
+
[1] 0,
|
113
|
+
[2] 1
|
114
|
+
]
|
115
|
+
[5] pry(main)> exit
|
116
|
+
$
|
117
|
+
```
|
118
|
+
|
119
|
+
#### Notes
|
120
|
+
|
121
|
+
`Types::IntegerRange` *can* be used as though it were a `Types::Range`, with the attribute initialisation using a standard `Range` instance. It was initially developed, however, to provide an easy shorthand for a `Range` with a lower bound of zero, for which one only need supply the upper bound.
|
122
|
+
|
123
|
+
### `Types::TimeOrNow`
|
124
|
+
|
125
|
+
**Declared in** `prolog/dry_types/time_or_now.rb`
|
126
|
+
|
127
|
+
#### Example usage
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
# In your 'time_demo.rb' file
|
131
|
+
|
132
|
+
require 'prolog/dry_types/time_or_now'
|
133
|
+
|
134
|
+
class TimeDemo < Dry::Types::Value
|
135
|
+
attribute :when, Types::TimeOrNow
|
136
|
+
end
|
137
|
+
|
138
|
+
# Interactive again
|
139
|
+
$ pry
|
140
|
+
[1] pry(main)> require '/path/to/time_demo'
|
141
|
+
true
|
142
|
+
[2] pry(main)> t0 = Time.now; t1 = TimeDemo.new when: nil
|
143
|
+
{
|
144
|
+
:when => 2016-07-31 01:56:11 +0800
|
145
|
+
}
|
146
|
+
[3] pry(main)> t1.when - t0
|
147
|
+
1.3e-05 # 13 microseconds on this system
|
148
|
+
[4] pry(main)> t2 = TimeDemo.new when: Time.parse('23 Jan 2016 12:34:56 SGT')
|
149
|
+
{
|
150
|
+
:when => 2016-01-23 12:34:56 +0800
|
151
|
+
}
|
152
|
+
[5] pry(main)> t3 = TimeDemo.new when: '23 Jan 2016 12:34:56 SGT'
|
153
|
+
Dry::Types::StructError: [TimeDemo.new] "23 Jan 2016 12:34:56 SGT" (String) has invalid type for :when
|
154
|
+
from (...omitted...):in 'rescue in new'
|
155
|
+
[6] pry(main)> exit
|
156
|
+
$
|
157
|
+
```
|
158
|
+
|
159
|
+
#### Notes
|
160
|
+
|
161
|
+
This attribute class was originally `Types::DateTimeOrNow`, wrapping a `DateTime` instance rather than a `Time` instance. The change was made in line with recently-updated [community coding guidelines](https://github.com/bbatsov/ruby-style-guide#no-datetime) which recommend against use of `DateTime` unless a need exists "to account for historical calendar reform".
|
162
|
+
|
163
|
+
### `Types::UUID`
|
164
|
+
|
165
|
+
**Declared in** `prolog/dry_types/uuid.rb`
|
166
|
+
|
167
|
+
#### Example usage
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
# In your 'uuid_demo.rb' file
|
171
|
+
|
172
|
+
require 'prolog/dry_types/uuid'
|
173
|
+
|
174
|
+
class UuidDemo < Dry::Types::Value
|
175
|
+
attribute :id, Types::UUID
|
176
|
+
end
|
177
|
+
|
178
|
+
# Once again, interactive demo
|
179
|
+
$ pry
|
180
|
+
[1] pry(main)> require '/path/to/uuid_demo'
|
181
|
+
true
|
182
|
+
[2] pry(main)> demo1 = UuidDemo.new id: nil
|
183
|
+
{
|
184
|
+
:id => "419c7d80-38b0-0134-4fad-3c0754526993"
|
185
|
+
}
|
186
|
+
[3] pry(main)> puts demo1.id
|
187
|
+
419c7d80-38b0-0134-4fad-3c0754526993
|
188
|
+
nil
|
189
|
+
[4] pry(main)> demo2 = UuidDemo.new id: '12345678-1234-5678-123456789012'
|
190
|
+
{
|
191
|
+
:id => "12345678-1234-5678-4fad-123456789012"
|
192
|
+
}
|
193
|
+
[5] pry(main)> demo3 = UuidDemo.new id: '12345678123456784fad123456789012'
|
194
|
+
Dry::Types::StructError: [UuidDemo.new] "12345678123456784fad123456789012" (String) has invalid type for :id
|
195
|
+
from (omitted):in 'rescue in new'
|
196
|
+
[6] pry(main)> exit
|
197
|
+
$
|
198
|
+
```
|
199
|
+
|
200
|
+
#### Notes
|
201
|
+
|
202
|
+
Remember that UUIDs, by definition, are for all practical purposes never generated with the same value twice; one common source of grief is to have your test code generate a UUID, then test your code under test which *also* generates a UUID, and from there, [hilarity ensues](http://tvtropes.org/pmwiki/pmwiki.php/Main/HilarityEnsues?from=Main.HilarityEnsued) as you try to figure out why your tests never pass.
|
203
|
+
|
204
|
+
Also remember that the only valid format for a UUID is as a string; if you want to work with the value as though it were a vector of bytes, integers, etc, then you are On Your Own with the existing code.
|
205
|
+
|
206
|
+
## Development
|
207
|
+
|
208
|
+
After checking out the repo, run `bin/setup` to create a `Gemfile.lock` file which identifies specific versions of runtime and development dependencies of this Gem (which as of now must already be installed on your local system). Then, run `bin/rake test` to run the tests, or `bin/rake` to run tests and, if tests are successful, further static-analysis tools ([RuboCop](https://github.com/bbatsov/rubocop), [Flay](https://github.com/seattlerb/flay), [Flog](https://github.com/seattlerb/flog), and [Reek](https://github.com/troessner/reek)).
|
209
|
+
|
210
|
+
To install *your build* of this Gem onto your local machine, run `bin/rake install`. We recommend that you uninstall any previously-installed "official" Gem to increase your confidence that your tests are running against your build.
|
211
|
+
|
212
|
+
## Contributing
|
213
|
+
|
214
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/TheProlog/prolog-dry-types. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
215
|
+
|
216
|
+
|
217
|
+
## License
|
218
|
+
|
219
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rake/testtask"
|
4
|
+
|
5
|
+
require 'rake/tasklib'
|
6
|
+
require 'flay'
|
7
|
+
require 'flay_task'
|
8
|
+
require 'tasks/prolog_flog_task'
|
9
|
+
require 'reek/rake/task'
|
10
|
+
require 'rubocop/rake_task'
|
11
|
+
|
12
|
+
Rake::TestTask.new(:test) do |t|
|
13
|
+
t.libs << "test"
|
14
|
+
t.libs << "lib"
|
15
|
+
t.test_files = FileList['test/**/*_test.rb']
|
16
|
+
end
|
17
|
+
|
18
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
19
|
+
task.patterns = [
|
20
|
+
'lib/**/*.rb',
|
21
|
+
'test/**/*.rb'
|
22
|
+
]
|
23
|
+
task.formatters = ['simple', 'd']
|
24
|
+
task.fail_on_error = true
|
25
|
+
task.options << '--display-cop-names'
|
26
|
+
end
|
27
|
+
|
28
|
+
Reek::Rake::Task.new do |t|
|
29
|
+
t.config_file = 'config.reek'
|
30
|
+
t.source_files = 'lib/**/*.rb'
|
31
|
+
t.reek_opts = '--sort-by smelliness -s'
|
32
|
+
end
|
33
|
+
|
34
|
+
FlayTask.new do |t|
|
35
|
+
t.verbose = true
|
36
|
+
t.dirs = %w(app lib)
|
37
|
+
end
|
38
|
+
|
39
|
+
FlogTask.new do |t|
|
40
|
+
t.verbose = true
|
41
|
+
t.threshold = 200 # default is 200
|
42
|
+
t.methods_only = true
|
43
|
+
t.dirs = %w(lib)
|
44
|
+
end
|
45
|
+
|
46
|
+
task(:default).clear
|
47
|
+
task default: [:test, :rubocop, :flay, :flog, :reek]
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "prolog/dry_types"
|
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
|
data/bin/setup
ADDED
data/config.reek
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-types'
|
4
|
+
|
5
|
+
# `Types` as a top-level namespace module seems to be a `dry-types` convention.
|
6
|
+
module Types
|
7
|
+
include Dry::Types.module # should have already been included
|
8
|
+
|
9
|
+
ErrorArray = Types::Strict::Array.member(Types::Strict::Hash)
|
10
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-types'
|
4
|
+
|
5
|
+
require_relative './range'
|
6
|
+
|
7
|
+
# `Types` as a top-level namespace module seems to be a `dry-types` convention.
|
8
|
+
module Types
|
9
|
+
include Dry::Types.module # should have already been included
|
10
|
+
|
11
|
+
# The original version of this type treated initialisation with an integer
|
12
|
+
# value of zero as invalid, setting the initialised range to (-1..-1). On
|
13
|
+
# reflection, this makes little sense as a general-purpose behaviour, as it is
|
14
|
+
# highly likely to surprise casual users.
|
15
|
+
IntegerRange = Range.constructor do |value|
|
16
|
+
if value.is_a?(::Range)
|
17
|
+
value
|
18
|
+
else
|
19
|
+
0..value.to_i
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-types'
|
4
|
+
|
5
|
+
# These need to be before `Dry::Types.module` is included. Also,
|
6
|
+
# obviously, after requiring `dry-types`.
|
7
|
+
Dry::Types.register 'range', Dry::Types::Definition[Range].new(Range)
|
8
|
+
Dry::Types.register 'strict.range',
|
9
|
+
Dry::Types['range'].constrained(type: Range)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-types'
|
4
|
+
|
5
|
+
# `Types` as a top-level namespace module seems to be a `dry-types` convention.
|
6
|
+
module Types
|
7
|
+
include Dry::Types.module # should have already been included
|
8
|
+
|
9
|
+
TimeOrNow = Types::Strict::Time.default { ::Time.now }
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uuid'
|
4
|
+
|
5
|
+
require 'dry-types'
|
6
|
+
|
7
|
+
# `Types` as a top-level namespace module seems to be a `dry-types` convention.
|
8
|
+
module Types
|
9
|
+
include Dry::Types.module # should have already been included
|
10
|
+
|
11
|
+
UUID_FORMAT = /\A\h{8}(-\h{4}){3}\-\h{12}\z/
|
12
|
+
UUID = Types::Strict::String.default { ::UUID.generate }
|
13
|
+
.constrained(format: UUID_FORMAT)
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-types'
|
4
|
+
|
5
|
+
require 'prolog/dry_types/version'
|
6
|
+
require 'prolog/dry_types/range'
|
7
|
+
|
8
|
+
# `Types` as a top-level namespace module seems to be a `dry-types` convention.
|
9
|
+
module Types
|
10
|
+
include Dry::Types.module
|
11
|
+
end
|
12
|
+
|
13
|
+
require_relative './dry_types/error_array'
|
14
|
+
require_relative './dry_types/integer_range'
|
15
|
+
require_relative './dry_types/time_or_now'
|
16
|
+
require_relative './dry_types/uuid'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rake/tasklib'
|
4
|
+
require 'flog'
|
5
|
+
require 'flog_task'
|
6
|
+
|
7
|
+
# Redefinition of standard task's Rake invocation. Because we don't like
|
8
|
+
# inconsistency in option settings.
|
9
|
+
class FlogTask < Rake::TaskLib
|
10
|
+
# Reek bitches that this is a :reek:Attribute (writable). That's the *point*.
|
11
|
+
attr_accessor :methods_only
|
12
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'prolog/dry_types/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "prolog-dry_types"
|
9
|
+
spec.version = Prolog::DryTypes::VERSION
|
10
|
+
spec.required_ruby_version = '>= 2.3.0'
|
11
|
+
spec.authors = ["Jeff Dickey"]
|
12
|
+
spec.email = ["jdickey@seven-sigma.com"]
|
13
|
+
|
14
|
+
spec.summary = %q{Dry::Types typedefs found to be generally useful. Replaces deprecated prolog-dry-types.}
|
15
|
+
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
16
|
+
spec.homepage = "https://github.com/TheProlog/prolog-dry_types"
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
# if spec.respond_to?(:metadata)
|
21
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
22
|
+
# else
|
23
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency "dry-types", "~> 0.8", ">= 0.8.1"
|
32
|
+
spec.add_dependency "uuid", "~> 2.3", ">= 2.3.8"
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
35
|
+
spec.add_development_dependency "rake", "~> 11.2", ">= 11.2.2"
|
36
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
37
|
+
|
38
|
+
spec.add_development_dependency "minitest-matchers", "~> 1.4", ">= 1.4.1"
|
39
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.1", ">= 1.1.11"
|
40
|
+
spec.add_development_dependency "minitest-tagz", "~> 1.5", ">= 1.5.1"
|
41
|
+
|
42
|
+
spec.add_development_dependency "flay", "~> 2.8", ">= 2.8.0"
|
43
|
+
spec.add_development_dependency "flog", "~> 4.4", ">= 4.4.0"
|
44
|
+
spec.add_development_dependency "reek", "~> 4.2", ">= 4.2.2"
|
45
|
+
spec.add_development_dependency "rubocop", "~> 0.42", ">= 0.42.0"
|
46
|
+
spec.add_development_dependency "simplecov", "~> 0.12", ">= 0.12.0"
|
47
|
+
spec.add_development_dependency "pry-byebug", "~> 3.4", ">= 3.4.0"
|
48
|
+
spec.add_development_dependency "pry-doc", "~> 0.9", ">= 0.9.0"
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,351 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prolog-dry_types
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Dickey
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-types
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.8.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.8'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.8.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: uuid
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.3'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.3.8
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.3'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.3.8
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.12'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.12'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '11.2'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 11.2.2
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '11.2'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 11.2.2
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: minitest
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '5.0'
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '5.0'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: minitest-matchers
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '1.4'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.4.1
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.4'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.4.1
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: minitest-reporters
|
123
|
+
requirement: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '1.1'
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 1.1.11
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '1.1'
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 1.1.11
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: minitest-tagz
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '1.5'
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 1.5.1
|
151
|
+
type: :development
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '1.5'
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 1.5.1
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: flay
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '2.8'
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 2.8.0
|
171
|
+
type: :development
|
172
|
+
prerelease: false
|
173
|
+
version_requirements: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - "~>"
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '2.8'
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 2.8.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: flog
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '4.4'
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: 4.4.0
|
191
|
+
type: :development
|
192
|
+
prerelease: false
|
193
|
+
version_requirements: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - "~>"
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '4.4'
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: 4.4.0
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
name: reek
|
203
|
+
requirement: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - "~>"
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '4.2'
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: 4.2.2
|
211
|
+
type: :development
|
212
|
+
prerelease: false
|
213
|
+
version_requirements: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - "~>"
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '4.2'
|
218
|
+
- - ">="
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: 4.2.2
|
221
|
+
- !ruby/object:Gem::Dependency
|
222
|
+
name: rubocop
|
223
|
+
requirement: !ruby/object:Gem::Requirement
|
224
|
+
requirements:
|
225
|
+
- - "~>"
|
226
|
+
- !ruby/object:Gem::Version
|
227
|
+
version: '0.42'
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: 0.42.0
|
231
|
+
type: :development
|
232
|
+
prerelease: false
|
233
|
+
version_requirements: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - "~>"
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0.42'
|
238
|
+
- - ">="
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: 0.42.0
|
241
|
+
- !ruby/object:Gem::Dependency
|
242
|
+
name: simplecov
|
243
|
+
requirement: !ruby/object:Gem::Requirement
|
244
|
+
requirements:
|
245
|
+
- - "~>"
|
246
|
+
- !ruby/object:Gem::Version
|
247
|
+
version: '0.12'
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: 0.12.0
|
251
|
+
type: :development
|
252
|
+
prerelease: false
|
253
|
+
version_requirements: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0.12'
|
258
|
+
- - ">="
|
259
|
+
- !ruby/object:Gem::Version
|
260
|
+
version: 0.12.0
|
261
|
+
- !ruby/object:Gem::Dependency
|
262
|
+
name: pry-byebug
|
263
|
+
requirement: !ruby/object:Gem::Requirement
|
264
|
+
requirements:
|
265
|
+
- - "~>"
|
266
|
+
- !ruby/object:Gem::Version
|
267
|
+
version: '3.4'
|
268
|
+
- - ">="
|
269
|
+
- !ruby/object:Gem::Version
|
270
|
+
version: 3.4.0
|
271
|
+
type: :development
|
272
|
+
prerelease: false
|
273
|
+
version_requirements: !ruby/object:Gem::Requirement
|
274
|
+
requirements:
|
275
|
+
- - "~>"
|
276
|
+
- !ruby/object:Gem::Version
|
277
|
+
version: '3.4'
|
278
|
+
- - ">="
|
279
|
+
- !ruby/object:Gem::Version
|
280
|
+
version: 3.4.0
|
281
|
+
- !ruby/object:Gem::Dependency
|
282
|
+
name: pry-doc
|
283
|
+
requirement: !ruby/object:Gem::Requirement
|
284
|
+
requirements:
|
285
|
+
- - "~>"
|
286
|
+
- !ruby/object:Gem::Version
|
287
|
+
version: '0.9'
|
288
|
+
- - ">="
|
289
|
+
- !ruby/object:Gem::Version
|
290
|
+
version: 0.9.0
|
291
|
+
type: :development
|
292
|
+
prerelease: false
|
293
|
+
version_requirements: !ruby/object:Gem::Requirement
|
294
|
+
requirements:
|
295
|
+
- - "~>"
|
296
|
+
- !ruby/object:Gem::Version
|
297
|
+
version: '0.9'
|
298
|
+
- - ">="
|
299
|
+
- !ruby/object:Gem::Version
|
300
|
+
version: 0.9.0
|
301
|
+
description:
|
302
|
+
email:
|
303
|
+
- jdickey@seven-sigma.com
|
304
|
+
executables: []
|
305
|
+
extensions: []
|
306
|
+
extra_rdoc_files: []
|
307
|
+
files:
|
308
|
+
- ".gitignore"
|
309
|
+
- ".rubocop.yml"
|
310
|
+
- ".travis.yml"
|
311
|
+
- CODE_OF_CONDUCT.md
|
312
|
+
- Gemfile
|
313
|
+
- LICENSE.txt
|
314
|
+
- README.md
|
315
|
+
- Rakefile
|
316
|
+
- bin/console
|
317
|
+
- bin/setup
|
318
|
+
- config.reek
|
319
|
+
- lib/prolog/dry_types.rb
|
320
|
+
- lib/prolog/dry_types/error_array.rb
|
321
|
+
- lib/prolog/dry_types/integer_range.rb
|
322
|
+
- lib/prolog/dry_types/range.rb
|
323
|
+
- lib/prolog/dry_types/time_or_now.rb
|
324
|
+
- lib/prolog/dry_types/uuid.rb
|
325
|
+
- lib/prolog/dry_types/version.rb
|
326
|
+
- lib/tasks/prolog_flog_task.rb
|
327
|
+
- prolog-dry_types.gemspec
|
328
|
+
homepage: https://github.com/TheProlog/prolog-dry_types
|
329
|
+
licenses: []
|
330
|
+
metadata: {}
|
331
|
+
post_install_message:
|
332
|
+
rdoc_options: []
|
333
|
+
require_paths:
|
334
|
+
- lib
|
335
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
336
|
+
requirements:
|
337
|
+
- - ">="
|
338
|
+
- !ruby/object:Gem::Version
|
339
|
+
version: 2.3.0
|
340
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
341
|
+
requirements:
|
342
|
+
- - ">="
|
343
|
+
- !ruby/object:Gem::Version
|
344
|
+
version: '0'
|
345
|
+
requirements: []
|
346
|
+
rubyforge_project:
|
347
|
+
rubygems_version: 2.6.6
|
348
|
+
signing_key:
|
349
|
+
specification_version: 4
|
350
|
+
summary: Dry::Types typedefs found to be generally useful. Replaces deprecated prolog-dry-types.
|
351
|
+
test_files: []
|