streak 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.0
4
+
5
+ * Key-space is now separated by a single `:` instead of `::`
6
+
3
7
  ## 0.0.2
4
8
 
5
9
  * Fix +total_key+ configuration.
@@ -14,35 +14,35 @@ module Streak
14
14
  def aggregate(id, count)
15
15
  if count >= 0
16
16
  previous_data = Streak.redis.multi do |transaction|
17
- transaction.get("#{Streak::namespace}::#{Streak::positive_key}::#{id}")
18
- transaction.get("#{Streak::namespace}::#{Streak::positive_streak_key}::#{id}")
17
+ transaction.get("#{Streak.namespace}:#{Streak.positive_key}:#{id}")
18
+ transaction.get("#{Streak.namespace}:#{Streak.positive_streak_key}:#{id}")
19
19
  end
20
20
 
21
21
  previous_wins = previous_data[0].to_i
22
22
  previous_streak = previous_data[1].to_i
23
23
 
24
24
  Streak.redis.multi do |transaction|
25
- transaction.set("#{Streak::namespace}::#{Streak::positive_streak_key}::#{id}", [previous_wins + count, previous_streak].max)
26
- transaction.incrby("#{Streak::namespace}::#{Streak::positive_key}::#{id}", count.abs)
27
- transaction.incrby("#{Streak::namespace}::#{Streak::positive_total_key}::#{id}", count.abs)
28
- transaction.set("#{Streak::namespace}::#{Streak::negative_key}::#{id}", 0)
29
- transaction.incrby("#{Streak::namespace}::#{Streak::total_key}::#{id}", count.abs)
25
+ transaction.set("#{Streak.namespace}:#{Streak.positive_streak_key}:#{id}", [previous_wins + count, previous_streak].max)
26
+ transaction.incrby("#{Streak.namespace}:#{Streak.positive_key}:#{id}", count.abs)
27
+ transaction.incrby("#{Streak.namespace}:#{Streak.positive_total_key}:#{id}", count.abs)
28
+ transaction.set("#{Streak.namespace}:#{Streak.negative_key}:#{id}", 0)
29
+ transaction.incrby("#{Streak.namespace}:#{Streak.total_key}:#{id}", count.abs)
30
30
  end
31
31
  else
32
32
  previous_data = Streak.redis.multi do |transaction|
33
- transaction.get("#{Streak::namespace}::#{Streak::negative_key}::#{id}")
34
- transaction.get("#{Streak::namespace}::#{Streak::negative_streak_key}::#{id}")
33
+ transaction.get("#{Streak.namespace}:#{Streak.negative_key}:#{id}")
34
+ transaction.get("#{Streak.namespace}:#{Streak.negative_streak_key}:#{id}")
35
35
  end
36
36
 
37
37
  previous_losses = previous_data[0].to_i
38
38
  previous_streak = previous_data[1].to_i
39
39
 
40
40
  Streak.redis.multi do |transaction|
41
- transaction.set("#{Streak::namespace}::#{Streak::negative_streak_key}::#{id}", [previous_losses + count.abs, previous_streak].max)
42
- transaction.incrby("#{Streak::namespace}::#{Streak::negative_key}::#{id}", count.abs)
43
- transaction.incrby("#{Streak::namespace}::#{Streak::negative_total_key}::#{id}", count.abs)
44
- transaction.set("#{Streak::namespace}::#{Streak::positive_key}::#{id}", 0)
45
- transaction.incrby("#{Streak::namespace}::#{Streak::total_key}::#{id}", count.abs)
41
+ transaction.set("#{Streak.namespace}:#{Streak.negative_streak_key}:#{id}", [previous_losses + count.abs, previous_streak].max)
42
+ transaction.incrby("#{Streak.namespace}:#{Streak.negative_key}:#{id}", count.abs)
43
+ transaction.incrby("#{Streak.namespace}:#{Streak.negative_total_key}:#{id}", count.abs)
44
+ transaction.set("#{Streak.namespace}:#{Streak.positive_key}:#{id}", 0)
45
+ transaction.incrby("#{Streak.namespace}:#{Streak.total_key}:#{id}", count.abs)
46
46
  end
47
47
  end
48
48
  end
@@ -61,7 +61,7 @@ module Streak
61
61
  def statistics(id, keys = [Streak.positive_key, Streak.positive_total_key, Streak.positive_streak_key, Streak.negative_key, Streak.negative_total_key, Streak.negative_streak_key, Streak.total_key])
62
62
  values = Streak.redis.multi do |transaction|
63
63
  keys.each do |key|
64
- transaction.get("#{Streak::namespace}::#{key}::#{id}")
64
+ transaction.get("#{Streak.namespace}:#{key}:#{id}")
65
65
  end
66
66
  end.map(&:to_i)
67
67
 
@@ -74,7 +74,7 @@ module Streak
74
74
  def reset_statistics(id)
75
75
  Streak.redis.multi do |transaction|
76
76
  [Streak.positive_key, Streak.positive_total_key, Streak.positive_streak_key, Streak.negative_key, Streak.negative_total_key, Streak.negative_streak_key, Streak.total_key].each do |key|
77
- transaction.set("#{Streak::namespace}::#{key}::#{id}", 0)
77
+ transaction.set("#{Streak.namespace}:#{key}:#{id}", 0)
78
78
  end
79
79
  end
80
80
  end
@@ -1,3 +1,3 @@
1
1
  module Streak
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -21,6 +21,6 @@ RSpec.configure do |config|
21
21
  end
22
22
 
23
23
  def streak_value_for(key, id)
24
- Streak.redis.get("#{Streak::namespace}::#{key}::#{id}").to_i
24
+ Streak.redis.get("#{Streak.namespace}:#{key}:#{id}").to_i
25
25
  end
26
26
  end
@@ -2,8 +2,6 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  require 'streak/version'
4
4
 
5
- # require File.expand_path('../lib/streak/version', __FILE__)
6
-
7
5
  Gem::Specification.new do |gem|
8
6
  gem.authors = ["David Czarnecki"]
9
7
  gem.email = ["me@davidczarnecki.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-18 00:00:00.000000000 Z
12
+ date: 2012-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70174020795560 !ruby/object:Gem::Requirement
16
+ requirement: &70352190361800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70174020795560
24
+ version_requirements: *70352190361800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70174020795100 !ruby/object:Gem::Requirement
27
+ requirement: &70352190361340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70174020795100
35
+ version_requirements: *70352190361340
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70174020794620 !ruby/object:Gem::Requirement
38
+ requirement: &70352190360860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70174020794620
46
+ version_requirements: *70352190360860
47
47
  description: Streak is a gem for calculating win/loss streaks
48
48
  email:
49
49
  - me@davidczarnecki.com
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  segments:
83
83
  - 0
84
- hash: -3807550842657624022
84
+ hash: 4141444244431860570
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: -3807550842657624022
93
+ hash: 4141444244431860570
94
94
  requirements: []
95
95
  rubyforge_project:
96
96
  rubygems_version: 1.8.10