the_role 2.5.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +178 -526
- data/gem_version.rb +3 -0
- data/lib/the_role/version.rb +1 -3
- data/lib/the_role.rb +3 -41
- data/the_role.gemspec +5 -5
- metadata +20 -231
- data/.ruby-gemset.example +0 -1
- data/.ruby-version.example +0 -1
- data/.rvmrc.example +0 -1
- data/.travis.yml +0 -5
- data/Bye_bye_CanCan_I_got_the_Role.png +0 -0
- data/app/controllers/admin/role_sections_controller.rb +0 -90
- data/app/controllers/admin/roles_controller.rb +0 -74
- data/app/controllers/concerns/controller.rb +0 -23
- data/app/models/_templates_/role.rb +0 -3
- data/app/models/concerns/base.rb +0 -37
- data/app/models/concerns/role.rb +0 -156
- data/app/models/concerns/user.rb +0 -57
- data/config/locales/en.yml +0 -44
- data/config/locales/es.yml +0 -42
- data/config/locales/nl.yml +0 -44
- data/config/locales/pl.yml +0 -43
- data/config/locales/pt_BR.yml +0 -43
- data/config/locales/ru.yml +0 -43
- data/config/locales/zh_CN.yml +0 -42
- data/config/routes.rb +0 -23
- data/db/migrate/20111025025129_create_roles.rb +0 -23
- data/docs/2.1.1.png +0 -0
- data/lib/generators/the_role/USAGE +0 -32
- data/lib/generators/the_role/templates/the_role.rb +0 -11
- data/lib/generators/the_role/the_role_generator.rb +0 -64
- data/lib/tasks/roles.rake +0 -137
- data/lib/the_role/activerecord.rb +0 -11
- data/lib/the_role/config.rb +0 -30
- data/lib/the_role/hash.rb +0 -58
- data/lib/the_role/the_class_exists.rb +0 -8
- data/pic.png +0 -0
- data/spec/dummy_app/.gitignore +0 -18
- data/spec/dummy_app/.rspec +0 -1
- data/spec/dummy_app/Gemfile +0 -43
- data/spec/dummy_app/README.md +0 -39
- data/spec/dummy_app/Rakefile +0 -6
- data/spec/dummy_app/app/assets/images/.keep +0 -0
- data/spec/dummy_app/app/assets/javascripts/application.js +0 -17
- data/spec/dummy_app/app/assets/stylesheets/app/style.css.scss +0 -23
- data/spec/dummy_app/app/assets/stylesheets/application.css +0 -3
- data/spec/dummy_app/app/controllers/application_controller.rb +0 -38
- data/spec/dummy_app/app/controllers/concerns/.keep +0 -0
- data/spec/dummy_app/app/controllers/pages_controller.rb +0 -75
- data/spec/dummy_app/app/controllers/users_controller.rb +0 -32
- data/spec/dummy_app/app/controllers/welcome_controller.rb +0 -13
- data/spec/dummy_app/app/helpers/application_helper.rb +0 -2
- data/spec/dummy_app/app/mailers/.keep +0 -0
- data/spec/dummy_app/app/models/.keep +0 -0
- data/spec/dummy_app/app/models/concerns/.keep +0 -0
- data/spec/dummy_app/app/models/page.rb +0 -24
- data/spec/dummy_app/app/models/role.rb +0 -4
- data/spec/dummy_app/app/models/user.rb +0 -21
- data/spec/dummy_app/app/views/layouts/_current_user_info.html.haml +0 -17
- data/spec/dummy_app/app/views/layouts/application.html.haml +0 -68
- data/spec/dummy_app/app/views/pages/_form.html.haml +0 -19
- data/spec/dummy_app/app/views/pages/edit.html.haml +0 -7
- data/spec/dummy_app/app/views/pages/index.html.haml +0 -27
- data/spec/dummy_app/app/views/pages/manage.html.haml +0 -23
- data/spec/dummy_app/app/views/pages/my.html.haml +0 -10
- data/spec/dummy_app/app/views/pages/new.html.haml +0 -5
- data/spec/dummy_app/app/views/pages/show.html.haml +0 -15
- data/spec/dummy_app/app/views/users/edit.html.haml +0 -34
- data/spec/dummy_app/app/views/welcome/index.html.haml +0 -38
- data/spec/dummy_app/app/views/welcome/profile.html.haml +0 -2
- data/spec/dummy_app/bin/bundle +0 -3
- data/spec/dummy_app/bin/rails +0 -4
- data/spec/dummy_app/bin/rake +0 -4
- data/spec/dummy_app/config/application.rb +0 -25
- data/spec/dummy_app/config/boot.rb +0 -4
- data/spec/dummy_app/config/database.yml +0 -17
- data/spec/dummy_app/config/environment.rb +0 -5
- data/spec/dummy_app/config/environments/development.rb +0 -29
- data/spec/dummy_app/config/environments/production.rb +0 -80
- data/spec/dummy_app/config/environments/test.rb +0 -36
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy_app/config/initializers/devise.rb +0 -227
- data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy_app/config/initializers/inflections.rb +0 -16
- data/spec/dummy_app/config/initializers/mime_types.rb +0 -5
- data/spec/dummy_app/config/initializers/secret_token.rb +0 -12
- data/spec/dummy_app/config/initializers/session_store.rb +0 -3
- data/spec/dummy_app/config/initializers/the_role.rb +0 -6
- data/spec/dummy_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy_app/config/locales/devise.en.yml +0 -57
- data/spec/dummy_app/config/locales/en.yml +0 -7
- data/spec/dummy_app/config/locales/ru.yml +0 -4
- data/spec/dummy_app/config/routes.rb +0 -26
- data/spec/dummy_app/config.ru +0 -4
- data/spec/dummy_app/db/migrate/20120212061952_devise_create_users.rb +0 -63
- data/spec/dummy_app/db/migrate/20120212063249_create_roles.rb +0 -18
- data/spec/dummy_app/db/migrate/20120314061307_create_pages.rb +0 -14
- data/spec/dummy_app/db/schema.rb +0 -59
- data/spec/dummy_app/db/seeds.rb +0 -85
- data/spec/dummy_app/lib/assets/.keep +0 -0
- data/spec/dummy_app/lib/tasks/.keep +0 -0
- data/spec/dummy_app/lib/tasks/assets.rake +0 -15
- data/spec/dummy_app/lib/tasks/db_bootstrap.rake +0 -16
- data/spec/dummy_app/log/.keep +0 -0
- data/spec/dummy_app/public/404.html +0 -58
- data/spec/dummy_app/public/422.html +0 -58
- data/spec/dummy_app/public/500.html +0 -57
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/public/robots.txt +0 -5
- data/spec/dummy_app/spec/controllers/admin_roles_controller_spec.rb +0 -52
- data/spec/dummy_app/spec/controllers/pages_controller_spec.rb +0 -141
- data/spec/dummy_app/spec/controllers/welcome_controller_spec.rb +0 -66
- data/spec/dummy_app/spec/factories/page.rb +0 -6
- data/spec/dummy_app/spec/factories/role.rb +0 -55
- data/spec/dummy_app/spec/factories/user.rb +0 -11
- data/spec/dummy_app/spec/models/hash_spec.rb +0 -272
- data/spec/dummy_app/spec/models/param_process_spec.rb +0 -39
- data/spec/dummy_app/spec/models/role_spec.rb +0 -218
- data/spec/dummy_app/spec/models/user_spec.rb +0 -164
- data/spec/dummy_app/spec/routing/admin_roles_routing_spec.rb +0 -41
- data/spec/dummy_app/spec/routing/pages_routing_spec.rb +0 -35
- data/spec/dummy_app/spec/spec_helper.rb +0 -68
- data/spec/dummy_app/vendor/assets/javascripts/.keep +0 -0
- data/spec/dummy_app/vendor/assets/stylesheets/.keep +0 -0
- data/the_role.yml.teamocil.example +0 -11
data/gem_version.rb
ADDED
data/lib/the_role/version.rb
CHANGED
data/lib/the_role.rb
CHANGED
@@ -1,44 +1,6 @@
|
|
1
|
-
require 'the_role/hash'
|
2
|
-
require 'the_role/config'
|
3
1
|
require 'the_role/version'
|
4
|
-
require 'the_role/activerecord'
|
5
2
|
|
6
|
-
require '
|
3
|
+
require 'the_role_api'
|
4
|
+
require 'the_role_management_panel'
|
7
5
|
|
8
|
-
module TheRole
|
9
|
-
class << self
|
10
|
-
def create_admin_role!
|
11
|
-
admin_role = ::Role.where(name: :admin).first_or_create!(
|
12
|
-
name: :admin,
|
13
|
-
title: "Role for admin",
|
14
|
-
description: "This user can do anything"
|
15
|
-
)
|
16
|
-
admin_role.create_rule(:system, :administrator)
|
17
|
-
admin_role.rule_on(:system, :administrator)
|
18
|
-
admin_role
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Engine < Rails::Engine
|
23
|
-
# initializer "TheRole precompile hook", group: :all do |app|
|
24
|
-
# app.config.assets.precompile += %w( x.js y.css )
|
25
|
-
# end
|
26
|
-
|
27
|
-
# http://stackoverflow.com/questions/6279325/adding-to-rails-autoload-path-from-gem
|
28
|
-
# config.to_prepare do; end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
_root_ = File.expand_path('../../', __FILE__)
|
33
|
-
|
34
|
-
# Loading of concerns
|
35
|
-
require "#{_root_}/config/routes.rb"
|
36
|
-
require "#{_root_}/app/controllers/concerns/controller.rb"
|
37
|
-
|
38
|
-
%w[ base role user ].each do |concern|
|
39
|
-
require "#{_root_}/app/models/concerns/#{concern}.rb"
|
40
|
-
end
|
41
|
-
|
42
|
-
if defined?(ActiveRecord::Base)
|
43
|
-
ActiveRecord::Base.extend TheRole::ActiveRecord
|
44
|
-
end
|
6
|
+
module TheRole; end
|
data/the_role.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Ilya N. Zykin [the-teacher]"]
|
9
9
|
s.email = ["zykin-ilya@ya.ru"]
|
10
10
|
s.homepage = "https://github.com/the-teacher/the_role"
|
11
|
-
s.summary = %q{Authorization for Rails
|
12
|
-
s.description = %q{Authorization for Rails
|
11
|
+
s.summary = %q{Authorization for Rails}
|
12
|
+
s.description = %q{Authorization gem for Ruby on Rails with Management Panel}
|
13
13
|
|
14
14
|
s.rubyforge_project = "the_role"
|
15
15
|
|
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.
|
22
|
-
s.add_runtime_dependency '
|
23
|
-
end
|
21
|
+
s.add_runtime_dependency 'the_role_api', '~> 3.0.1'
|
22
|
+
s.add_runtime_dependency 'the_role_management_panel', '~> 3.0.1'
|
23
|
+
end
|
metadata
CHANGED
@@ -1,182 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_role
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya N. Zykin [the-teacher]
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: the_role_api
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: the_role_management_panel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
- - <
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '5'
|
33
|
+
version: 3.0.1
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '3'
|
44
|
-
- - <
|
38
|
+
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
description: Authorization for Rails
|
40
|
+
version: 3.0.1
|
41
|
+
description: Authorization gem for Ruby on Rails with Management Panel
|
48
42
|
email:
|
49
43
|
- zykin-ilya@ya.ru
|
50
44
|
executables: []
|
51
45
|
extensions: []
|
52
46
|
extra_rdoc_files: []
|
53
47
|
files:
|
54
|
-
- .gitignore
|
55
|
-
- .ruby-gemset.example
|
56
|
-
- .ruby-version.example
|
57
|
-
- .rvmrc.example
|
58
|
-
- .travis.yml
|
59
|
-
- Bye_bye_CanCan_I_got_the_Role.png
|
48
|
+
- ".gitignore"
|
60
49
|
- Gemfile
|
61
50
|
- README.md
|
62
51
|
- Rakefile
|
63
|
-
-
|
64
|
-
- app/controllers/admin/roles_controller.rb
|
65
|
-
- app/controllers/concerns/controller.rb
|
66
|
-
- app/models/_templates_/role.rb
|
67
|
-
- app/models/concerns/base.rb
|
68
|
-
- app/models/concerns/role.rb
|
69
|
-
- app/models/concerns/user.rb
|
70
|
-
- config/locales/en.yml
|
71
|
-
- config/locales/es.yml
|
72
|
-
- config/locales/nl.yml
|
73
|
-
- config/locales/pl.yml
|
74
|
-
- config/locales/pt_BR.yml
|
75
|
-
- config/locales/ru.yml
|
76
|
-
- config/locales/zh_CN.yml
|
77
|
-
- config/routes.rb
|
78
|
-
- db/migrate/20111025025129_create_roles.rb
|
79
|
-
- docs/2.1.1.png
|
80
|
-
- lib/generators/the_role/USAGE
|
81
|
-
- lib/generators/the_role/templates/the_role.rb
|
82
|
-
- lib/generators/the_role/the_role_generator.rb
|
83
|
-
- lib/tasks/roles.rake
|
52
|
+
- gem_version.rb
|
84
53
|
- lib/the_role.rb
|
85
|
-
- lib/the_role/activerecord.rb
|
86
|
-
- lib/the_role/config.rb
|
87
|
-
- lib/the_role/hash.rb
|
88
|
-
- lib/the_role/the_class_exists.rb
|
89
54
|
- lib/the_role/version.rb
|
90
|
-
- pic.png
|
91
55
|
- the_role.gemspec
|
92
|
-
- the_role.yml.teamocil.example
|
93
|
-
- spec/dummy_app/.gitignore
|
94
|
-
- spec/dummy_app/.rspec
|
95
|
-
- spec/dummy_app/Gemfile
|
96
|
-
- spec/dummy_app/README.md
|
97
|
-
- spec/dummy_app/Rakefile
|
98
|
-
- spec/dummy_app/app/assets/images/.keep
|
99
|
-
- spec/dummy_app/app/assets/javascripts/application.js
|
100
|
-
- spec/dummy_app/app/assets/stylesheets/app/style.css.scss
|
101
|
-
- spec/dummy_app/app/assets/stylesheets/application.css
|
102
|
-
- spec/dummy_app/app/controllers/application_controller.rb
|
103
|
-
- spec/dummy_app/app/controllers/concerns/.keep
|
104
|
-
- spec/dummy_app/app/controllers/pages_controller.rb
|
105
|
-
- spec/dummy_app/app/controllers/users_controller.rb
|
106
|
-
- spec/dummy_app/app/controllers/welcome_controller.rb
|
107
|
-
- spec/dummy_app/app/helpers/application_helper.rb
|
108
|
-
- spec/dummy_app/app/mailers/.keep
|
109
|
-
- spec/dummy_app/app/models/.keep
|
110
|
-
- spec/dummy_app/app/models/concerns/.keep
|
111
|
-
- spec/dummy_app/app/models/page.rb
|
112
|
-
- spec/dummy_app/app/models/role.rb
|
113
|
-
- spec/dummy_app/app/models/user.rb
|
114
|
-
- spec/dummy_app/app/views/layouts/_current_user_info.html.haml
|
115
|
-
- spec/dummy_app/app/views/layouts/application.html.haml
|
116
|
-
- spec/dummy_app/app/views/pages/_form.html.haml
|
117
|
-
- spec/dummy_app/app/views/pages/edit.html.haml
|
118
|
-
- spec/dummy_app/app/views/pages/index.html.haml
|
119
|
-
- spec/dummy_app/app/views/pages/manage.html.haml
|
120
|
-
- spec/dummy_app/app/views/pages/my.html.haml
|
121
|
-
- spec/dummy_app/app/views/pages/new.html.haml
|
122
|
-
- spec/dummy_app/app/views/pages/show.html.haml
|
123
|
-
- spec/dummy_app/app/views/users/edit.html.haml
|
124
|
-
- spec/dummy_app/app/views/welcome/index.html.haml
|
125
|
-
- spec/dummy_app/app/views/welcome/profile.html.haml
|
126
|
-
- spec/dummy_app/bin/bundle
|
127
|
-
- spec/dummy_app/bin/rails
|
128
|
-
- spec/dummy_app/bin/rake
|
129
|
-
- spec/dummy_app/config.ru
|
130
|
-
- spec/dummy_app/config/application.rb
|
131
|
-
- spec/dummy_app/config/boot.rb
|
132
|
-
- spec/dummy_app/config/database.yml
|
133
|
-
- spec/dummy_app/config/environment.rb
|
134
|
-
- spec/dummy_app/config/environments/development.rb
|
135
|
-
- spec/dummy_app/config/environments/production.rb
|
136
|
-
- spec/dummy_app/config/environments/test.rb
|
137
|
-
- spec/dummy_app/config/initializers/backtrace_silencers.rb
|
138
|
-
- spec/dummy_app/config/initializers/devise.rb
|
139
|
-
- spec/dummy_app/config/initializers/filter_parameter_logging.rb
|
140
|
-
- spec/dummy_app/config/initializers/inflections.rb
|
141
|
-
- spec/dummy_app/config/initializers/mime_types.rb
|
142
|
-
- spec/dummy_app/config/initializers/secret_token.rb
|
143
|
-
- spec/dummy_app/config/initializers/session_store.rb
|
144
|
-
- spec/dummy_app/config/initializers/the_role.rb
|
145
|
-
- spec/dummy_app/config/initializers/wrap_parameters.rb
|
146
|
-
- spec/dummy_app/config/locales/devise.en.yml
|
147
|
-
- spec/dummy_app/config/locales/en.yml
|
148
|
-
- spec/dummy_app/config/locales/ru.yml
|
149
|
-
- spec/dummy_app/config/routes.rb
|
150
|
-
- spec/dummy_app/db/migrate/20120212061952_devise_create_users.rb
|
151
|
-
- spec/dummy_app/db/migrate/20120212063249_create_roles.rb
|
152
|
-
- spec/dummy_app/db/migrate/20120314061307_create_pages.rb
|
153
|
-
- spec/dummy_app/db/schema.rb
|
154
|
-
- spec/dummy_app/db/seeds.rb
|
155
|
-
- spec/dummy_app/lib/assets/.keep
|
156
|
-
- spec/dummy_app/lib/tasks/.keep
|
157
|
-
- spec/dummy_app/lib/tasks/assets.rake
|
158
|
-
- spec/dummy_app/lib/tasks/db_bootstrap.rake
|
159
|
-
- spec/dummy_app/log/.keep
|
160
|
-
- spec/dummy_app/public/404.html
|
161
|
-
- spec/dummy_app/public/422.html
|
162
|
-
- spec/dummy_app/public/500.html
|
163
|
-
- spec/dummy_app/public/favicon.ico
|
164
|
-
- spec/dummy_app/public/robots.txt
|
165
|
-
- spec/dummy_app/spec/controllers/admin_roles_controller_spec.rb
|
166
|
-
- spec/dummy_app/spec/controllers/pages_controller_spec.rb
|
167
|
-
- spec/dummy_app/spec/controllers/welcome_controller_spec.rb
|
168
|
-
- spec/dummy_app/spec/factories/page.rb
|
169
|
-
- spec/dummy_app/spec/factories/role.rb
|
170
|
-
- spec/dummy_app/spec/factories/user.rb
|
171
|
-
- spec/dummy_app/spec/models/hash_spec.rb
|
172
|
-
- spec/dummy_app/spec/models/param_process_spec.rb
|
173
|
-
- spec/dummy_app/spec/models/role_spec.rb
|
174
|
-
- spec/dummy_app/spec/models/user_spec.rb
|
175
|
-
- spec/dummy_app/spec/routing/admin_roles_routing_spec.rb
|
176
|
-
- spec/dummy_app/spec/routing/pages_routing_spec.rb
|
177
|
-
- spec/dummy_app/spec/spec_helper.rb
|
178
|
-
- spec/dummy_app/vendor/assets/javascripts/.keep
|
179
|
-
- spec/dummy_app/vendor/assets/stylesheets/.keep
|
180
56
|
homepage: https://github.com/the-teacher/the_role
|
181
57
|
licenses: []
|
182
58
|
metadata: {}
|
@@ -186,105 +62,18 @@ require_paths:
|
|
186
62
|
- lib
|
187
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
188
64
|
requirements:
|
189
|
-
- -
|
65
|
+
- - ">="
|
190
66
|
- !ruby/object:Gem::Version
|
191
67
|
version: '0'
|
192
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
69
|
requirements:
|
194
|
-
- -
|
70
|
+
- - ">="
|
195
71
|
- !ruby/object:Gem::Version
|
196
72
|
version: '0'
|
197
73
|
requirements: []
|
198
74
|
rubyforge_project: the_role
|
199
|
-
rubygems_version: 2.
|
75
|
+
rubygems_version: 2.2.2
|
200
76
|
signing_key:
|
201
77
|
specification_version: 4
|
202
|
-
summary: Authorization for Rails
|
203
|
-
test_files:
|
204
|
-
- spec/dummy_app/.gitignore
|
205
|
-
- spec/dummy_app/.rspec
|
206
|
-
- spec/dummy_app/Gemfile
|
207
|
-
- spec/dummy_app/README.md
|
208
|
-
- spec/dummy_app/Rakefile
|
209
|
-
- spec/dummy_app/app/assets/images/.keep
|
210
|
-
- spec/dummy_app/app/assets/javascripts/application.js
|
211
|
-
- spec/dummy_app/app/assets/stylesheets/app/style.css.scss
|
212
|
-
- spec/dummy_app/app/assets/stylesheets/application.css
|
213
|
-
- spec/dummy_app/app/controllers/application_controller.rb
|
214
|
-
- spec/dummy_app/app/controllers/concerns/.keep
|
215
|
-
- spec/dummy_app/app/controllers/pages_controller.rb
|
216
|
-
- spec/dummy_app/app/controllers/users_controller.rb
|
217
|
-
- spec/dummy_app/app/controllers/welcome_controller.rb
|
218
|
-
- spec/dummy_app/app/helpers/application_helper.rb
|
219
|
-
- spec/dummy_app/app/mailers/.keep
|
220
|
-
- spec/dummy_app/app/models/.keep
|
221
|
-
- spec/dummy_app/app/models/concerns/.keep
|
222
|
-
- spec/dummy_app/app/models/page.rb
|
223
|
-
- spec/dummy_app/app/models/role.rb
|
224
|
-
- spec/dummy_app/app/models/user.rb
|
225
|
-
- spec/dummy_app/app/views/layouts/_current_user_info.html.haml
|
226
|
-
- spec/dummy_app/app/views/layouts/application.html.haml
|
227
|
-
- spec/dummy_app/app/views/pages/_form.html.haml
|
228
|
-
- spec/dummy_app/app/views/pages/edit.html.haml
|
229
|
-
- spec/dummy_app/app/views/pages/index.html.haml
|
230
|
-
- spec/dummy_app/app/views/pages/manage.html.haml
|
231
|
-
- spec/dummy_app/app/views/pages/my.html.haml
|
232
|
-
- spec/dummy_app/app/views/pages/new.html.haml
|
233
|
-
- spec/dummy_app/app/views/pages/show.html.haml
|
234
|
-
- spec/dummy_app/app/views/users/edit.html.haml
|
235
|
-
- spec/dummy_app/app/views/welcome/index.html.haml
|
236
|
-
- spec/dummy_app/app/views/welcome/profile.html.haml
|
237
|
-
- spec/dummy_app/bin/bundle
|
238
|
-
- spec/dummy_app/bin/rails
|
239
|
-
- spec/dummy_app/bin/rake
|
240
|
-
- spec/dummy_app/config.ru
|
241
|
-
- spec/dummy_app/config/application.rb
|
242
|
-
- spec/dummy_app/config/boot.rb
|
243
|
-
- spec/dummy_app/config/database.yml
|
244
|
-
- spec/dummy_app/config/environment.rb
|
245
|
-
- spec/dummy_app/config/environments/development.rb
|
246
|
-
- spec/dummy_app/config/environments/production.rb
|
247
|
-
- spec/dummy_app/config/environments/test.rb
|
248
|
-
- spec/dummy_app/config/initializers/backtrace_silencers.rb
|
249
|
-
- spec/dummy_app/config/initializers/devise.rb
|
250
|
-
- spec/dummy_app/config/initializers/filter_parameter_logging.rb
|
251
|
-
- spec/dummy_app/config/initializers/inflections.rb
|
252
|
-
- spec/dummy_app/config/initializers/mime_types.rb
|
253
|
-
- spec/dummy_app/config/initializers/secret_token.rb
|
254
|
-
- spec/dummy_app/config/initializers/session_store.rb
|
255
|
-
- spec/dummy_app/config/initializers/the_role.rb
|
256
|
-
- spec/dummy_app/config/initializers/wrap_parameters.rb
|
257
|
-
- spec/dummy_app/config/locales/devise.en.yml
|
258
|
-
- spec/dummy_app/config/locales/en.yml
|
259
|
-
- spec/dummy_app/config/locales/ru.yml
|
260
|
-
- spec/dummy_app/config/routes.rb
|
261
|
-
- spec/dummy_app/db/migrate/20120212061952_devise_create_users.rb
|
262
|
-
- spec/dummy_app/db/migrate/20120212063249_create_roles.rb
|
263
|
-
- spec/dummy_app/db/migrate/20120314061307_create_pages.rb
|
264
|
-
- spec/dummy_app/db/schema.rb
|
265
|
-
- spec/dummy_app/db/seeds.rb
|
266
|
-
- spec/dummy_app/lib/assets/.keep
|
267
|
-
- spec/dummy_app/lib/tasks/.keep
|
268
|
-
- spec/dummy_app/lib/tasks/assets.rake
|
269
|
-
- spec/dummy_app/lib/tasks/db_bootstrap.rake
|
270
|
-
- spec/dummy_app/log/.keep
|
271
|
-
- spec/dummy_app/public/404.html
|
272
|
-
- spec/dummy_app/public/422.html
|
273
|
-
- spec/dummy_app/public/500.html
|
274
|
-
- spec/dummy_app/public/favicon.ico
|
275
|
-
- spec/dummy_app/public/robots.txt
|
276
|
-
- spec/dummy_app/spec/controllers/admin_roles_controller_spec.rb
|
277
|
-
- spec/dummy_app/spec/controllers/pages_controller_spec.rb
|
278
|
-
- spec/dummy_app/spec/controllers/welcome_controller_spec.rb
|
279
|
-
- spec/dummy_app/spec/factories/page.rb
|
280
|
-
- spec/dummy_app/spec/factories/role.rb
|
281
|
-
- spec/dummy_app/spec/factories/user.rb
|
282
|
-
- spec/dummy_app/spec/models/hash_spec.rb
|
283
|
-
- spec/dummy_app/spec/models/param_process_spec.rb
|
284
|
-
- spec/dummy_app/spec/models/role_spec.rb
|
285
|
-
- spec/dummy_app/spec/models/user_spec.rb
|
286
|
-
- spec/dummy_app/spec/routing/admin_roles_routing_spec.rb
|
287
|
-
- spec/dummy_app/spec/routing/pages_routing_spec.rb
|
288
|
-
- spec/dummy_app/spec/spec_helper.rb
|
289
|
-
- spec/dummy_app/vendor/assets/javascripts/.keep
|
290
|
-
- spec/dummy_app/vendor/assets/stylesheets/.keep
|
78
|
+
summary: Authorization for Rails
|
79
|
+
test_files: []
|
data/.ruby-gemset.example
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
the_role
|
data/.ruby-version.example
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby-2.0.0-p353
|
data/.rvmrc.example
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use ruby-2.0.0-p353@the_role --create
|
data/.travis.yml
DELETED
Binary file
|
@@ -1,90 +0,0 @@
|
|
1
|
-
class Admin::RoleSectionsController < ApplicationController
|
2
|
-
include TheRole::Controller
|
3
|
-
layout TheRole.config.layout.to_s
|
4
|
-
|
5
|
-
before_filter :login_required
|
6
|
-
before_filter :role_required
|
7
|
-
|
8
|
-
before_filter :section_rule_names, only: [:rule_on, :rule_off, :destroy_rule]
|
9
|
-
before_filter :role_find, only: [:create, :create_rule, :rule_on, :rule_off, :destroy, :destroy_rule]
|
10
|
-
before_filter :owner_required, only: [:create, :create_rule, :rule_on, :rule_off, :destroy, :destroy_rule]
|
11
|
-
|
12
|
-
def create
|
13
|
-
if @role.create_section params[:section_name]
|
14
|
-
flash[:notice] = t 'the_role.section_created'
|
15
|
-
else
|
16
|
-
flash[:error] = t 'the_role.section_not_created'
|
17
|
-
end
|
18
|
-
|
19
|
-
redirect_to_edit
|
20
|
-
end
|
21
|
-
|
22
|
-
def create_rule
|
23
|
-
if @role.create_rule params[:section_name], params[:rule_name]
|
24
|
-
flash[:notice] = t 'the_role.section_rule_created'
|
25
|
-
else
|
26
|
-
flash[:error] = t 'the_role.section_rule_not_created'
|
27
|
-
end
|
28
|
-
|
29
|
-
redirect_to_edit
|
30
|
-
end
|
31
|
-
|
32
|
-
def rule_on
|
33
|
-
if @role.rule_on @section_name, @rule_name
|
34
|
-
flash[:notice] = t 'the_role.section_rule_on'
|
35
|
-
else
|
36
|
-
flash[:error] = t 'the_role.state_not_changed'
|
37
|
-
end
|
38
|
-
|
39
|
-
redirect_to_edit
|
40
|
-
end
|
41
|
-
|
42
|
-
def rule_off
|
43
|
-
if @role.rule_off @section_name, @rule_name
|
44
|
-
flash[:notice] = t 'the_role.section_rule_off'
|
45
|
-
else
|
46
|
-
flash[:error] = t 'the_role.state_not_changed'
|
47
|
-
end
|
48
|
-
|
49
|
-
redirect_to_edit
|
50
|
-
end
|
51
|
-
|
52
|
-
def destroy_rule
|
53
|
-
if @role.delete_rule @section_name, @rule_name
|
54
|
-
flash[:notice] = t 'the_role.section_rule_deleted'
|
55
|
-
else
|
56
|
-
flash[:error] = t 'the_role.section_rule_not_deleted'
|
57
|
-
end
|
58
|
-
|
59
|
-
redirect_to_edit
|
60
|
-
end
|
61
|
-
|
62
|
-
def destroy
|
63
|
-
section_name = params[:id]
|
64
|
-
if @role.delete_section section_name
|
65
|
-
flash[:notice] = t 'the_role.section_deleted'
|
66
|
-
else
|
67
|
-
flash[:error] = t 'the_role.section_not_deleted'
|
68
|
-
end
|
69
|
-
redirect_to_edit
|
70
|
-
end
|
71
|
-
|
72
|
-
protected
|
73
|
-
|
74
|
-
def section_rule_names
|
75
|
-
@section_name = params[:id]
|
76
|
-
@rule_name = params[:name]
|
77
|
-
end
|
78
|
-
|
79
|
-
def role_find
|
80
|
-
@role = Role.find params[:role_id]
|
81
|
-
|
82
|
-
# TheRole: You should define OWNER CHECK OBJECT
|
83
|
-
# When editable object was found
|
84
|
-
@owner_check_object = @role
|
85
|
-
end
|
86
|
-
|
87
|
-
def redirect_to_edit
|
88
|
-
redirect_to edit_admin_role_path @role
|
89
|
-
end
|
90
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
class Admin::RolesController < ApplicationController
|
2
|
-
include TheRole::Controller
|
3
|
-
layout TheRole.config.layout.to_s
|
4
|
-
|
5
|
-
before_filter :login_required
|
6
|
-
before_filter :role_required
|
7
|
-
|
8
|
-
before_filter :role_find, only: [:edit, :update, :destroy, :change]
|
9
|
-
before_filter :owner_required, only: [:edit, :update, :destroy, :change]
|
10
|
-
|
11
|
-
def index
|
12
|
-
@roles = Role.all.order('created_at ASC')
|
13
|
-
end
|
14
|
-
|
15
|
-
def new
|
16
|
-
@role = Role.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def edit; end
|
20
|
-
|
21
|
-
def create
|
22
|
-
@role = Role.new role_params
|
23
|
-
|
24
|
-
if @role.save
|
25
|
-
flash[:notice] = t 'the_role.role_created'
|
26
|
-
redirect_to_edit
|
27
|
-
else
|
28
|
-
render :action => :new
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def update
|
33
|
-
if @role.update_role params[:role][:the_role]
|
34
|
-
flash[:notice] = t 'the_role.role_updated'
|
35
|
-
redirect_to_edit
|
36
|
-
else
|
37
|
-
render :action => :edit
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def change
|
42
|
-
if @role.update_attributes!(role_params)
|
43
|
-
flash[:notice] = t 'the_role.role_updated'
|
44
|
-
redirect_to_edit
|
45
|
-
else
|
46
|
-
render :action => :edit
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def destroy
|
51
|
-
@role.destroy
|
52
|
-
flash[:notice] = t 'the_role.role_deleted'
|
53
|
-
redirect_to admin_roles_url
|
54
|
-
end
|
55
|
-
|
56
|
-
protected
|
57
|
-
|
58
|
-
def role_params
|
59
|
-
params.require(:role).permit(:name, :title, :description, :the_role, :based_on_role)
|
60
|
-
end
|
61
|
-
|
62
|
-
def role_find
|
63
|
-
@role = Role.find params[:id]
|
64
|
-
|
65
|
-
# TheRole: You should define OWNER CHECK OBJECT
|
66
|
-
# When editable object was found
|
67
|
-
@owner_check_object = @role
|
68
|
-
end
|
69
|
-
|
70
|
-
def redirect_to_edit
|
71
|
-
redirect_to edit_admin_role_path @role
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module TheRole
|
2
|
-
module Controller
|
3
|
-
def login_required
|
4
|
-
send TheRole.config.login_required_method
|
5
|
-
end
|
6
|
-
|
7
|
-
def role_access_denied
|
8
|
-
send TheRole.config.access_denied_method
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def role_required
|
14
|
-
role_access_denied unless current_user.has_role?(controller_path, action_name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def owner_required
|
18
|
-
# TheRole: You should define OWNER CHECK OBJECT
|
19
|
-
# When editable object was found
|
20
|
-
role_access_denied unless current_user.owner?(@owner_check_object)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/app/models/concerns/base.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module TheRole
|
2
|
-
module Base
|
3
|
-
def has_section? section_name
|
4
|
-
hash = role_hash
|
5
|
-
section_name = section_name.to_slug_param(sep: '_')
|
6
|
-
return true if hash[section_name]
|
7
|
-
false
|
8
|
-
end
|
9
|
-
|
10
|
-
def has_role? section_name, rule_name
|
11
|
-
hash = role_hash
|
12
|
-
section_name = section_name.to_slug_param(sep: '_')
|
13
|
-
rule_name = rule_name.to_slug_param(sep: '_')
|
14
|
-
|
15
|
-
return true if hash.try(:[], 'system').try(:[], 'administrator')
|
16
|
-
return true if hash.try(:[], 'moderator').try(:[], section_name)
|
17
|
-
|
18
|
-
return false unless hash[section_name]
|
19
|
-
return false unless hash[section_name].key? rule_name
|
20
|
-
hash[section_name][rule_name]
|
21
|
-
end
|
22
|
-
|
23
|
-
def any_role? roles_hash = {}
|
24
|
-
roles_hash.each_pair{|section, action| return true if has_role?(section, action)}
|
25
|
-
false
|
26
|
-
end
|
27
|
-
|
28
|
-
def moderator? section_name
|
29
|
-
section_name = section_name.to_slug_param(sep: '_')
|
30
|
-
has_role? section_name, 'any_crazy_name'
|
31
|
-
end
|
32
|
-
|
33
|
-
def admin?
|
34
|
-
has_role? 'any_crazy_name', 'any_crazy_name'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|