Skip to content

Commit

Permalink
README update, explaining new rankings. Releases v0.4.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
tute committed Apr 10, 2012
1 parent 4f95248 commit e0934e0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
23 changes: 13 additions & 10 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,18 @@ method(s) defined in the <tt>:to</tt> option. Define rules on

# Defining rank rules

Rankings are very similar to badges. They give "badges" which have a hierarchy
defined by <tt>level</tt>'s lexicografical order (greater is better). If a
rank is granted, lower level ranks are taken off. 5 stars is a common ranking
use case.

They are not given at specified actions like badges, you should define a cron
job to test if ranks are to be granted.
5 stars is a common ranking use case. They are not given at specified actions
like badges, you should define a cron job to test if ranks are to be granted.

Define rules on <tt>app/models/merit_rank_rules.rb</tt>:

<tt>set_rank</tt> accepts:

* <tt>badge_name</tt> name of this ranking
* <tt>:level</tt> ranking level (greater is better)
* <tt>:to</tt> model or scope to check if new rankings apply
* <tt>:level_name</tt> attribute name (default is empty and results in
'<tt>level</tt>' attribute, if set it's appended like
'<tt>level_#{level_name}</tt>')

Check for rules on a rake task executed in background like:

Expand All @@ -99,11 +96,11 @@ Check for rules on a rake task executed in background like:

## Examples

set_rank :stars, :level => 2, :to => Commiter.active do |commiter|
set_rank :level => 2, :to => Commiter.active do |commiter|
commiter.branches > 1 && commiter.followers >= 10
end

set_rank :stars, :level => 3, :to => Commiter.active do |commiter|
set_rank :level => 3, :to => Commiter.active do |commiter|
commiter.branches > 2 && commiter.followers >= 20
end

Expand All @@ -128,6 +125,12 @@ installation, and configuring <tt>config.orm = :mongo_mapper</tt> in

# Notes on upgrades

## to 0.4.0

Rankings are now integer attributes on "meritable" models ("<tt>level</tt>"),
they are not badges anymore. <tt>set_rank</tt> now doesn't accept
<tt>badge_name</tt>.

## to 0.3.0

Badges data is now stored in <tt>config/initializers/merit.rb</tt> using
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/merit/templates/merit_rank_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# +set_rank+ accepts:
# * :+level+ ranking level (greater is better)
# * :+to+ model or scope to check if new rankings apply
# * :+level_name+ attribute name (default is empty and results in 'level'
# attribute, if set it's appended like 'level_#{level_name}')

class MeritRankRules
include Merit::RankRules
Expand Down
2 changes: 2 additions & 0 deletions lib/merit/rules_rank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Merit
# +set_rank+ accepts:
# * :+level+ ranking level (greater is better)
# * :+to+ model or scope to check if new rankings apply
# * :+level_name+ attribute name (default is empty and results in 'level'
# attribute, if set it's appended like 'level_#{level_name}')
module RankRules
# Populates +defined_rules+ hash with following hierarchy:
# defined_rules[ModelToRank] = { levels => blocks }
Expand Down
2 changes: 1 addition & 1 deletion merit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Gem::Specification.new do |s|
s.summary = "General reputation Rails engine."
s.description = "General reputation Rails engine."
s.files = `git ls-files`.split("\n").reject{|f| f =~ /^\./ }
s.version = "0.3.3"
s.version = "0.4.0"
s.authors = ["Tute Costa"]
s.email = 'tutecosta@gmail.com'
s.add_dependency 'ambry'
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/models/merit_rank_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# +set_rank+ accepts:
# * :+level+ ranking level (greater is better)
# * :+to+ model or scope to check if new rankings apply
# * :+level_name+ attribute name (default is empty and results in 'level'
# attribute, if set it's appended like 'level_#{level_name}')

class MeritRankRules
include Merit::RankRules
Expand Down

0 comments on commit e0934e0

Please sign in to comment.