merit 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/UPGRADING.md +2 -1
- data/lib/generators/merit/templates/merit_badge_rules.rb +2 -0
- data/lib/generators/merit/templates/merit_point_rules.rb +2 -0
- data/lib/generators/merit/templates/merit_rank_rules.rb +2 -0
- data/lib/merit/rules_badge.rb +1 -1
- data/lib/merit/rules_points.rb +1 -1
- data/lib/merit/rules_rank.rb +1 -1
- data/merit.gemspec +1 -1
- data/test/dummy/app/models/merit/badge_rules.rb +3 -1
- data/test/dummy/app/models/merit/point_rules.rb +2 -0
- data/test/dummy/app/models/merit/rank_rules.rb +2 -0
- data/test/dummy/config/initializers/merit.rb +27 -1
- metadata +12 -13
- data/test/dummy/config/initializers/badges_data.rb +0 -40
data/UPGRADING.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Upgrading
|
2
2
|
|
3
|
-
## to 0.6.
|
3
|
+
## to 0.6.1
|
4
4
|
|
5
5
|
<tt>MeritBadgeRules</tt>, <tt>MeritPointRules</tt> and <tt>MeritRankRules</tt>
|
6
6
|
are now namespaced into Merit module. Move and change:
|
@@ -13,6 +13,7 @@ app/models/merit_{badge|point|rank}_rules.rb -> app/models/merit/{badge|point|ra
|
|
13
13
|
- include Merit::{Badge|Point|Rank}Rules
|
14
14
|
+module Merit
|
15
15
|
+ class {Badge|Point|Rank}Rules
|
16
|
+
+ include Merit::{Badge|Point|Rank}RulesMethods
|
16
17
|
</pre>
|
17
18
|
|
18
19
|
## to 0.5.0
|
data/lib/merit/rules_badge.rb
CHANGED
@@ -29,7 +29,7 @@ module Merit
|
|
29
29
|
#
|
30
30
|
# Luego chequea las condiciones sincronizadamente, o mediante un proceso en
|
31
31
|
# background, por ejemplo cada 5 minutos (Merit::BadgeRules#check_new_actions).
|
32
|
-
|
32
|
+
module BadgeRulesMethods
|
33
33
|
# Define rule for granting badges
|
34
34
|
def grant_on(action, *args, &block)
|
35
35
|
options = args.extract_options!
|
data/lib/merit/rules_points.rb
CHANGED
@@ -2,7 +2,7 @@ module Merit
|
|
2
2
|
# Points are a simple integer value which are given to "meritable" resources
|
3
3
|
# according to rules in +app/models/merit_point_rules.rb+. They are given on
|
4
4
|
# actions-triggered.
|
5
|
-
|
5
|
+
module PointRulesMethods
|
6
6
|
# Define rules on certaing actions for giving points
|
7
7
|
def score(points, *args, &block)
|
8
8
|
options = args.extract_options!
|
data/lib/merit/rules_rank.rb
CHANGED
@@ -8,7 +8,7 @@ module Merit
|
|
8
8
|
# * :+to+ model or scope to check if new rankings apply
|
9
9
|
# * :+level_name+ attribute name (default is empty and results in 'level'
|
10
10
|
# attribute, if set it's appended like 'level_#{level_name}')
|
11
|
-
|
11
|
+
module RankRulesMethods
|
12
12
|
# Populates +defined_rules+ hash with following hierarchy:
|
13
13
|
# defined_rules[ModelToRank] = { levels => blocks }
|
14
14
|
def set_rank(*args, &block)
|
data/merit.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.description = "Manage badges, points and rankings (reputation) of resources in a Rails application."
|
5
5
|
s.homepage = "http://github.com/tute/merit"
|
6
6
|
s.files = `git ls-files`.split("\n").reject{|f| f =~ /^\./ }
|
7
|
-
s.version = "0.6.
|
7
|
+
s.version = "0.6.1"
|
8
8
|
s.authors = ["Tute Costa"]
|
9
9
|
s.email = 'tutecosta@gmail.com'
|
10
10
|
s.add_dependency 'ambry'
|
@@ -16,6 +16,8 @@
|
|
16
16
|
|
17
17
|
module Merit
|
18
18
|
class BadgeRules
|
19
|
+
include Merit::BadgeRulesMethods
|
20
|
+
|
19
21
|
def initialize
|
20
22
|
# If it creates user, grant badge
|
21
23
|
# Should be "current_user" after registration for badge to be granted.
|
@@ -23,7 +25,7 @@ module Merit
|
|
23
25
|
|
24
26
|
# If it has 10 comments, grant commenter-10 badge
|
25
27
|
grant_on 'comments#create', :badge => 'commenter', :level => 10 do |comment|
|
26
|
-
comment.user.comments.count
|
28
|
+
comment.user.comments.count >= 10
|
27
29
|
end
|
28
30
|
|
29
31
|
# If it has at least 10 votes, grant relevant-commenter badge
|
@@ -5,4 +5,30 @@ Merit.setup do |config|
|
|
5
5
|
|
6
6
|
# Define ORM. Could be :active_record (default) and :mongo_mapper
|
7
7
|
# config.orm = :active_record
|
8
|
-
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Create application badges (uses https://github.com/norman/ambry)
|
11
|
+
badge_id = 0
|
12
|
+
[{
|
13
|
+
:id => (badge_id = badge_id+1),
|
14
|
+
:name => 'commenter',
|
15
|
+
:description => 'You\'ve participated good in our boards!',
|
16
|
+
:level => 10
|
17
|
+
}, {
|
18
|
+
:id => (badge_id = badge_id+1),
|
19
|
+
:name => 'commenter',
|
20
|
+
:description => 'You\'ve participated great in our boards!'
|
21
|
+
}, {
|
22
|
+
:id => (badge_id = badge_id+1),
|
23
|
+
:name => 'relevant-commenter',
|
24
|
+
:description => 'You\'ve received 5 votes on a comment.'
|
25
|
+
}, {
|
26
|
+
:id => (badge_id = badge_id+1),
|
27
|
+
:name => 'autobiographer',
|
28
|
+
:description => 'You\'ve edited your name and it\'s above 4 characters! (?)'
|
29
|
+
}, {
|
30
|
+
:id => (badge_id = badge_id+1),
|
31
|
+
:name => 'just-registered'
|
32
|
+
}].each do |badge|
|
33
|
+
Badge.create! badge
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
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-
|
12
|
+
date: 2012-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ambry
|
16
|
-
requirement: &
|
16
|
+
requirement: &70267830450700 !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: *
|
24
|
+
version_requirements: *70267830450700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &70267830447420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.10
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70267830447420
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3
|
38
|
-
requirement: &
|
38
|
+
requirement: &70267830445160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70267830445160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: haml
|
49
|
-
requirement: &
|
49
|
+
requirement: &70267830443020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70267830443020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: capybara
|
60
|
-
requirement: &
|
60
|
+
requirement: &70267830442080 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70267830442080
|
69
69
|
description: Manage badges, points and rankings (reputation) of resources in a Rails
|
70
70
|
application.
|
71
71
|
email: tutecosta@gmail.com
|
@@ -136,7 +136,6 @@ files:
|
|
136
136
|
- test/dummy/config/environments/production.rb
|
137
137
|
- test/dummy/config/environments/test.rb
|
138
138
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
139
|
-
- test/dummy/config/initializers/badges_data.rb
|
140
139
|
- test/dummy/config/initializers/inflections.rb
|
141
140
|
- test/dummy/config/initializers/merit.rb
|
142
141
|
- test/dummy/config/initializers/mime_types.rb
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# Create badges (Ambry)
|
2
|
-
badge_id = 0
|
3
|
-
|
4
|
-
# Rank badges (5 stars)
|
5
|
-
(1..5).each do |i|
|
6
|
-
Badge.create!(
|
7
|
-
:id => (badge_id = badge_id+1),
|
8
|
-
:name => 'stars',
|
9
|
-
:level => i
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Normal badges
|
14
|
-
[
|
15
|
-
{
|
16
|
-
:id => (badge_id = badge_id+1),
|
17
|
-
:name => 'commenter',
|
18
|
-
:description => 'You\'ve participated good in our boards!',
|
19
|
-
:level => 10
|
20
|
-
}, {
|
21
|
-
:id => (badge_id = badge_id+1),
|
22
|
-
:name => 'commenter',
|
23
|
-
:description => 'You\'ve participated great in our boards!',
|
24
|
-
:level => 20
|
25
|
-
}, {
|
26
|
-
:id => (badge_id = badge_id+1),
|
27
|
-
:name => 'relevant-commenter',
|
28
|
-
:description => 'You\'ve received 5 votes on a comment.',
|
29
|
-
:level => 5
|
30
|
-
}, {
|
31
|
-
:id => (badge_id = badge_id+1),
|
32
|
-
:name => 'autobiographer',
|
33
|
-
:description => 'You\'ve edited your name and it\'s above 4 characters! (?)'
|
34
|
-
}, {
|
35
|
-
:id => (badge_id = badge_id+1),
|
36
|
-
:name => 'just-registered'
|
37
|
-
}
|
38
|
-
].each do |badge|
|
39
|
-
Badge.create! badge
|
40
|
-
end
|