leaderboard 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.3.0 (2013-07-17)
4
+
5
+ * Added `rank_member_across` method to be able to rank a member across multiple leaderboards at once.
6
+
3
7
  ## 3.2.0 (2013-05-31)
4
8
 
5
9
  * Added `remove_members_outside_rank` method to remove members from the leaderboard outside a given rank.
data/README.markdown CHANGED
@@ -294,6 +294,12 @@ highscore_lb.rank_members(['member_1', 1, 'member_5', 5, 'member_10', 10])
294
294
 
295
295
  Use this method to do bulk insert of data, but be mindful of the amount of data you are inserting since a single transaction can get quite large.
296
296
 
297
+ ### Ranking a member across multiple leaderboards
298
+
299
+ ```ruby
300
+ highscore_lb.rank_member_across(['highscores', 'more_highscores'], 'david', 50000, { :member_name => "david" })
301
+ ```
302
+
297
303
  ### Other useful methods
298
304
 
299
305
  ```
data/leaderboard.gemspec CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "https://github.com/agoragames/leaderboard"
12
12
  s.summary = %q{Leaderboards backed by Redis in Ruby}
13
13
  s.description = %q{Leaderboards backed by Redis in Ruby}
14
+ s.license = 'MIT'
14
15
 
15
16
  s.rubyforge_project = "leaderboard"
16
17
 
data/lib/leaderboard.rb CHANGED
@@ -129,6 +129,21 @@ class Leaderboard
129
129
  end
130
130
  end
131
131
 
132
+ # Rank a member across multiple leaderboards.
133
+ #
134
+ # @param leaderboards [Array] Leaderboard names.
135
+ # @param member [String] Member name.
136
+ # @param score [float] Member score.
137
+ # @param member_data [String] Optional member data.
138
+ def rank_member_across(leaderboards, member, score, member_data = nil)
139
+ @redis_connection.multi do |transaction|
140
+ leaderboards.each do |leaderboard_name|
141
+ transaction.zadd(leaderboard_name, score, member)
142
+ transaction.hset(member_data_key(leaderboard_name), member, member_data) if member_data
143
+ end
144
+ end
145
+ end
146
+
132
147
  # Rank a member in the leaderboard based on execution of the +rank_conditional+.
133
148
  #
134
149
  # The +rank_conditional+ is passed the following parameters:
@@ -1,3 +1,3 @@
1
1
  class Leaderboard
2
- VERSION = '3.2.0'.freeze
2
+ VERSION = '3.3.0'.freeze
3
3
  end
@@ -719,4 +719,10 @@ describe 'Leaderboard' do
719
719
  leaders.size.should == 2
720
720
  leaders.collect { |leader| leader.keys.should == [:member] }
721
721
  end
722
+
723
+ it 'should allow you to rank a member across multiple leaderboards' do
724
+ @leaderboard.rank_member_across(['highscores', 'more_highscores'], 'david', 50000, { :member_name => "david" })
725
+ @leaderboard.leaders_in('highscores', 1).size.should eql(1)
726
+ @leaderboard.leaders_in('more_highscores', 1).size.should eql(1)
727
+ end
722
728
  end
data/spec/version_spec.rb CHANGED
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Leaderboard::VERSION' do
4
4
  it 'should be the correct version' do
5
- Leaderboard::VERSION.should == '3.2.0'
5
+ Leaderboard::VERSION.should == '3.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leaderboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-31 00:00:00.000000000 Z
12
+ date: 2013-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
@@ -84,7 +84,8 @@ files:
84
84
  - spec/spec_helper.rb
85
85
  - spec/version_spec.rb
86
86
  homepage: https://github.com/agoragames/leaderboard
87
- licenses: []
87
+ licenses:
88
+ - MIT
88
89
  post_install_message:
89
90
  rdoc_options: []
90
91
  require_paths:
@@ -97,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
98
  version: '0'
98
99
  segments:
99
100
  - 0
100
- hash: -3549560815015692578
101
+ hash: 1089001734082897595
101
102
  required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  none: false
103
104
  requirements:
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  version: '0'
107
108
  segments:
108
109
  - 0
109
- hash: -3549560815015692578
110
+ hash: 1089001734082897595
110
111
  requirements: []
111
112
  rubyforge_project: leaderboard
112
113
  rubygems_version: 1.8.25