ensurance 0.1.26 → 0.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/CHANGELOG.md +3 -1
- data/Gemfile.lock +34 -31
- data/lib/ensurance/time_ensure.rb +20 -20
- data/lib/ensurance/version.rb +3 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb3462b1b10a12355e59ff4b7709e6a439d9114b3c35d056e72ff49449f1c30f
|
4
|
+
data.tar.gz: 3921e9484383934f097da4d9184162f66ecfef36da878ccf7b3b7fcf3f9589e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d8d760fb541bb58e0d12271bd9cb14cea799c59d6e8b1c035453fedf65b353e819df0de9318cfb628f075db6da91e8149985737baec27ed286bd82ce4cbb7e4
|
7
|
+
data.tar.gz: 7ac86524e006719d7843ccaf559c96f810f2f150ff74db549a6ea5b02032299e194d21a12a10ec239ae23040f7aa90a4458f12a8fc24d7248c3c7ab62233da69
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,47 +1,50 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ensurance (0.1.
|
4
|
+
ensurance (0.1.27)
|
5
5
|
activesupport (>= 3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (
|
11
|
-
activesupport (=
|
12
|
-
activerecord (
|
13
|
-
activemodel (=
|
14
|
-
activesupport (=
|
15
|
-
activesupport (
|
10
|
+
activemodel (6.0.3)
|
11
|
+
activesupport (= 6.0.3)
|
12
|
+
activerecord (6.0.3)
|
13
|
+
activemodel (= 6.0.3)
|
14
|
+
activesupport (= 6.0.3)
|
15
|
+
activesupport (6.0.3)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>=
|
18
|
-
minitest (
|
19
|
-
tzinfo (~>
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
i18n (>= 0.7, < 2)
|
18
|
+
minitest (~> 5.1)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
21
|
+
awesome_print (1.8.0)
|
22
|
+
concurrent-ruby (1.1.6)
|
23
|
+
diff-lcs (1.3)
|
24
|
+
globalid (0.4.2)
|
25
|
+
activesupport (>= 4.2.0)
|
26
|
+
i18n (1.8.2)
|
26
27
|
concurrent-ruby (~> 1.0)
|
27
|
-
minitest (5.
|
28
|
-
rake (13.0.
|
29
|
-
rspec (3.
|
30
|
-
rspec-core (~> 3.
|
31
|
-
rspec-expectations (~> 3.
|
32
|
-
rspec-mocks (~> 3.
|
33
|
-
rspec-core (3.
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-expectations (3.
|
28
|
+
minitest (5.14.0)
|
29
|
+
rake (13.0.1)
|
30
|
+
rspec (3.9.0)
|
31
|
+
rspec-core (~> 3.9.0)
|
32
|
+
rspec-expectations (~> 3.9.0)
|
33
|
+
rspec-mocks (~> 3.9.0)
|
34
|
+
rspec-core (3.9.2)
|
35
|
+
rspec-support (~> 3.9.3)
|
36
|
+
rspec-expectations (3.9.1)
|
36
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.9.0)
|
39
|
+
rspec-mocks (3.9.1)
|
39
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-support (3.
|
41
|
+
rspec-support (~> 3.9.0)
|
42
|
+
rspec-support (3.9.3)
|
42
43
|
sqlite3 (1.4.2)
|
43
|
-
|
44
|
-
|
44
|
+
thread_safe (0.3.6)
|
45
|
+
tzinfo (1.2.7)
|
46
|
+
thread_safe (~> 0.1)
|
47
|
+
zeitwerk (2.3.0)
|
45
48
|
|
46
49
|
PLATFORMS
|
47
50
|
ruby
|
@@ -14,25 +14,27 @@ module Ensurance
|
|
14
14
|
::Time.zone ||= "UTC"
|
15
15
|
|
16
16
|
case thing.class.name
|
17
|
-
when 'NilClass'
|
17
|
+
when 'NilClass', 'Time'
|
18
18
|
thing
|
19
|
-
when
|
20
|
-
thing
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
if thing.to_i.to_s == thing.to_s
|
25
|
-
dec = thing.to_s.size - 10
|
26
|
-
thing /= (10 ** dec).to_f if dec > 0
|
19
|
+
when "Integer"
|
20
|
+
if thing < 10 ** 10
|
21
|
+
::Time.zone.at(thing)
|
22
|
+
else # assume millis
|
23
|
+
::Time.zone.at(thing / 1000.0)
|
27
24
|
end
|
25
|
+
when "Float"
|
28
26
|
::Time.zone.at(thing)
|
29
27
|
when 'String'
|
30
|
-
if thing.
|
31
|
-
::Time.
|
32
|
-
elsif thing.
|
33
|
-
|
28
|
+
if thing.match?(/\d{2}:\d{2}/) || thing.match?(/^\d{4}-\d{2}-\d{2}$/)
|
29
|
+
::Time.parse(thing)
|
30
|
+
elsif thing.match?(/^\d+\.\d+$/)
|
31
|
+
self.ensure(thing.to_f)
|
32
|
+
elsif thing.match?(/^\d+$/)
|
33
|
+
self.ensure(thing.to_i)
|
34
|
+
elsif thing.blank?
|
35
|
+
nil
|
34
36
|
else
|
35
|
-
|
37
|
+
raise ArgumentError, "Cannot convert #{thing.class}/\"#{thing}\" to Time"
|
36
38
|
end
|
37
39
|
else
|
38
40
|
if thing.respond_to?(:to_time)
|
@@ -43,12 +45,10 @@ module Ensurance
|
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
|
-
def ensure!(
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
result
|
51
|
-
end
|
48
|
+
def ensure!(thing)
|
49
|
+
result = self.ensure(thing)
|
50
|
+
raise ArgumentError, "Cannot Time.ensure(#{thing})" unless result
|
51
|
+
result
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
data/lib/ensurance/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ensurance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sharpe
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -149,6 +149,7 @@ extra_rdoc_files: []
|
|
149
149
|
files:
|
150
150
|
- ".gitignore"
|
151
151
|
- ".rspec"
|
152
|
+
- ".tool-versions"
|
152
153
|
- ".travis.yml"
|
153
154
|
- CHANGELOG.md
|
154
155
|
- Gemfile
|
@@ -170,7 +171,7 @@ homepage: https://github.com/bsharpe/ensurance
|
|
170
171
|
licenses:
|
171
172
|
- MIT
|
172
173
|
metadata: {}
|
173
|
-
post_install_message:
|
174
|
+
post_install_message:
|
174
175
|
rdoc_options: []
|
175
176
|
require_paths:
|
176
177
|
- lib
|
@@ -185,8 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
186
|
- !ruby/object:Gem::Version
|
186
187
|
version: '0'
|
187
188
|
requirements: []
|
188
|
-
rubygems_version: 3.
|
189
|
-
signing_key:
|
189
|
+
rubygems_version: 3.3.15
|
190
|
+
signing_key:
|
190
191
|
specification_version: 4
|
191
192
|
summary: Add ability to ensure ActiveRecord models
|
192
193
|
test_files: []
|