merit 3.0.3 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -9
  3. data/NEWS.md +25 -0
  4. data/README.md +29 -10
  5. data/app/models/merit/badge.rb +1 -9
  6. data/lib/merit/{rules_badge_methods.rb → badge_rules_methods.rb} +0 -0
  7. data/lib/merit/base_target_finder.rb +1 -6
  8. data/lib/merit/{model_additions.rb → class_methods.rb} +0 -11
  9. data/lib/merit/controller_extensions.rb +4 -22
  10. data/lib/{generators → merit/generators}/active_record/install_generator.rb +8 -8
  11. data/lib/{generators → merit/generators}/active_record/merit_generator.rb +4 -4
  12. data/lib/{generators → merit/generators}/active_record/remove_generator.rb +5 -5
  13. data/lib/{generators/active_record/templates/add_merit_fields_to_model.rb → merit/generators/active_record/templates/add_merit_fields_to_model.erb} +0 -0
  14. data/lib/{generators/active_record/templates/create_badges_sashes.rb → merit/generators/active_record/templates/create_badges_sashes.erb} +0 -0
  15. data/lib/{generators/active_record/templates/create_merit_actions.rb → merit/generators/active_record/templates/create_merit_actions.erb} +2 -0
  16. data/lib/{generators/active_record/templates/create_merit_activity_logs.rb → merit/generators/active_record/templates/create_merit_activity_logs.erb} +0 -0
  17. data/lib/{generators/active_record/templates/create_sashes.rb → merit/generators/active_record/templates/create_sashes.erb} +0 -0
  18. data/lib/{generators/active_record/templates/create_scores_and_points.rb → merit/generators/active_record/templates/create_scores_and_points.erb} +1 -1
  19. data/lib/{generators/active_record/templates/remove_merit_fields_from_model.rb → merit/generators/active_record/templates/remove_merit_fields_from_model.erb} +0 -0
  20. data/lib/{generators/active_record/templates/remove_merit_tables.rb → merit/generators/active_record/templates/remove_merit_tables.erb} +0 -0
  21. data/lib/merit/generators/install_generator.rb +21 -0
  22. data/lib/{generators/merit → merit/generators}/merit_generator.rb +7 -2
  23. data/lib/{generators/merit → merit/generators}/remove_generator.rb +7 -2
  24. data/lib/{generators/merit/templates/merit.rb → merit/generators/templates/merit.erb} +13 -14
  25. data/lib/{generators/merit/templates/merit_badge_rules.rb → merit/generators/templates/merit_badge_rules.erb} +0 -0
  26. data/lib/{generators/merit/templates/merit_point_rules.rb → merit/generators/templates/merit_point_rules.erb} +0 -0
  27. data/lib/{generators/merit/templates/merit_rank_rules.rb → merit/generators/templates/merit_rank_rules.erb} +0 -0
  28. data/lib/merit/judge.rb +6 -5
  29. data/{app/models/merit/action.rb → lib/merit/models/action_concern.rb} +12 -10
  30. data/lib/merit/models/active_record/{merit/action.rb → action.rb} +5 -1
  31. data/lib/merit/models/active_record/{merit/activity_log.rb → activity_log.rb} +3 -1
  32. data/lib/merit/models/active_record/{merit/badges_sash.rb → badges_sash.rb} +4 -2
  33. data/lib/merit/models/active_record/{merit/sash.rb → sash.rb} +5 -2
  34. data/lib/merit/models/active_record/{merit/score.rb → score.rb} +4 -1
  35. data/lib/merit/models/badges_sash_concern.rb +13 -0
  36. data/lib/merit/models/base/badges_sash.rb +1 -1
  37. data/lib/merit/models/base/sash.rb +1 -1
  38. data/lib/merit/models/sash_concern.rb +53 -0
  39. data/lib/merit/{rules_points_methods.rb → point_rules_methods.rb} +0 -0
  40. data/lib/merit/{rules_rank_methods.rb → rank_rules_methods.rb} +3 -18
  41. data/lib/merit.rb +29 -56
  42. data/merit.gemspec +5 -2
  43. data/test/dummy/app/models/address.rb +1 -12
  44. data/test/dummy/app/models/comment.rb +3 -21
  45. data/test/dummy/app/models/user.rb +1 -14
  46. data/test/dummy/config/application.rb +5 -1
  47. data/test/dummy/config/application_api_only.rb +1 -1
  48. data/test/dummy/db/migrate/20130329224406_create_merit_actions.rb +2 -0
  49. data/test/dummy/db/schema.rb +4 -8
  50. data/test/integration/navigation_test.rb +3 -3
  51. data/test/test_helper.rb +0 -2
  52. data/test/unit/base_target_finder_test.rb +7 -26
  53. data/test/unit/merit_unit_test.rb +6 -8
  54. data/test/unit/rule_unit_test.rb +8 -8
  55. data/test/unit/rules_matcher_test.rb +9 -6
  56. data/test/unit/sash_finder_test.rb +5 -5
  57. data/test/unit/sash_test.rb +16 -0
  58. data/test/unit/score_test.rb +1 -1
  59. data/test/unit/target_finder_test.rb +13 -13
  60. metadata +64 -62
  61. data/UPGRADING.md +0 -256
  62. data/lib/generators/active_record/templates/add_target_data_to_merit_actions.rb +0 -5
  63. data/lib/generators/active_record/upgrade_generator.rb +0 -40
  64. data/lib/generators/merit/install_generator.rb +0 -16
  65. data/lib/generators/merit/upgrade_generator.rb +0 -7
  66. data/lib/merit/models/mongoid/merit/action.rb +0 -18
  67. data/lib/merit/models/mongoid/merit/activity_log.rb +0 -11
  68. data/lib/merit/models/mongoid/merit/badges_sash.rb +0 -20
  69. data/lib/merit/models/mongoid/merit/sash.rb +0 -30
  70. data/lib/merit/models/mongoid/merit/score.rb +0 -45
  71. data/test/dummy/db/migrate/20140906225844_create_players.rb +0 -8
  72. data/test/dummy/public/javascripts/application.js +0 -2
  73. data/test/dummy/public/javascripts/controls.js +0 -965
  74. data/test/dummy/public/javascripts/dragdrop.js +0 -974
  75. data/test/dummy/public/javascripts/effects.js +0 -1123
  76. data/test/dummy/public/javascripts/prototype.js +0 -6001
  77. data/test/dummy/public/javascripts/rails.js +0 -191
  78. data/test/orm_models/active_record.rb +0 -11
  79. data/test/orm_models/mongoid.rb +0 -15
@@ -17,14 +17,14 @@ describe Merit::TargetFinder do
17
17
 
18
18
  finder = Merit::TargetFinder.new(rule, action)
19
19
  collection = finder.find
20
- collection.size.must_be :==, 1
21
- collection.must_include comment
20
+ _(collection.size).must_be :==, 1
21
+ _(collection).must_include comment
22
22
  end
23
23
  end
24
24
 
25
25
  describe 'rule#to is :action_user' do
26
26
  before do
27
- Merit.setup { |config| config.user_model_name = 'Player' }
27
+ Merit.setup { |config| config.user_model_name = 'User' }
28
28
  end
29
29
  after do
30
30
  Merit.setup { |config| config.user_model_name = 'User' }
@@ -34,14 +34,14 @@ describe Merit::TargetFinder do
34
34
  rule = Merit::Rule.new
35
35
  rule.to = :action_user
36
36
  action = Merit::Action.new(user_id: 22)
37
- user = Player.new
37
+ user = User.new
38
38
 
39
- Player.stubs(:find_by_id).with(22).returns(user)
39
+ User.stubs(:find_by_id).with(22).returns(user)
40
40
 
41
41
  finder = Merit::TargetFinder.new(rule, action)
42
42
  collection = finder.find
43
- collection.size.must_be :==, 1
44
- collection.must_include user
43
+ _(collection.size).must_be :==, 1
44
+ _(collection).must_include user
45
45
  end
46
46
 
47
47
  describe 'when user does not exist' do
@@ -50,9 +50,9 @@ describe Merit::TargetFinder do
50
50
  rule.to = :action_user
51
51
  action = Merit::Action.new(user_id: 22)
52
52
 
53
- Rails.logger.expects(:warn).with('[merit] no Player found with id 22')
53
+ Rails.logger.expects(:warn).with('[merit] no User found with id 22')
54
54
  finder = Merit::TargetFinder.new(rule, action)
55
- finder.find.must_be_empty
55
+ _(finder.find).must_be_empty
56
56
  end
57
57
  end
58
58
  end
@@ -64,15 +64,15 @@ describe Merit::TargetFinder do
64
64
  rule.model_name = 'comments'
65
65
  action = Merit::Action.new(target_id: 40)
66
66
 
67
- user = Player.new
67
+ user = User.new
68
68
  comment = Comment.new
69
69
  comment.stubs(:user).returns(user)
70
70
  Comment.stubs(:find_by_id).with(40).returns(comment)
71
71
 
72
72
  finder = Merit::TargetFinder.new(rule, action)
73
73
  collection = finder.find
74
- collection.size.must_be :==, 1
75
- collection.must_include user
74
+ _(collection.size).must_be :==, 1
75
+ _(collection).must_include user
76
76
  end
77
77
 
78
78
  describe 'rule#to does not exist as a method on the original target' do
@@ -90,7 +90,7 @@ describe Merit::TargetFinder do
90
90
 
91
91
  Rails.logger.expects(:warn).with(str)
92
92
  finder = Merit::TargetFinder.new(rule, action)
93
- finder.find.must_be_empty
93
+ _(finder.find).must_be_empty
94
94
  end
95
95
  end
96
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tute Costa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2022-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ambry
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: zeitwerk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rails
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webrick
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  description: Manage badges, points and rankings (reputation) in your Rails app.
112
140
  email: tutecosta@gmail.com
113
141
  executables: []
@@ -122,54 +150,47 @@ files:
122
150
  - RELEASING.md
123
151
  - Rakefile
124
152
  - TESTING.txt
125
- - UPGRADING.md
126
- - app/models/merit/action.rb
127
153
  - app/models/merit/badge.rb
128
154
  - config/locales/en.yml
129
- - lib/generators/active_record/install_generator.rb
130
- - lib/generators/active_record/merit_generator.rb
131
- - lib/generators/active_record/remove_generator.rb
132
- - lib/generators/active_record/templates/add_merit_fields_to_model.rb
133
- - lib/generators/active_record/templates/add_target_data_to_merit_actions.rb
134
- - lib/generators/active_record/templates/create_badges_sashes.rb
135
- - lib/generators/active_record/templates/create_merit_actions.rb
136
- - lib/generators/active_record/templates/create_merit_activity_logs.rb
137
- - lib/generators/active_record/templates/create_sashes.rb
138
- - lib/generators/active_record/templates/create_scores_and_points.rb
139
- - lib/generators/active_record/templates/remove_merit_fields_from_model.rb
140
- - lib/generators/active_record/templates/remove_merit_tables.rb
141
- - lib/generators/active_record/upgrade_generator.rb
142
- - lib/generators/merit/install_generator.rb
143
- - lib/generators/merit/merit_generator.rb
144
- - lib/generators/merit/remove_generator.rb
145
- - lib/generators/merit/templates/merit.rb
146
- - lib/generators/merit/templates/merit_badge_rules.rb
147
- - lib/generators/merit/templates/merit_point_rules.rb
148
- - lib/generators/merit/templates/merit_rank_rules.rb
149
- - lib/generators/merit/upgrade_generator.rb
150
155
  - lib/merit.rb
156
+ - lib/merit/badge_rules_methods.rb
151
157
  - lib/merit/base_target_finder.rb
158
+ - lib/merit/class_methods.rb
152
159
  - lib/merit/controller_extensions.rb
160
+ - lib/merit/generators/active_record/install_generator.rb
161
+ - lib/merit/generators/active_record/merit_generator.rb
162
+ - lib/merit/generators/active_record/remove_generator.rb
163
+ - lib/merit/generators/active_record/templates/add_merit_fields_to_model.erb
164
+ - lib/merit/generators/active_record/templates/create_badges_sashes.erb
165
+ - lib/merit/generators/active_record/templates/create_merit_actions.erb
166
+ - lib/merit/generators/active_record/templates/create_merit_activity_logs.erb
167
+ - lib/merit/generators/active_record/templates/create_sashes.erb
168
+ - lib/merit/generators/active_record/templates/create_scores_and_points.erb
169
+ - lib/merit/generators/active_record/templates/remove_merit_fields_from_model.erb
170
+ - lib/merit/generators/active_record/templates/remove_merit_tables.erb
171
+ - lib/merit/generators/install_generator.rb
172
+ - lib/merit/generators/merit_generator.rb
173
+ - lib/merit/generators/remove_generator.rb
174
+ - lib/merit/generators/templates/merit.erb
175
+ - lib/merit/generators/templates/merit_badge_rules.erb
176
+ - lib/merit/generators/templates/merit_point_rules.erb
177
+ - lib/merit/generators/templates/merit_rank_rules.erb
153
178
  - lib/merit/judge.rb
154
- - lib/merit/model_additions.rb
155
- - lib/merit/models/active_record/merit/action.rb
156
- - lib/merit/models/active_record/merit/activity_log.rb
157
- - lib/merit/models/active_record/merit/badges_sash.rb
158
- - lib/merit/models/active_record/merit/sash.rb
159
- - lib/merit/models/active_record/merit/score.rb
179
+ - lib/merit/models/action_concern.rb
180
+ - lib/merit/models/active_record/action.rb
181
+ - lib/merit/models/active_record/activity_log.rb
182
+ - lib/merit/models/active_record/badges_sash.rb
183
+ - lib/merit/models/active_record/sash.rb
184
+ - lib/merit/models/active_record/score.rb
185
+ - lib/merit/models/badges_sash_concern.rb
160
186
  - lib/merit/models/base/badges_sash.rb
161
187
  - lib/merit/models/base/sash.rb
162
- - lib/merit/models/mongoid/merit/action.rb
163
- - lib/merit/models/mongoid/merit/activity_log.rb
164
- - lib/merit/models/mongoid/merit/badges_sash.rb
165
- - lib/merit/models/mongoid/merit/sash.rb
166
- - lib/merit/models/mongoid/merit/score.rb
188
+ - lib/merit/models/sash_concern.rb
189
+ - lib/merit/point_rules_methods.rb
190
+ - lib/merit/rank_rules_methods.rb
167
191
  - lib/merit/reputation_change_observer.rb
168
192
  - lib/merit/rule.rb
169
- - lib/merit/rules_badge_methods.rb
170
193
  - lib/merit/rules_matcher.rb
171
- - lib/merit/rules_points_methods.rb
172
- - lib/merit/rules_rank_methods.rb
173
194
  - lib/merit/sash_finder.rb
174
195
  - lib/merit/target_finder.rb
175
196
  - merit.gemspec
@@ -232,26 +253,17 @@ files:
232
253
  - test/dummy/db/migrate/20130329224410_create_scores_and_points.rb
233
254
  - test/dummy/db/migrate/20140211144001_create_addresses.rb
234
255
  - test/dummy/db/migrate/20140819133931_add_target_data_to_merit_actions.rb
235
- - test/dummy/db/migrate/20140906225844_create_players.rb
236
256
  - test/dummy/db/schema.rb
237
257
  - test/dummy/db/seeds.rb
238
258
  - test/dummy/public/404.html
239
259
  - test/dummy/public/422.html
240
260
  - test/dummy/public/500.html
241
261
  - test/dummy/public/favicon.ico
242
- - test/dummy/public/javascripts/application.js
243
- - test/dummy/public/javascripts/controls.js
244
- - test/dummy/public/javascripts/dragdrop.js
245
- - test/dummy/public/javascripts/effects.js
246
- - test/dummy/public/javascripts/prototype.js
247
- - test/dummy/public/javascripts/rails.js
248
262
  - test/dummy/public/rails.js
249
263
  - test/dummy/public/stylesheets/.gitkeep
250
264
  - test/dummy/public/stylesheets/scaffold.css
251
265
  - test/dummy/script/rails
252
266
  - test/integration/navigation_test.rb
253
- - test/orm_models/active_record.rb
254
- - test/orm_models/mongoid.rb
255
267
  - test/support/integration_case.rb
256
268
  - test/test_helper.rb
257
269
  - test/unit/action_test.rb
@@ -267,7 +279,7 @@ homepage: https://github.com/merit-gem/merit
267
279
  licenses:
268
280
  - MIT
269
281
  metadata: {}
270
- post_install_message:
282
+ post_install_message:
271
283
  rdoc_options: []
272
284
  require_paths:
273
285
  - lib
@@ -282,9 +294,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
294
  - !ruby/object:Gem::Version
283
295
  version: '0'
284
296
  requirements: []
285
- rubyforge_project:
286
- rubygems_version: 2.7.6.2
287
- signing_key:
297
+ rubygems_version: 3.2.32
298
+ signing_key:
288
299
  specification_version: 4
289
300
  summary: Reputation engine for Rails apps
290
301
  test_files:
@@ -347,26 +358,17 @@ test_files:
347
358
  - test/dummy/db/migrate/20130329224410_create_scores_and_points.rb
348
359
  - test/dummy/db/migrate/20140211144001_create_addresses.rb
349
360
  - test/dummy/db/migrate/20140819133931_add_target_data_to_merit_actions.rb
350
- - test/dummy/db/migrate/20140906225844_create_players.rb
351
361
  - test/dummy/db/schema.rb
352
362
  - test/dummy/db/seeds.rb
353
363
  - test/dummy/public/404.html
354
364
  - test/dummy/public/422.html
355
365
  - test/dummy/public/500.html
356
366
  - test/dummy/public/favicon.ico
357
- - test/dummy/public/javascripts/application.js
358
- - test/dummy/public/javascripts/controls.js
359
- - test/dummy/public/javascripts/dragdrop.js
360
- - test/dummy/public/javascripts/effects.js
361
- - test/dummy/public/javascripts/prototype.js
362
- - test/dummy/public/javascripts/rails.js
363
367
  - test/dummy/public/rails.js
364
368
  - test/dummy/public/stylesheets/.gitkeep
365
369
  - test/dummy/public/stylesheets/scaffold.css
366
370
  - test/dummy/script/rails
367
371
  - test/integration/navigation_test.rb
368
- - test/orm_models/active_record.rb
369
- - test/orm_models/mongoid.rb
370
372
  - test/support/integration_case.rb
371
373
  - test/test_helper.rb
372
374
  - test/unit/action_test.rb
data/UPGRADING.md DELETED
@@ -1,256 +0,0 @@
1
- # Main Changes / Upgrading Notes
2
-
3
- ## 2.1.0
4
-
5
- Adds serialisation of destroyed target models so that reputation can be awarded
6
- when the item is already deleted from the DB. For this to work you need a new
7
- column, to add it you can run:
8
-
9
- ```
10
- rails generate merit:upgrade
11
- rake db:migrate
12
- ```
13
-
14
- This is a backwards compatible addition, so if you don't add the column but
15
- upgrade, your application should continue to work well, without the new feature.
16
-
17
- ## 2.0.0
18
-
19
- * Removes deprecated methods: `Merit::Badge.last_granted` and
20
- `Merit::Score.top_scored`.
21
- * Removes `add_points` `log` parameter.
22
- * Adds points category option.
23
-
24
- ## 1.9.0
25
-
26
- * Deprecates `Merit::Badge.last_granted` and `Merit::Score.top_scored`.
27
- Code can be readded to client applications following instructions in:
28
- https://github.com/tute/merit/wiki/How-to-show-a-points-leaderboard
29
- https://github.com/tute/merit/wiki/How-to-show-last-granted-badges
30
- * Deprecates `add_points` `log` parameter.
31
-
32
- ## 1.8.0
33
-
34
- * Completes implementation of observer patter for getting reputation grant
35
- notifications to the client app. See: https://github.com/tute/merit#getting-
36
- notifications.
37
- * Work on mongoid adapter (not yet ready), and other internals polishing.
38
-
39
- ## 1.7.0
40
-
41
- * Adds support for dynamic scoring
42
- * `substract_points` is deprecated in favor of `subtract_points`. Careless
43
- computers didn't mind my misspellings. ;-)
44
- * JRuby and Rubinius compatibility
45
-
46
- ## 1.6.0
47
-
48
- * Rails 4 ready.
49
- * Adds ability to wildcard controllers like:
50
- ```ruby
51
- grant_on '.*search#index', badge: 'searcher', multiple: true
52
- ```
53
- * Allows custom fields to be defined on badges [97c998f]. Example:
54
- Merit::Badge.create!({
55
- id: 1,
56
- name: 'best-unicorn',
57
- custom_fields: { category: 'fantasy' }
58
- })
59
-
60
- ## 1.5.0
61
-
62
- * Adds `Merit::ActivityLog` join model between `Merit::Action` and
63
- `Merit::BadgesSash` and `Merit::Score::Point` for logging purposes. Every
64
- time a badge is granted or removed, or points are changed, a new
65
- `ActivityLog` object gets created.
66
- * Namespaces `Badge`, `Sash` and `BadgesSash` into `Merit` module. If your app
67
- uses any of those class names, you should add a `Merit::` prefix.
68
- * Removes undocumented `log:string` column from `merit_actions`.
69
-
70
- Run the following migration to upgrade from 1.4.0:
71
-
72
- ```ruby
73
- class UpgradeMeritTo150 < ActiveRecord::Migration
74
- def self.up
75
- remove_column :merit_actions, :log
76
- create_table "merit_activity_logs", :force => true do |t|
77
- t.integer "action_id"
78
- t.string "related_change_type"
79
- t.integer "related_change_id"
80
- t.string "description"
81
- t.datetime "created_at"
82
- end
83
- end
84
- end
85
- ```
86
-
87
- ## 1.4.0
88
-
89
- * Removed `BadgesSash#set_notified!` undocumented method from code base.
90
- * `:to` option for points and badges granting may now return an array of
91
- objects. For instance:
92
-
93
- ```ruby
94
- # All user's comments earn points
95
- score 2, to: :user_comments, on: 'comments#vote'
96
- ```
97
-
98
- ## to 1.3.0
99
-
100
- Adds two methods meant to display a leaderboard.
101
-
102
- * `Badge.last_granted(options = {})`. Accepts options:
103
- * `:since_date` (`1.month.ago` by default)
104
- * `:limit` (10 by default).
105
-
106
- It lists last 10 badge grants in the last month, unless you change query
107
- parameters.
108
-
109
- * `Merit::Score.top_scored(options = {})`. Accepts options:
110
- * `:table_name` (`users` by default)
111
- * `:since_date` (`1.month.ago` by default)
112
- * `:limit` (10 by default).
113
-
114
- It lists top 10 scored objects in the last month, unless you change query
115
- parameters.
116
-
117
- ## to 1.2.0
118
-
119
- * `Badge#grant_to(meritable_object)` no longer exists. Use
120
- `meritable_object.add_badge(badge_id)` (may add badges more than once).
121
- * `Badge#delete_from(meritable_object)` no longer exists. Use
122
- `meritable_object.rm_badge(badge_id)`.
123
-
124
- ## to 1.1.0
125
-
126
- Code refactorings. Support for Ruby 1.8.7 has been dropped.
127
-
128
- ## to 1.0.1
129
-
130
- Adds `Merit::Point#created_at` (`merit_score_points` table) attribute.
131
- May already be added if upgrading from merit < 1).
132
-
133
- ## to 1.0.0
134
-
135
- Points granting history is now logged.
136
-
137
- * Attribute `points` and method `points=` don't exist anymore (method `points`
138
- still works for querying number of points for a resource).
139
- * There are new methods `add_points(num_points, log_message)` and
140
- `remove_points(num_points, log_message)` in meritable resources to manually
141
- change their amount of points, keeping a history log.
142
-
143
- Run the following migration to have the new DB tables:
144
-
145
- class UpgradeMerit < ActiveRecord::Migration
146
- def self.up
147
- create_table :merit_scores do |t|
148
- t.references :sash
149
- t.string :category, :default => 'default'
150
- end
151
-
152
- create_table :merit_score_points do |t|
153
- t.references :score
154
- t.integer :num_points, :default => 0
155
- t.string :log
156
- t.datetime :created_at
157
- end
158
- end
159
-
160
- def self.down
161
- drop_table :merit_scores
162
- drop_table :merit_score_points
163
- end
164
- end
165
-
166
- # This will create a single point entry log, with previous points granted
167
- # to each meritable resource. Code example for a User class.
168
-
169
- class UpgradeMeritableResources < ActiveRecord::Migration
170
- def up
171
- User.find_each do |user|
172
- unless user.sash
173
- user.sash = Sash.create!
174
- user.save
175
- end
176
-
177
- user.sash.scores << Merit::Score.create
178
- user.add_points(user.read_attribute(:points), 'Initial merit points import.')
179
- end
180
- remove_column :users, :points
181
- end
182
- end
183
-
184
- If you get an `ActiveRecord::DangerousAttributeError: points` exception, you
185
- may need to temporarily tweak your meritable model, as explained in
186
- http://stackoverflow.com/a/1515571/356060.
187
-
188
-
189
- ## to 0.10.0
190
-
191
- `badges_sashes` table gets a primary key `id` column. Run the following migration:
192
-
193
- class AddIdToBadgesSashes < ActiveRecord::Migration
194
- def self.up
195
- add_column :badges_sashes, :id, :primary_key
196
- end
197
-
198
- def self.down
199
- remove_column :badges_sashes, :id
200
- end
201
- end
202
-
203
- `set_notified!(badge = nil, sash = nil)` no longer exists, just call `set_notified!`
204
- over the `badge_sash` object, with no parameters.
205
-
206
- ## to 0.9.0
207
-
208
- Adds `allow_multiple` boolean option to `Badge#grant_to` (defaults to
209
- `false`). If you used this method to grant a badge it will now grant only if
210
- resource doesn't have the badge.
211
-
212
- Use `badge.grant_to resource, :allow_multiple => true` where needed.
213
-
214
- ## to 0.8.0
215
-
216
- No changes needed. Adds Mongoid support.
217
-
218
- ## to 0.7.0
219
-
220
- No changes needed. Adds `:multiple` boolean option to `grant_on` to grant
221
- badge multiple times.
222
-
223
- ## to 0.6.0
224
-
225
- <tt>MeritBadgeRules</tt>, <tt>MeritPointRules</tt> and <tt>MeritRankRules</tt>
226
- are now namespaced into Merit module. Move and change:
227
-
228
- <pre>
229
- app/models/merit_{badge|point|rank}_rules.rb -> app/models/merit/{badge|point|rank}_rules.rb
230
- </pre>
231
- <pre>
232
- -class Merit{Badge|Point|Rank}Rules
233
- - include Merit::{Badge|Point|Rank}Rules
234
- +module Merit
235
- + class {Badge|Point|Rank}Rules
236
- + include Merit::{Badge|Point|Rank}RulesMethods
237
- </pre>
238
-
239
- ## to 0.5.0
240
-
241
- Add <tt>log:string</tt> column to <tt>merit_actions</tt> table.
242
-
243
- ## to 0.4.0
244
-
245
- Rankings are now integer attributes (<tt>level</tt>), they are not badges
246
- anymore. <tt>set_rank</tt> doesn't accept <tt>badge_name</tt> anymore.
247
-
248
- ## to 0.3.0
249
-
250
- Badges data is now stored in <tt>config/initializers/merit.rb</tt> using
251
- <tt>ambry</tt> syntax (not in the DB anymore, as that table needed to be in
252
- sync in all development environments).
253
-
254
- ## to 0.2.0
255
-
256
- Added <tt>had_errors</tt> boolean attribute to <tt>merit_actions</tt> table.
@@ -1,5 +0,0 @@
1
- class AddTargetDataToMeritActions < ActiveRecord::Migration<%= migration_version %>
2
- def change
3
- add_column :merit_actions, :target_data, :text
4
- end
5
- end
@@ -1,40 +0,0 @@
1
- require 'rails/generators/active_record'
2
-
3
- module ActiveRecord
4
- module Generators
5
- class UpgradeGenerator < Rails::Generators::Base
6
- include Rails::Generators::Migration
7
-
8
- source_root File.expand_path('../templates', __FILE__)
9
- desc 'Makes Active Record migrations to handle upgrades between versions'
10
-
11
- def self.next_migration_number(path)
12
- ActiveRecord::Generators::Base.next_migration_number(path)
13
- end
14
-
15
- def copy_migrations_and_model
16
- if merit_actions_exists? && target_data_column_doesnt_exist?
17
- migration_template 'add_target_data_to_merit_actions.rb',
18
- 'db/migrate/add_target_data_to_merit_actions.rb'
19
- end
20
- end
21
-
22
- def migration_version
23
- "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
24
- end
25
-
26
- private
27
-
28
- def target_data_column_doesnt_exist?
29
- !ActiveRecord::Base.connection.column_exists?(:merit_actions,
30
- :target_data)
31
- end
32
-
33
- # Might be foolishly running this before install. Ugly error if we don't
34
- # check.
35
- def merit_actions_exists?
36
- ActiveRecord::Base.connection.table_exists? :merit_actions
37
- end
38
- end
39
- end
40
- end
@@ -1,16 +0,0 @@
1
- module Merit
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path('../templates', __FILE__)
5
- hook_for :orm
6
-
7
- desc 'Copy config and rules files'
8
- def copy_migrations_and_model
9
- template 'merit.rb', 'config/initializers/merit.rb'
10
- template 'merit_badge_rules.rb', 'app/models/merit/badge_rules.rb'
11
- template 'merit_point_rules.rb', 'app/models/merit/point_rules.rb'
12
- template 'merit_rank_rules.rb', 'app/models/merit/rank_rules.rb'
13
- end
14
- end
15
- end
16
- end
@@ -1,7 +0,0 @@
1
- module Merit
2
- module Generators
3
- class UpgradeGenerator < Rails::Generators::Base
4
- hook_for :orm
5
- end
6
- end
7
- end
@@ -1,18 +0,0 @@
1
- module Merit
2
- class Action
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- has_many :activity_logs, class_name: 'Merit::ActivityLog', as: :related_change
7
-
8
- field :user_id
9
- field :action_method
10
- field :action_value, type: Integer
11
- field :had_errors, type: Boolean
12
- field :target_model
13
- field :target_id
14
- field :target_data
15
- field :processed, type: Boolean, default: false
16
- field :log
17
- end
18
- end
@@ -1,11 +0,0 @@
1
- module Merit
2
- class ActivityLog
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- field :description
7
-
8
- belongs_to :action, class_name: 'Merit::Action'
9
- belongs_to :related_change, polymorphic: true
10
- end
11
- end
@@ -1,20 +0,0 @@
1
- module Merit
2
- class BadgesSash
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
- include Base::BadgesSash
6
-
7
- field :badge_id, type: Integer
8
-
9
- belongs_to :sash, class_name: 'Merit::Sash'
10
- has_many :activity_logs, class_name: 'Merit::ActivityLog', as: :related_change
11
-
12
- def self.last_granted(options = {})
13
- options[:since_date] ||= 1.month.ago
14
- options[:limit] ||= 10
15
- where(:created_at.lte => options[:since_date])
16
- .limit(options[:limit])
17
- .map(&:badge)
18
- end
19
- end
20
- end