state_of_the_nation 1.1.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/state_of_the_nation/version.rb +1 -1
- data/lib/state_of_the_nation.rb +6 -33
- 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: f9953a5747485077b6b886669e70f2e652ec75837f2fc3a18e9593f208953d47
|
4
|
+
data.tar.gz: 9ffe1c9d237754ce9c2bdfbd8385e95e0b5ccbaa7eb8169dc10e4313a69e4253
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcbf936777c4cca79342052f6092ac1722a1cc006017e1abc7b9cd16c70c462ea06d83b05d7fc6123b113c13bc68b670f0cdee9b63ab77c68b80b6f570b8f505
|
7
|
+
data.tar.gz: e3d8a957ae397887f048bc3f105564d2e29a301c150a0233c9116b36f256c4e2ec1e994c983cc506830f6d7c6a0a7bcb4b473d7c6adff0b753fc5a8d9799e1c6
|
data/lib/state_of_the_nation.rb
CHANGED
@@ -27,12 +27,12 @@ module StateOfTheNation
|
|
27
27
|
@finish_key = finish_key
|
28
28
|
|
29
29
|
define_method "active?" do |time = Time.now.utc|
|
30
|
-
(finish.blank? ||
|
30
|
+
(finish.blank? || finish > time) && start <= time
|
31
31
|
end
|
32
32
|
|
33
33
|
define_method "active_in_interval?" do |interval_start, interval_end|
|
34
|
-
record_start =
|
35
|
-
record_end =
|
34
|
+
record_start = start
|
35
|
+
record_end = finish
|
36
36
|
if ignore_empty && record_start == record_end
|
37
37
|
false
|
38
38
|
elsif interval_start.nil? && interval_end.nil?
|
@@ -51,28 +51,10 @@ module StateOfTheNation
|
|
51
51
|
end
|
52
52
|
|
53
53
|
scope :active, lambda { |time = Time.now.utc|
|
54
|
-
where(QueryString.query_for(:active_scope, self),
|
54
|
+
where(QueryString.query_for(:active_scope, self), time, time)
|
55
55
|
}
|
56
56
|
end
|
57
57
|
|
58
|
-
private def round_if_should(time)
|
59
|
-
return time if !should_round_timestamps?
|
60
|
-
time.respond_to?(:round) ? time.round : time
|
61
|
-
end
|
62
|
-
|
63
|
-
private def should_round_timestamps?
|
64
|
-
# MySQL datetime fields do not support millisecond resolution while
|
65
|
-
# PostgreSQL's do. To prevent issues with near identical timestamps not
|
66
|
-
# comparing as expected in .active? methods we'll choose the resolution
|
67
|
-
# appropriate for the database adapter backing the model.
|
68
|
-
case self.connection.adapter_name
|
69
|
-
when /PostgreSQL/
|
70
|
-
false
|
71
|
-
else
|
72
|
-
true
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
58
|
self
|
77
59
|
end
|
78
60
|
|
@@ -163,12 +145,12 @@ module StateOfTheNation
|
|
163
145
|
|
164
146
|
def start
|
165
147
|
return unless start_key.present?
|
166
|
-
return
|
148
|
+
return self.send(start_key) || Time.now.utc
|
167
149
|
end
|
168
150
|
|
169
151
|
def finish
|
170
152
|
return unless finish_key.present?
|
171
|
-
|
153
|
+
self.send(finish_key)
|
172
154
|
end
|
173
155
|
|
174
156
|
def bad_configuration?
|
@@ -196,13 +178,4 @@ module StateOfTheNation
|
|
196
178
|
def ignore_empty
|
197
179
|
self.class.ignore_empty
|
198
180
|
end
|
199
|
-
|
200
|
-
def should_round_timestamps?
|
201
|
-
self.class.send(:should_round_timestamps?)
|
202
|
-
end
|
203
|
-
|
204
|
-
def round_if_should(time)
|
205
|
-
return time if time.nil?
|
206
|
-
self.class.send(:round_if_should, time)
|
207
|
-
end
|
208
181
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: state_of_the_nation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick O'Doherty
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|