rice_bubble 0.1.1 → 0.1.2

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: 4a6ac1880406c9b129d4d9f0fa1029acc21a46cb1a3c9be1feaece000fc99e5c
4
- data.tar.gz: 6f684b2691b37a6ccb30cd73aa4d45ab689546377f184e3fb33d8e5eab8e22e7
3
+ metadata.gz: 5ff1a10fe0388c60a178246ee4c45a005292355ec741b9f175b56c8ba393b060
4
+ data.tar.gz: 35c94ec3a32ea7187b031eaf4341c59ad4a55649510bece671a52b480a10c2c5
5
5
  SHA512:
6
- metadata.gz: 4936fab7ed2f4a4d5ba5e044606f11ce6311e51b287f4bcdc4024113b90d2ae0e2323eb63af42b7a860bc9ccba9b4c1bc785ebfd555d8e49fd7e7af57862a261
7
- data.tar.gz: 04fb49f5fd9e425b2df7311ef7301e6613a279301de442047b171a90a2ee1b063d4de117255c4f75a2e01e96de458220be06ba2704b5eed3f85fa5313fb19b6a
6
+ metadata.gz: 1eb7c799044b2d70f6f13a2066d175b4ff09965b19b11d91c36493509d579e6e9ea6ebbeb4cfe1d897faf5aded93bc74ea5e955db81fc396bda9a292689537c3
7
+ data.tar.gz: 9bd2f3aa7f5c6c70ebb5c8afc1d2ca2d4ee95e2978c5491c5a6a1e225ce31c4f3ea5e908a933fa48d74e1cea4d437e131f1718c5e0c496df7c7bf0f99196699b
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ## [Unreleased]
1
+ ## [0.1.2] - 2023-05-23
2
+
3
+ - Add DateTime attribute type
2
4
 
3
5
  ## [0.1.0] - 2023-05-04
4
6
 
@@ -0,0 +1,28 @@
1
+ module RiceBubble
2
+ class Attributes
3
+ class Datetime < Base
4
+ def valid?(value)
5
+ return false unless valid_datetime?(value)
6
+
7
+ value.respond_to?(:to_datetime)
8
+ end
9
+
10
+ def coerce(value)
11
+ return nil unless valid_datetime?(value)
12
+
13
+ value.respond_to?(:to_datetime) ? value.to_datetime : value
14
+ end
15
+
16
+ private
17
+
18
+ def valid_datetime?(value)
19
+ case value
20
+ when ::Time then true
21
+ when ::DateTime then true
22
+ when ::Date then false
23
+ else value.respond_to?(:to_datetime)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module RiceBubble
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
data/lib/rice_bubble.rb CHANGED
@@ -5,6 +5,7 @@ require_relative 'rice_bubble/attributes/any'
5
5
  require_relative 'rice_bubble/attributes/array'
6
6
  require_relative 'rice_bubble/attributes/boolean'
7
7
  require_relative 'rice_bubble/attributes/date'
8
+ require_relative 'rice_bubble/attributes/datetime'
8
9
  require_relative 'rice_bubble/attributes/enum'
9
10
  require_relative 'rice_bubble/attributes/number'
10
11
  require_relative 'rice_bubble/attributes/integer'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rice_bubble
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Powell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-12 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -146,6 +146,7 @@ files:
146
146
  - lib/rice_bubble/attributes/base.rb
147
147
  - lib/rice_bubble/attributes/boolean.rb
148
148
  - lib/rice_bubble/attributes/date.rb
149
+ - lib/rice_bubble/attributes/datetime.rb
149
150
  - lib/rice_bubble/attributes/enum.rb
150
151
  - lib/rice_bubble/attributes/integer.rb
151
152
  - lib/rice_bubble/attributes/literal.rb