easy_roles 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ easy_roles (1.2.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ activemodel (3.0.10)
10
+ activesupport (= 3.0.10)
11
+ builder (~> 2.1.2)
12
+ i18n (~> 0.5.0)
13
+ activerecord (3.0.10)
14
+ activemodel (= 3.0.10)
15
+ activesupport (= 3.0.10)
16
+ arel (~> 2.0.10)
17
+ tzinfo (~> 0.3.23)
18
+ activesupport (3.0.10)
19
+ arel (2.0.10)
20
+ builder (2.1.2)
21
+ diff-lcs (1.1.2)
22
+ i18n (0.5.0)
23
+ rspec (2.6.0)
24
+ rspec-core (~> 2.6.0)
25
+ rspec-expectations (~> 2.6.0)
26
+ rspec-mocks (~> 2.6.0)
27
+ rspec-core (2.6.4)
28
+ rspec-expectations (2.6.0)
29
+ diff-lcs (~> 1.1.2)
30
+ rspec-mocks (2.6.0)
31
+ sqlite3 (1.3.4)
32
+ tzinfo (0.3.29)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ activerecord
39
+ easy_roles!
40
+ rspec
41
+ sqlite3
data/Manifest CHANGED
@@ -1,15 +1,16 @@
1
1
  CHANGELOG.rdoc
2
+ Gemfile
3
+ Gemfile.lock
2
4
  README.rdoc
3
5
  Rakefile
4
6
  easy_roles.gemspec
5
- generators/easy_bitmask_roles/USAGE
6
- generators/easy_bitmask_roles/easy_bitmask_roles_generator.rb
7
- generators/easy_bitmask_roles/templates/migration.rb
8
- generators/easy_roles/USAGE
9
- generators/easy_roles/easy_roles_generator.rb
10
- generators/easy_roles/templates/migration.rb
11
7
  init.rb
12
8
  lib/easy_roles.rb
9
+ lib/generators/active_record/easy_roles_generator.rb
10
+ lib/generators/active_record/templates/migration_bitmask.rb
11
+ lib/generators/active_record/templates/migration_non_bitmask.rb
12
+ lib/generators/easy_roles/easy_roles_generator.rb
13
+ lib/generators/templates/README
13
14
  spec/easy_roles_spec.rb
14
15
  spec/spec_helper.rb
15
16
  Manifest
data/Rakefile CHANGED
@@ -2,11 +2,11 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('easy_roles', '1.1.0') do |p|
5
+ Echoe.new('easy_roles', '1.2.0') do |p|
6
6
  p.description = "Easy role authorization in rails"
7
7
  p.url = "http://github.com/platform45/easy_roles"
8
8
  p.author = "Platform45"
9
9
  p.email = "ryan@platform45.com"
10
10
  p.ignore_pattern = ["tmp/*", "script/*"]
11
- p.development_dependencies = ["rspec", "active_record", "sqlite3-ruby"]
11
+ p.development_dependencies = ["rspec", "activerecord", "sqlite3"]
12
12
  end
@@ -2,38 +2,37 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{easy_roles}
5
- s.version = "1.1.0"
5
+ s.version = "1.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Platform45"]
9
- s.date = %q{2010-09-06}
8
+ s.authors = [%q{Platform45}]
9
+ s.date = %q{2011-08-18}
10
10
  s.description = %q{Easy role authorization in rails}
11
11
  s.email = %q{ryan@platform45.com}
12
- s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc", "lib/easy_roles.rb"]
13
- s.files = ["CHANGELOG.rdoc", "README.rdoc", "Rakefile", "easy_roles.gemspec", "generators/easy_bitmask_roles/USAGE", "generators/easy_bitmask_roles/easy_bitmask_roles_generator.rb", "generators/easy_bitmask_roles/templates/migration.rb", "generators/easy_roles/USAGE", "generators/easy_roles/easy_roles_generator.rb", "generators/easy_roles/templates/migration.rb", "init.rb", "lib/easy_roles.rb", "spec/easy_roles_spec.rb", "spec/spec_helper.rb", "Manifest"]
12
+ s.extra_rdoc_files = [%q{CHANGELOG.rdoc}, %q{README.rdoc}, %q{lib/easy_roles.rb}, %q{lib/generators/active_record/easy_roles_generator.rb}, %q{lib/generators/active_record/templates/migration_bitmask.rb}, %q{lib/generators/active_record/templates/migration_non_bitmask.rb}, %q{lib/generators/easy_roles/easy_roles_generator.rb}, %q{lib/generators/templates/README}]
13
+ s.files = [%q{CHANGELOG.rdoc}, %q{Gemfile}, %q{Gemfile.lock}, %q{README.rdoc}, %q{Rakefile}, %q{easy_roles.gemspec}, %q{init.rb}, %q{lib/easy_roles.rb}, %q{lib/generators/active_record/easy_roles_generator.rb}, %q{lib/generators/active_record/templates/migration_bitmask.rb}, %q{lib/generators/active_record/templates/migration_non_bitmask.rb}, %q{lib/generators/easy_roles/easy_roles_generator.rb}, %q{lib/generators/templates/README}, %q{spec/easy_roles_spec.rb}, %q{spec/spec_helper.rb}, %q{Manifest}]
14
14
  s.homepage = %q{http://github.com/platform45/easy_roles}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Easy_roles", "--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
15
+ s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Easy_roles}, %q{--main}, %q{README.rdoc}]
16
+ s.require_paths = [%q{lib}]
17
17
  s.rubyforge_project = %q{easy_roles}
18
- s.rubygems_version = %q{1.3.7}
18
+ s.rubygems_version = %q{1.8.8}
19
19
  s.summary = %q{Easy role authorization in rails}
20
20
 
21
21
  if s.respond_to? :specification_version then
22
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
22
  s.specification_version = 3
24
23
 
25
24
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
25
  s.add_development_dependency(%q<rspec>, [">= 0"])
27
- s.add_development_dependency(%q<active_record>, [">= 0"])
28
- s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
26
+ s.add_development_dependency(%q<activerecord>, [">= 0"])
27
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
29
28
  else
30
29
  s.add_dependency(%q<rspec>, [">= 0"])
31
- s.add_dependency(%q<active_record>, [">= 0"])
32
- s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
30
+ s.add_dependency(%q<activerecord>, [">= 0"])
31
+ s.add_dependency(%q<sqlite3>, [">= 0"])
33
32
  end
34
33
  else
35
34
  s.add_dependency(%q<rspec>, [">= 0"])
36
- s.add_dependency(%q<active_record>, [">= 0"])
37
- s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
35
+ s.add_dependency(%q<activerecord>, [">= 0"])
36
+ s.add_dependency(%q<sqlite3>, [">= 0"])
38
37
  end
39
38
  end
@@ -12,8 +12,11 @@ module EasyRoles
12
12
 
13
13
  if options[:method] == :serialize
14
14
  serialize name.to_sym, Array
15
- respond_to?(:before_validation_on_create) ? before_validation_on_create(:make_default_roles) : before_validation(:make_default_roles, :on => :create)
16
-
15
+
16
+ ActiveSupport::Deprecation.silence do
17
+ respond_to?(:before_validation_on_create) ? before_validation_on_create(:make_default_roles) : before_validation(:make_default_roles, :on => :create)
18
+ end
19
+
17
20
  class_eval <<-EOC
18
21
  def has_role?(role)
19
22
  #{name}.include?(role)
@@ -0,0 +1,26 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module ActiveRecord
4
+ module Generators
5
+ class EasyRolesGenerator < ActiveRecord::Generators::Base
6
+
7
+ argument :role_col, :type => :string, :required => false, :default => "roles", :banner => "role column"
8
+
9
+ class_option :use_bitmask_method, :type => :boolean, :required => false, :default => false,
10
+ :desc => "Setup migration for Bitmask method"
11
+
12
+ desc "Internal use by easy_roles generator - use that instead"
13
+
14
+ source_root File.expand_path("../templates", __FILE__)
15
+
16
+ def copy_easy_roles_migration
17
+ if options.use_bitmask_method
18
+ migration_template "migration_bitmask.rb", "db/migrate/add_bitmask_roles_to_#{table_name}"
19
+ else
20
+ migration_template "migration_non_bitmask.rb", "db/migrate/add_easy_roles_to_#{table_name}"
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ class AddBitmaskRolesTo<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :<%= table_name %>, :<%= self.role_col %>, :integer, :default => 0
4
+ end
5
+
6
+ def self.down
7
+ remove_column :<%= table_name.to_sym %>, :<%= self.role_col %>
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddEasyRolesTo<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :<%= table_name %>, :<%= self.role_col %>, :string, :default => "--- []"
4
+ end
5
+
6
+ def self.down
7
+ remove_column :<%= table_name.to_sym %>, :<%= self.role_col %>
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ module EasyRoles
2
+ module Generators
3
+ class EasyRolesGenerator < Rails::Generators::NamedBase
4
+ namespace "easy_roles"
5
+
6
+ argument :role_col, :type => :string, :required => false, :default => "roles", :banner => "role column"
7
+
8
+ class_option :use_bitmask_method, :type => :boolean, :required => false, :default => false,
9
+ :desc => "Setup migration for Bitmask method"
10
+
11
+ desc "Create ActiveRecord migration for easy_roles on NAME model using [ROLE] column -- defaults to 'roles'"
12
+
13
+ source_root File.expand_path('../../templates', __FILE__)
14
+
15
+ hook_for :orm
16
+
17
+ def show_readme
18
+ readme "README" if behavior == :invoke
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+
2
+
3
+ ===============================================
4
+
5
+ Now run rake db:migrate
6
+
7
+ ===============================================
8
+
9
+
@@ -4,11 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'active_record'
5
5
  require 'easy_roles'
6
6
 
7
- require 'spec'
8
- require 'spec/autorun'
9
-
10
-
11
- Spec::Runner.configure do |config|
7
+ RSpec.configure do |config|
12
8
  end
13
9
 
14
10
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
metadata CHANGED
@@ -1,130 +1,107 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: easy_roles
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 1
9
- - 0
10
- version: 1.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Platform45
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-09-06 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-18 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2153550700 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: active_record
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2153550700
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ requirement: &2153550220 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
47
33
  type: :development
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: sqlite3-ruby
51
34
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2153550220
36
+ - !ruby/object:Gem::Dependency
37
+ name: sqlite3
38
+ requirement: &2153549740 !ruby/object:Gem::Requirement
53
39
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
61
44
  type: :development
62
- version_requirements: *id003
45
+ prerelease: false
46
+ version_requirements: *2153549740
63
47
  description: Easy role authorization in rails
64
48
  email: ryan@platform45.com
65
49
  executables: []
66
-
67
50
  extensions: []
68
-
69
- extra_rdoc_files:
51
+ extra_rdoc_files:
70
52
  - CHANGELOG.rdoc
71
53
  - README.rdoc
72
54
  - lib/easy_roles.rb
73
- files:
55
+ - lib/generators/active_record/easy_roles_generator.rb
56
+ - lib/generators/active_record/templates/migration_bitmask.rb
57
+ - lib/generators/active_record/templates/migration_non_bitmask.rb
58
+ - lib/generators/easy_roles/easy_roles_generator.rb
59
+ - lib/generators/templates/README
60
+ files:
74
61
  - CHANGELOG.rdoc
62
+ - Gemfile
63
+ - Gemfile.lock
75
64
  - README.rdoc
76
65
  - Rakefile
77
66
  - easy_roles.gemspec
78
- - generators/easy_bitmask_roles/USAGE
79
- - generators/easy_bitmask_roles/easy_bitmask_roles_generator.rb
80
- - generators/easy_bitmask_roles/templates/migration.rb
81
- - generators/easy_roles/USAGE
82
- - generators/easy_roles/easy_roles_generator.rb
83
- - generators/easy_roles/templates/migration.rb
84
67
  - init.rb
85
68
  - lib/easy_roles.rb
69
+ - lib/generators/active_record/easy_roles_generator.rb
70
+ - lib/generators/active_record/templates/migration_bitmask.rb
71
+ - lib/generators/active_record/templates/migration_non_bitmask.rb
72
+ - lib/generators/easy_roles/easy_roles_generator.rb
73
+ - lib/generators/templates/README
86
74
  - spec/easy_roles_spec.rb
87
75
  - spec/spec_helper.rb
88
76
  - Manifest
89
- has_rdoc: true
90
77
  homepage: http://github.com/platform45/easy_roles
91
78
  licenses: []
92
-
93
79
  post_install_message:
94
- rdoc_options:
80
+ rdoc_options:
95
81
  - --line-numbers
96
82
  - --inline-source
97
83
  - --title
98
84
  - Easy_roles
99
85
  - --main
100
86
  - README.rdoc
101
- require_paths:
87
+ require_paths:
102
88
  - lib
103
- required_ruby_version: !ruby/object:Gem::Requirement
89
+ required_ruby_version: !ruby/object:Gem::Requirement
104
90
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
112
- required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
96
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 11
118
- segments:
119
- - 1
120
- - 2
121
- version: "1.2"
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '1.2'
122
101
  requirements: []
123
-
124
102
  rubyforge_project: easy_roles
125
- rubygems_version: 1.3.7
103
+ rubygems_version: 1.8.8
126
104
  signing_key:
127
105
  specification_version: 3
128
106
  summary: Easy role authorization in rails
129
107
  test_files: []
130
-
@@ -1,11 +0,0 @@
1
- NAME
2
- easy_bitmask_roles - generates migration for your bitmask roles authorization column
3
-
4
- USAGE
5
- ./script/generate easy_bitmask_roles Model Column_Name
6
-
7
- EXAMPLE
8
- ./script/generate easy_bitmask_roles user roles_mask
9
-
10
- MORE INFO
11
- http://github.com/platform45/easy_roles
@@ -1,8 +0,0 @@
1
- class EasyBitmaskRolesGenerator < Rails::Generator::NamedBase
2
- def manifest
3
- record do |m|
4
- m.class_collisions class_name
5
- m.migration_template 'migration.rb', "db/migrate", :migration_file_name => "add_bitmask_roles_to_#{table_name}"
6
- end
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- class AddBitmaskRolesTo<%= class_name.pluralize %> < ActiveRecord::Migration
2
- def self.up
3
- add_column :<%= table_name %>, :<%= args.first %>, :integer, :default => 0
4
- end
5
-
6
- def self.down
7
- remove_column :<%= table_name.to_sym %>, :<%= args.first.to_sym %>
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- NAME
2
- easy_roles - generates migration for your roles authorization column
3
-
4
- USAGE
5
- ./script/generate easy_roles Model Column_Name
6
-
7
- EXAMPLE
8
- ./script/generate easy_roles user roles
9
-
10
- MORE INFO
11
- http://github.com/platform45/easy_roles
@@ -1,8 +0,0 @@
1
- class EasyRolesGenerator < Rails::Generator::NamedBase
2
- def manifest
3
- record do |m|
4
- m.class_collisions class_name
5
- m.migration_template 'migration.rb', "db/migrate", :migration_file_name => "add_roles_to_#{table_name}"
6
- end
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- class AddRolesTo<%= class_name.pluralize %> < ActiveRecord::Migration
2
- def self.up
3
- add_column :<%= table_name %>, :<%= args.first %>, :string, :default => "--- []"
4
- end
5
-
6
- def self.down
7
- remove_column :<%= table_name.to_sym %>, :<%= args.first.to_sym %>
8
- end
9
- end