subroutine 3.0.2 → 3.0.3
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/lib/subroutine/type_caster.rb +7 -1
- data/lib/subroutine/version.rb +1 -1
- data/test/subroutine/type_caster_test.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2dedf592996ae8331d333379af49033a3f5a3e74a4c8dd8d8cf5fbe7c878258
|
|
4
|
+
data.tar.gz: ab33d0b731a9f28b52e4661fdcb6626d6eda2f2e8883a8f05ecfa2b529f2961a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 26617e51aeb874dbabb64ad62add32903ad734014ed09e4b0c59f81829bb9bbf728726ab4c7690d82ce1280967b59507c689a58464c13216ad46df87b99c0ff5
|
|
7
|
+
data.tar.gz: 3a45d5cbac6d68660c875e0c7163b403276b360a7d37efb86199d2b593c04876060e6f83b99cef3e0dd2c144cba2c75c11a2eeb51a17253bfff49cb6657c55c7
|
|
@@ -4,9 +4,11 @@ require 'date'
|
|
|
4
4
|
require 'time'
|
|
5
5
|
require 'bigdecimal'
|
|
6
6
|
require 'securerandom'
|
|
7
|
+
require 'active_support/core_ext/object/acts_like'
|
|
7
8
|
require 'active_support/core_ext/object/blank'
|
|
8
9
|
require 'active_support/core_ext/object/try'
|
|
9
10
|
require 'active_support/core_ext/array/wrap'
|
|
11
|
+
require 'active_support/core_ext/time/acts_like'
|
|
10
12
|
|
|
11
13
|
module Subroutine
|
|
12
14
|
module TypeCaster
|
|
@@ -118,7 +120,11 @@ end
|
|
|
118
120
|
::Subroutine::TypeCaster.register :time, :timestamp, :datetime do |value, _options = {}|
|
|
119
121
|
next nil unless value.present?
|
|
120
122
|
|
|
121
|
-
|
|
123
|
+
if value.try(:acts_like?, :time)
|
|
124
|
+
value
|
|
125
|
+
else
|
|
126
|
+
::Time.parse(String(value))
|
|
127
|
+
end
|
|
122
128
|
end
|
|
123
129
|
|
|
124
130
|
::Subroutine::TypeCaster.register :hash, :object, :hashmap, :dict do |value, _options = {}|
|
data/lib/subroutine/version.rb
CHANGED
|
@@ -256,7 +256,7 @@ module Subroutine
|
|
|
256
256
|
assert_equal 0, op.time_input.min
|
|
257
257
|
assert_equal 0, op.time_input.sec
|
|
258
258
|
|
|
259
|
-
op.time_input = '2023-05-05T10:00:
|
|
259
|
+
op.time_input = '2023-05-05T10:00:30.123456Z'
|
|
260
260
|
assert_equal ::Time, op.time_input.class
|
|
261
261
|
refute_equal ::DateTime, op.time_input.class
|
|
262
262
|
|
|
@@ -266,6 +266,12 @@ module Subroutine
|
|
|
266
266
|
assert_equal 10, op.time_input.hour
|
|
267
267
|
assert_equal 0, op.time_input.min
|
|
268
268
|
assert_equal 30, op.time_input.sec
|
|
269
|
+
assert_equal 123456, op.time_input.usec
|
|
270
|
+
|
|
271
|
+
time = Time.at(1678741605.123456)
|
|
272
|
+
op.time_input = time
|
|
273
|
+
assert_equal time, op.time_input
|
|
274
|
+
assert_equal time.object_id, op.time_input.object_id
|
|
269
275
|
end
|
|
270
276
|
|
|
271
277
|
def test_iso_date_inputs
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: subroutine
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Nelson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|