thy 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -1
- data/lib/thy.rb +3 -0
- data/lib/thy/types/datetime.rb +15 -0
- data/lib/thy/types/time.rb +15 -0
- data/thy.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ccbbda02412e2b1ad6c3fb20300a275dc430f2225e3ee593811b7cb428b2533
|
4
|
+
data.tar.gz: 2a4ee81daa40594a99d5c46b04994dde247727f6b315804472ffa31041a67c6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 233fc9226bfd960c2457fa61517298715c712b28a9744bd11df280f0cd9c69d036530ba489b8cdad244a6b7abdf40139ace24c6f401da7c75d6789f746db9c36
|
7
|
+
data.tar.gz: dd2cd66cc7a18e7c05804d907c156ce040c7001d96c9b60d6ee06d491b977b48db6b331fe9583c5b77430e0c6ad87c428ddf2f14a16bcc8ea8c0aa39d243b5b2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -76,7 +76,7 @@ module Types
|
|
76
76
|
include Thy::Types
|
77
77
|
|
78
78
|
NonZeroValue = Thy::Type.new do |value|
|
79
|
-
value
|
79
|
+
value != 0 || Thy::Result::Failure.new("Expected #{value.inspect} to be nonzero")
|
80
80
|
end
|
81
81
|
end
|
82
82
|
```
|
@@ -127,6 +127,15 @@ Thy::Integer.check(3).success? # => true
|
|
127
127
|
Thy::Boolean.check(true).success? # => true
|
128
128
|
Thy::Boolean.check(false).success? # => true
|
129
129
|
|
130
|
+
# Time
|
131
|
+
Thy::Time.check(Time.now).success? # => true
|
132
|
+
Thy::Time.check(0).success? # => false
|
133
|
+
|
134
|
+
# DateTime
|
135
|
+
require 'date'
|
136
|
+
Thy::DateTime.check(DateTime.now).success? # => true
|
137
|
+
Thy::DateTime.check(0).success? # => false
|
138
|
+
|
130
139
|
# nil
|
131
140
|
Thy::Nil.check(nil).success? # => true
|
132
141
|
Thy::Nil.check(0).success? # => false
|
data/lib/thy.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thy
|
4
|
+
module Types
|
5
|
+
module DateTime
|
6
|
+
def self.check(value)
|
7
|
+
if value.is_a?(::DateTime)
|
8
|
+
Result::Success
|
9
|
+
else
|
10
|
+
Result::Failure.new("Expected DateTime, but got: #{value.inspect}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/thy.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Komarov <ak@akxcv.com>
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/thy/types/array.rb
|
107
107
|
- lib/thy/types/boolean.rb
|
108
108
|
- lib/thy/types/class_extending.rb
|
109
|
+
- lib/thy/types/datetime.rb
|
109
110
|
- lib/thy/types/enum.rb
|
110
111
|
- lib/thy/types/float.rb
|
111
112
|
- lib/thy/types/hash.rb
|
@@ -117,6 +118,7 @@ files:
|
|
117
118
|
- lib/thy/types/option.rb
|
118
119
|
- lib/thy/types/string.rb
|
119
120
|
- lib/thy/types/symbol.rb
|
121
|
+
- lib/thy/types/time.rb
|
120
122
|
- lib/thy/types/untyped_array.rb
|
121
123
|
- lib/thy/types/untyped_hash.rb
|
122
124
|
- lib/thy/types/variant.rb
|