forget_table 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 51b34b5b1d37ac5d704a4d7e48c6b635fb8de7b0
4
- data.tar.gz: 276ca5952d1e6bdcca27c1c257c8b1fb4b3054d7
3
+ metadata.gz: 2c9b1ef276b379ae6552110f0b5578918970f391
4
+ data.tar.gz: 0fdbf0d6b22f7654edcd6186549276b20f61486d
5
5
  SHA512:
6
- metadata.gz: d28a09e53676e1b908a8bdcefded130c241b71bdebf5610c48d0e2b25c39d063293f1efc1c82483c8c7552630efc3def2844a103fa98ed0833bb924ad9b03129
7
- data.tar.gz: 8abb4e1332f2aeac8f2423d09b47fdfd081ae8d86c853915b503662b9d2d9687e3da7865d753faf46dbe89304784dc0a9c1797aad5f7973a901f6058ce54c5cf
6
+ metadata.gz: be440481a82942e904bdddfacf64589efbb4304c4227baa01063f685ef5257e91517c12b94f5aa4f906ce6b1d5e70b6f5ea2d77179fdbd9163a6f6dad3c96748
7
+ data.tar.gz: 43326a746a2b82cd2f879cf3ce41564cd813a888560d6b0b00abd76db84783f603977eccca8206046d408c46e2c0a36505a44771227313f9de1e4bdb030e7b97
@@ -1,5 +1,6 @@
1
1
  require 'redis'
2
2
 
3
+ require 'forget_table/configuration'
3
4
  require 'forget_table/decay'
4
5
  require 'forget_table/decrementer'
5
6
  require 'forget_table/distribution'
@@ -0,0 +1,14 @@
1
+ module ForgetTable
2
+
3
+ class Configuration
4
+
5
+ def self.decay_rate
6
+ @decay_rate || ForgetTable::Decay::DEFAULT_DECAY_RATE
7
+ end
8
+
9
+ def self.decay_rate=(value)
10
+ @decay_rate = value
11
+ end
12
+
13
+ end
14
+ end
@@ -2,7 +2,7 @@ module ForgetTable
2
2
 
3
3
  class Decay
4
4
 
5
- DEFAULT_DECAY_RATE = 0.05
5
+ DEFAULT_DECAY_RATE = 0.2
6
6
 
7
7
  # - last_updated: timestamp of the last update
8
8
  # - rate: the rate of the decay (optional)
@@ -25,8 +25,12 @@ module ForgetTable
25
25
  end
26
26
 
27
27
  def decrement(values)
28
- decay = Decay.new(last_updated_at)
28
+ decay = Decay.new(last_updated_at, decay_rate)
29
29
  values.map { |value| decay.decay_value(value) }
30
30
  end
31
+
32
+ def decay_rate
33
+ ForgetTable::Configuration.decay_rate
34
+ end
31
35
  end
32
36
  end
@@ -20,7 +20,9 @@ describe ForgetTable::DistributionDecrementer do
20
20
  end
21
21
 
22
22
  before do
23
- allow(ForgetTable::Decay).to receive(:new).with(last_updated_at) { |arg| FakeDecay.new(arg) }
23
+ allow(ForgetTable::Decay).to receive(:new).with(
24
+ last_updated_at, ForgetTable::Configuration.decay_rate
25
+ ) { |arg| FakeDecay.new(arg) }
24
26
  end
25
27
 
26
28
  class FakeDecay
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forget_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolò Calcavecchia
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - lib/forget_table.rb
77
+ - lib/forget_table/configuration.rb
77
78
  - lib/forget_table/decay.rb
78
79
  - lib/forget_table/decrementer.rb
79
80
  - lib/forget_table/distribution.rb