ensurance 0.1.23 → 0.1.26
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/CHANGELOG.md +11 -1
- data/Gemfile.lock +32 -35
- data/lib/ensurance/time_ensure.rb +5 -1
- data/lib/ensurance/version.rb +1 -1
- data/lib/ensurance.rb +4 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abc1835e5b3de9739e9b9251e18bcb537147de9cdcba75b515f49c003081217c
|
4
|
+
data.tar.gz: a74ed354554f1178716eea0cbc5acab7045ef4bacc6fdd3a18c60b98799c3b75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db7c657713d8a5c1aa5358d680b9cee04e7794932d544166c24d24a1fd209d712328c386470612e37205ee44448ceee9d87d5bb7a48f10c992351502a0d6f209
|
7
|
+
data.tar.gz: bfcbd5b6ea5a048e935cc0b2770a025ecb29380fbe153ea417e8d525fba4ea0dd7338ce0c6ee0e05e1ed3eae918aca15e8a769348bf4891117124ca4672ab3d4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
|
4
|
+
## 1.0.26
|
5
|
+
- auto handle milli and microseconds integers sent to Time.ensure
|
6
|
+
|
7
|
+
## 1.0.25
|
8
|
+
- have to use a string comparison for final result `1 != "1"`
|
9
|
+
|
10
|
+
## 1.0.24
|
11
|
+
- make sure that a string that starts with a number doesn't find an integer primary key record
|
12
|
+
|
3
13
|
## 1.0.23
|
4
14
|
- forgot version boundry on ActiveSupport
|
5
15
|
|
@@ -7,7 +17,7 @@
|
|
7
17
|
- support Rails 6+
|
8
18
|
|
9
19
|
## 1.0.21
|
10
|
-
- properly handle empty strings
|
20
|
+
- properly handle empty strings
|
11
21
|
|
12
22
|
## 1.0.20
|
13
23
|
- support Rails 6
|
data/Gemfile.lock
CHANGED
@@ -1,50 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ensurance (0.1.
|
4
|
+
ensurance (0.1.26)
|
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 (7.0.2.4)
|
11
|
+
activesupport (= 7.0.2.4)
|
12
|
+
activerecord (7.0.2.4)
|
13
|
+
activemodel (= 7.0.2.4)
|
14
|
+
activesupport (= 7.0.2.4)
|
15
|
+
activesupport (7.0.2.4)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>=
|
18
|
-
minitest (
|
19
|
-
tzinfo (~>
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
i18n (1.7.0)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
awesome_print (1.9.2)
|
21
|
+
concurrent-ruby (1.1.10)
|
22
|
+
diff-lcs (1.5.0)
|
23
|
+
globalid (1.0.0)
|
24
|
+
activesupport (>= 5.0)
|
25
|
+
i18n (1.10.0)
|
27
26
|
concurrent-ruby (~> 1.0)
|
28
|
-
minitest (5.
|
29
|
-
rake (13.0.
|
30
|
-
rspec (3.
|
31
|
-
rspec-core (~> 3.
|
32
|
-
rspec-expectations (~> 3.
|
33
|
-
rspec-mocks (~> 3.
|
34
|
-
rspec-core (3.
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-expectations (3.
|
27
|
+
minitest (5.15.0)
|
28
|
+
rake (13.0.6)
|
29
|
+
rspec (3.11.0)
|
30
|
+
rspec-core (~> 3.11.0)
|
31
|
+
rspec-expectations (~> 3.11.0)
|
32
|
+
rspec-mocks (~> 3.11.0)
|
33
|
+
rspec-core (3.11.0)
|
34
|
+
rspec-support (~> 3.11.0)
|
35
|
+
rspec-expectations (3.11.0)
|
37
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-mocks (3.
|
37
|
+
rspec-support (~> 3.11.0)
|
38
|
+
rspec-mocks (3.11.1)
|
40
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-support (3.
|
43
|
-
sqlite3 (1.4.
|
44
|
-
|
45
|
-
|
46
|
-
thread_safe (~> 0.1)
|
47
|
-
zeitwerk (2.2.1)
|
40
|
+
rspec-support (~> 3.11.0)
|
41
|
+
rspec-support (3.11.0)
|
42
|
+
sqlite3 (1.4.2)
|
43
|
+
tzinfo (2.0.4)
|
44
|
+
concurrent-ruby (~> 1.0)
|
48
45
|
|
49
46
|
PLATFORMS
|
50
47
|
ruby
|
@@ -21,10 +21,14 @@ module Ensurance
|
|
21
21
|
when 'Date'
|
22
22
|
thing.beginning_of_day
|
23
23
|
when 'Integer', 'Float'
|
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
|
27
|
+
end
|
24
28
|
::Time.zone.at(thing)
|
25
29
|
when 'String'
|
26
30
|
if thing.to_i.to_s == thing
|
27
|
-
::Time.
|
31
|
+
::Time.ensure(thing.to_i)
|
28
32
|
elsif thing.to_f.to_s == thing
|
29
33
|
::Time.zone.at(thing.to_f)
|
30
34
|
else
|
data/lib/ensurance/version.rb
CHANGED
data/lib/ensurance.rb
CHANGED
@@ -17,7 +17,7 @@ module Ensurance
|
|
17
17
|
def ensure_by(*args, order: nil)
|
18
18
|
@_additional_ensure_by = args
|
19
19
|
if (::ActiveRecord::Base.connection rescue false)
|
20
|
-
@_ensure_order = (order || primary_key).to_s
|
20
|
+
@_ensure_order = (order || self.primary_key).to_s
|
21
21
|
@_ensure_by = [@_additional_ensure_by || primary_key].flatten.compact.uniq
|
22
22
|
end
|
23
23
|
# ap "Ensure By: #{self}.#{@_ensure_by} Order: #{self}.#{@_ensure_order}"
|
@@ -36,7 +36,7 @@ module Ensurance
|
|
36
36
|
return found
|
37
37
|
end
|
38
38
|
|
39
|
-
@_ensure_by ||= [@_additional_ensure_by || primary_key].flatten.compact.uniq
|
39
|
+
@_ensure_by ||= [@_additional_ensure_by || self.primary_key].flatten.compact.uniq
|
40
40
|
@_ensure_order ||= primary_key
|
41
41
|
|
42
42
|
found = []
|
@@ -60,7 +60,8 @@ module Ensurance
|
|
60
60
|
else
|
61
61
|
record = find_by(ensure_field => value) if value.present? && !value.is_a?(Hash)
|
62
62
|
end
|
63
|
-
|
63
|
+
record = nil if record&.__send__(ensure_field).to_s != value.to_s
|
64
|
+
break if record
|
64
65
|
end
|
65
66
|
found << record
|
66
67
|
end
|
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.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sharpe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
rubygems_version: 3.
|
188
|
+
rubygems_version: 3.1.6
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: Add ability to ensure ActiveRecord models
|