merit 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- merit (0.9.2)
4
+ merit (0.9.3)
5
5
  ambry (~> 0.3.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  1. Add `gem 'merit'` to your `Gemfile`
15
15
  2. Run `rails g merit:install`
16
- 3. Run `rails g merit MODEL_NAME`
16
+ 3. Run `rails g merit MODEL_NAME` (e.g. `user`)
17
17
  4. Depending on your ORM
18
18
  * ActiveRecord: Run `rake db:migrate`
19
19
  * Mongoid: Set `config.orm = :mongoid` in `config/initializers/merit.rb`
@@ -61,10 +61,10 @@ end
61
61
 
62
62
  ## Grant manually
63
63
 
64
- You may also grant badges "by hand":
64
+ You may also grant badges "by hand" (optionally multiple times):
65
65
 
66
66
  ```ruby
67
- Badge.find(3).grant_to(current_user)
67
+ Badge.find(3).grant_to(current_user, :allow_multiple => true)
68
68
  ```
69
69
 
70
70
  ---
@@ -0,0 +1,26 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module ActiveRecord
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ desc "add active_record merit migrations for the root objects"
9
+
10
+ def self.next_migration_number(path)
11
+ unless @prev_migration_nr
12
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
13
+ else
14
+ @prev_migration_nr += 1
15
+ end
16
+ @prev_migration_nr.to_s
17
+ end
18
+
19
+ def copy_migrations_and_model
20
+ migration_template 'create_merit_actions.rb', 'db/migrate/create_merit_actions.rb'
21
+ migration_template 'create_sashes.rb', 'db/migrate/create_sashes.rb'
22
+ migration_template 'create_badges_sashes.rb', 'db/migrate/create_badges_sashes.rb'
23
+ end
24
+ end
25
+ end
26
+ end
@@ -17,9 +17,6 @@ module ActiveRecord
17
17
  end
18
18
 
19
19
  def copy_migrations_and_model
20
- migration_template 'create_merit_actions.rb', 'db/migrate/create_merit_actions.rb'
21
- migration_template 'create_sashes.rb', 'db/migrate/create_sashes.rb'
22
- migration_template 'create_badges_sashes.rb', 'db/migrate/create_badges_sashes.rb'
23
20
  migration_template "add_fields_to_model.rb", "db/migrate/add_fields_to_#{table_name}"
24
21
  end
25
22
  end
@@ -2,6 +2,8 @@ module Merit
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path('../templates', __FILE__)
5
+ hook_for :orm
6
+
5
7
  desc "Copy config and rules files"
6
8
  def copy_migrations_and_model
7
9
  template 'merit.rb', 'config/initializers/merit.rb'
@@ -4,6 +4,12 @@ module Merit
4
4
  source_root File.expand_path("../templates", __FILE__)
5
5
  hook_for :orm
6
6
 
7
+ def inject_merit_content
8
+ inject_into_class(model_path, class_name, " has_merit\n\n") if model_exists?
9
+ end
10
+
11
+ private
12
+
7
13
  def model_exists?
8
14
  File.exists?(File.join(destination_root, model_path))
9
15
  end
@@ -12,9 +18,6 @@ module Merit
12
18
  @model_path ||= File.join("app", "models", "#{file_path}.rb")
13
19
  end
14
20
 
15
- def inject_merit_content
16
- inject_into_class(model_path, class_name, " has_merit\n\n") if model_exists?
17
- end
18
21
  end
19
22
  end
20
- end
23
+ end
@@ -20,6 +20,8 @@ module Merit
20
20
  end
21
21
 
22
22
  class Engine < Rails::Engine
23
+ config.app_generators.orm Merit.orm
24
+
23
25
  initializer 'merit.controller' do |app|
24
26
  if Merit.orm == :active_record
25
27
  require "merit/models/#{Merit.orm}/sash"
@@ -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.9.2"
7
+ s.version = "0.9.3"
8
8
  s.authors = ["Tute Costa"]
9
9
  s.email = 'tutecosta@gmail.com'
10
10
  s.add_dependency 'ambry', '~> 0.3.0'
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.9.2
4
+ version: 0.9.3
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: 2012-07-16 00:00:00.000000000 Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ambry
@@ -156,6 +156,7 @@ files:
156
156
  - app/models/badge.rb
157
157
  - app/models/merit_action.rb
158
158
  - config/locales/en.yml
159
+ - lib/generators/active_record/install_generator.rb
159
160
  - lib/generators/active_record/merit_generator.rb
160
161
  - lib/generators/active_record/templates/add_fields_to_model.rb
161
162
  - lib/generators/active_record/templates/create_badges_sashes.rb