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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8e119f100c2d79df5089c32fc407f038e208ef8acdba30c01573b262a4eb139
4
- data.tar.gz: 3d6000c7313dfbfe61fc1c1959a38c08ff3118b2b560d4f73cddf3c0c130c8f4
3
+ metadata.gz: 2ccbbda02412e2b1ad6c3fb20300a275dc430f2225e3ee593811b7cb428b2533
4
+ data.tar.gz: 2a4ee81daa40594a99d5c46b04994dde247727f6b315804472ffa31041a67c6d
5
5
  SHA512:
6
- metadata.gz: 5566cd48c42f865fdb7f2c328e4f98e723f82f69ba2a71150d765c144fe2209e68cf62f143c34bc657f773a8499d888495698f5c1517c4a146db5592286f3a89
7
- data.tar.gz: aae23e9108b6e06aab5c0e3f71d4785673dce4c7e314bf913201cc9d1cf9c7621359692845172b1c80fc797773bd77c4e8cbb10dd27aad3e67969d32b702b397
6
+ metadata.gz: 233fc9226bfd960c2457fa61517298715c712b28a9744bd11df280f0cd9c69d036530ba489b8cdad244a6b7abdf40139ace24c6f401da7c75d6789f746db9c36
7
+ data.tar.gz: dd2cd66cc7a18e7c05804d907c156ce040c7001d96c9b60d6ee06d491b977b48db6b331fe9583c5b77430e0c6ad87c428ddf2f14a16bcc8ea8c0aa39d243b5b2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thy (0.1.3)
4
+ thy (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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 == 0 || Thy::Result::Failure.new("Expected #{value.inspect} to be nonzero")
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
@@ -11,6 +11,9 @@ require 'thy/types/float'
11
11
  require 'thy/types/boolean'
12
12
  require 'thy/types/nil'
13
13
 
14
+ require 'thy/types/time'
15
+ require 'thy/types/datetime'
16
+
14
17
  require 'thy/types/array'
15
18
  require 'thy/types/untyped_array'
16
19
 
@@ -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
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thy
4
+ module Types
5
+ module Time
6
+ def self.check(value)
7
+ if value.is_a?(::Time)
8
+ Result::Success
9
+ else
10
+ Result::Failure.new("Expected Time, but got: #{value.inspect}")
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'thy'
8
- spec.version = '0.1.3'
8
+ spec.version = '0.1.4'
9
9
  spec.authors = ['Alexander Komarov <ak@akxcv.com>']
10
10
  spec.email = ['ak@akxcv.com']
11
11
 
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.3
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-10-17 00:00:00.000000000 Z
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