state_of_the_nation 1.1.6 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc3cdbd88385c581951562d576585cc78ff3528de59b908b280ad331c4794bc4
4
- data.tar.gz: 4a41b1f65f1d1e517568deb529e1fdfaaae033a561d5b2d8b660a49588590c64
3
+ metadata.gz: f9953a5747485077b6b886669e70f2e652ec75837f2fc3a18e9593f208953d47
4
+ data.tar.gz: 9ffe1c9d237754ce9c2bdfbd8385e95e0b5ccbaa7eb8169dc10e4313a69e4253
5
5
  SHA512:
6
- metadata.gz: 35dba604ed379b09913369ac0f59b14593c5c6fd40f7fa999733235a71b8ab5da41e9fb6a03e635fc04ab83535eb7699303723c3036cadac9c206208e2873a0c
7
- data.tar.gz: 5a44d3263e9cafec224645750ae87e7e78faa7d85e27a5dbcc4e6a318658a1bdfec3da2554003fe6de712582a282341b655d2cbb8096385babf82603a2cad123
6
+ metadata.gz: bcbf936777c4cca79342052f6092ac1722a1cc006017e1abc7b9cd16c70c462ea06d83b05d7fc6123b113c13bc68b670f0cdee9b63ab77c68b80b6f570b8f505
7
+ data.tar.gz: e3d8a957ae397887f048bc3f105564d2e29a301c150a0233c9116b36f256c4e2ec1e994c983cc506830f6d7c6a0a7bcb4b473d7c6adff0b753fc5a8d9799e1c6
@@ -1,3 +1,3 @@
1
1
  module StateOfTheNation
2
- VERSION = "1.1.6"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -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? || round_if_should(finish) > round_if_should(time)) && round_if_should(start) <= round_if_should(time)
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 = round_if_should(start)
35
- record_end = round_if_should(finish)
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), round_if_should(time), round_if_should(time))
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 round_if_should(self.send(start_key) || Time.now.utc)
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
- round_if_should(self.send(finish_key))
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: 1.1.6
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: 2020-03-12 00:00:00.000000000 Z
12
+ date: 2022-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler