counterwise 0.1.7 → 0.1.8

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: 872eddb45910800263c3c79d08192c149f1a93e406b777ace0e37a069b27c581
4
- data.tar.gz: f1c75031995349a525f45ef0127dbad1dd8e922a31c638936ebecd5da8995b7e
3
+ metadata.gz: 98ea12fd31d7f6fbf9d9e1c11c682825ff8f713558d50f6c16033251f8bc33af
4
+ data.tar.gz: 763508e600c386bbe73c8734619944bb9fbfd2081ee8315fadb1c2ac5fe83178
5
5
  SHA512:
6
- metadata.gz: acc758026ab1392efd1a18abed79901b51a9b19b3b310e6dcbb71fdf4daec4b06e3c5a191f7232f47a25b1fc402ad054c769daa32d4ea080632cbad5383df939
7
- data.tar.gz: a81196e23f65e894f2c31780633255fdf2900fe109ea5a7b240d9cd2d54310c79d8a6511886af1208e441b80214e42dcc455b06c1b3a0b7c8cbbd6af2b5de1f9
6
+ metadata.gz: cadb970d0a22154e6d2b38fe2b6a3573ea08812d966af0f6021bd7c9e52d7056a4a692cd768fa984fe666fcf0d7397d081b9f7cb1252650f37a6c5921e1a165b
7
+ data.tar.gz: f7c519035c5c1ad238827d6b70121537e983100c0150e29b9686fc8db15d6e1b72c3a89a0f9e306ec787d5fd1b1492cc3ee824488667f3a3dd7c05f18649b4fe
data/README.md CHANGED
@@ -481,7 +481,7 @@ See the asociated project in Github but roughly I'm thinking:
481
481
 
482
482
  Bug reports and pull requests are welcome, especially around naming, internal APIs, bug fixes, and additional features. Please open an issue first if you're thinking of adding a new feature so we can discuss it.
483
483
 
484
- I'm unlikely to entertain suport for older Ruby or Rails versions, or databases other than Postgres.
484
+ I'm unlikely to entertain support for older Ruby or Rails versions, or databases other than Postgres.
485
485
 
486
486
  ## License
487
487
 
@@ -2,25 +2,29 @@ module Counter::Verifyable
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  def correct?
5
- # We can't verify these values
6
- return true if definition.global?
5
+ # We can't verify these values: manual counters (which includes globals)
6
+ # have no countable source of truth, so their stored value is authoritative.
7
+ return true if definition.manual?
7
8
 
8
- old_value, new_value = verify
9
- old_value == new_value
9
+ correct_value, current_value = verify
10
+ correct_value == current_value
10
11
  end
11
12
 
12
13
  def correct!
13
- # We can't verify these values
14
- return true if definition.global?
14
+ # We can't verify these values: manual counters (which includes globals)
15
+ # have no countable source of truth, so their stored value is authoritative.
16
+ return true if definition.manual?
15
17
 
16
- old_value, new_value = verify
18
+ correct_value, current_value = verify
17
19
 
18
- requires_recalculation = old_value != new_value
19
- update! value: new_value if requires_recalculation
20
+ requires_recalculation = correct_value != current_value
21
+ update! value: correct_value if requires_recalculation
20
22
 
21
23
  !requires_recalculation
22
24
  end
23
25
 
26
+ # Returns [correct_value, current_value]: the value recomputed from live
27
+ # data, and the value currently stored on the counter.
24
28
  def verify
25
29
  if definition.calculated?
26
30
  [calculate, value]
@@ -43,7 +47,7 @@ module Counter::Verifyable
43
47
  counter = counters.where("id >= ?", random_id).limit(1).first
44
48
  next if counter.nil?
45
49
 
46
- if counter.definition.global? || counter.definition.calculated?
50
+ if counter.definition.manual? || counter.definition.calculated?
47
51
  puts "➡️ Skipping counter #{counter.name} (#{counter.id})" if verbose
48
52
  next
49
53
  end
@@ -1,3 +1,3 @@
1
1
  module Counter
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: counterwise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Lawrence