subroutine 3.0.2 → 3.0.3

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: a69ecebbd8549a3067d41ac4d8981d51c175614f4e052b296226cdce3ad15b30
4
- data.tar.gz: e375bae8ee9f1e73ff3eb3128373d50e4cd20af0cf68eaeef16af28688ca2d36
3
+ metadata.gz: a2dedf592996ae8331d333379af49033a3f5a3e74a4c8dd8d8cf5fbe7c878258
4
+ data.tar.gz: ab33d0b731a9f28b52e4661fdcb6626d6eda2f2e8883a8f05ecfa2b529f2961a
5
5
  SHA512:
6
- metadata.gz: bc51e2794c9a41589aec6d47097cc13644f6e9683b5d5e99ce13310dcf07184d23896dd493ab00ddf54dfa648d7b6236a45968318194b8da53ac66663ae28fc7
7
- data.tar.gz: ef4e70f7bf48e180485082f1107b84a9ffbc02037dcc100432435d07d6a634d427ce58546f3010f24723f7e9fbdac52067944fba1294c71078ce11cf30e66488
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
- ::Time.parse(String(value))
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 = {}|
@@ -4,7 +4,7 @@ module Subroutine
4
4
 
5
5
  MAJOR = 3
6
6
  MINOR = 0
7
- PATCH = 2
7
+ PATCH = 3
8
8
  PRE = nil
9
9
 
10
10
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
@@ -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:30Z'
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.2
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-04-03 00:00:00.000000000 Z
11
+ date: 2024-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel