roles 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ = v0.0.3 (Aug 23, 2012)
2
+ * fix generator error
3
+
1
4
  = v0.0.2 (Aug 19, 2012)
2
5
  * rename `user.resources` to `user.resources_with_role`
3
6
 
@@ -8,19 +8,18 @@ module Roles
8
8
  source_root File.expand_path('../templates', __FILE__)
9
9
  argument :role_cname, :type => :string, :default => "Role"
10
10
  argument :user_cname, :type => :string, :default => "User"
11
- argument :orm_adapter, :type => :string, :default => "active_record"
12
11
 
13
12
  desc "Generates a model with the given NAME and a migration file."
14
13
 
15
14
  def generate_role
16
- template "role-#{orm_adapter}.rb", "app/models/#{role_cname.underscore}.rb"
15
+ template "role-active_record.rb", "app/models/#{role_cname.underscore}.rb"
17
16
  inject_into_file(model_path, :after => inject_roles_method) do
18
- " roles" + (role_cname == "Role" ? "" : " :role_cname => '#{role_cname.camelize}'") + "\n"
17
+ " rolify" + (role_cname == "Role" ? "" : " :role_cname => '#{role_cname.camelize}'") + "\n"
19
18
  end
20
19
  end
21
20
 
22
21
  def copy_role_file
23
- migration_template "migration.rb", "db/migrate/roles_create_#{role_cname.tableize}" if orm_adapter == "active_record"
22
+ migration_template "migration.rb", "db/migrate/roles_create_#{role_cname.tableize}"
24
23
  end
25
24
 
26
25
  def model_path
@@ -32,15 +31,11 @@ module Roles
32
31
  end
33
32
 
34
33
  def show_readme
35
- readme "README-#{orm_adapter}" if behavior == :invoke
34
+ readme "README-active_record" if behavior == :invoke
36
35
  end
37
36
 
38
37
  def inject_roles_method
39
- if orm_adapter == "active_record"
40
- /class #{user_cname.camelize}\n|class #{user_cname.camelize} .*\n/
41
- else
42
- /include Mongoid::Document\n|include Mongoid::Document .*\n/
43
- end
38
+ /class #{user_cname.camelize}\n|class #{user_cname.camelize} .*\n/
44
39
  end
45
40
  end
46
41
  end
@@ -1,5 +1,5 @@
1
1
  class <%= role_cname.camelize %> < ActiveRecord::Base
2
- belongs_to :<%= user_cname.tableize %>
2
+ belongs_to :<%= user_cname.tableize.singularize %>
3
3
  belongs_to :resource, :polymorphic => true
4
4
 
5
5
  end
data/lib/roles/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Roles
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.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-08-19 00:00:00.000000000 Z
12
+ date: 2012-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3