arpa 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/arpa.gemspec +0 -1
- data/lib/arpa/services/verifier.rb +1 -1
- data/lib/arpa/version.rb +1 -1
- data/lib/generators/arpa/controllers_generator.rb +59 -0
- data/lib/generators/arpa/install_generator.rb +20 -48
- data/lib/{arpa → generators/arpa/templates}/assets/stylesheets/arpa_accordion.scss +0 -0
- data/lib/{arpa → generators/arpa/templates}/controllers/profiles_controller.rb +0 -2
- data/lib/{arpa → generators/arpa/templates}/controllers/resources_controller.rb +0 -2
- data/lib/{arpa → generators/arpa/templates}/controllers/roles_controller.rb +0 -2
- data/lib/generators/arpa/templates/migration.rb +4 -2
- data/lib/{arpa → generators/arpa/templates}/views/profiles/_form.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/profiles/edit.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/profiles/index.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/profiles/new.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/profiles/show.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/resources/index.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/resources/show.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/roles/_form.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/roles/edit.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/roles/index.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/roles/new.html.erb +0 -0
- data/lib/{arpa → generators/arpa/templates}/views/roles/show.html.erb +0 -0
- data/spec/lib/ar/services/verifier_spec.rb +10 -1
- metadata +19 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 931f0491ce2453cff1606cdc0f2cd5991a7921c6
|
4
|
+
data.tar.gz: 6ed81530f8cc41943e1b9683c4676e60db6d697e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a7cf1f28d58a0406abe0ff35ae3ab121bc8e209b5f807f287f2ca3e5309bbb5fc446a4799be6f034a7e6a80d61939c99b224ead2784a3d8dd26dbe5a7314068
|
7
|
+
data.tar.gz: f0481f9001e29f74fa20db57c016270de9b4538a430691d67bfe727adda6190458d7216f691a169f78d2d84f8fd4b6ee14c8b9073fdea9e7234e12157bd7a822
|
data/arpa.gemspec
CHANGED
@@ -9,7 +9,7 @@ module Arpa
|
|
9
9
|
|
10
10
|
def has_access?(resource, action)
|
11
11
|
free_access_action = action.to_s.split('_')[0]
|
12
|
-
return true if free_access_action.empty?
|
12
|
+
return true if @current_user.is_arpa_admin? || free_access_action.empty?
|
13
13
|
@session[:entity_permissions] ||= action_finder.permissions(@current_user.profile_ids)
|
14
14
|
@session[:entity_permissions].has_permission?(resource.to_s, action.to_s)
|
15
15
|
end
|
data/lib/arpa/version.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Arpa
|
2
|
+
module Generators
|
3
|
+
class ControllersGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
def copy_resources_views_files
|
7
|
+
copy_file 'views/resources/index.html.erb', 'app/views/arpa/resources/index.html.erb'
|
8
|
+
copy_file 'views/resources/show.html.erb', 'app/views/arpa/resources/show.html.erb'
|
9
|
+
|
10
|
+
copy_file 'views/roles/index.html.erb', 'app/views/arpa/roles/index.html.erb'
|
11
|
+
copy_file 'views/roles/show.html.erb', 'app/views/arpa/roles/show.html.erb'
|
12
|
+
copy_file 'views/roles/new.html.erb', 'app/views/arpa/roles/new.html.erb'
|
13
|
+
copy_file 'views/roles/edit.html.erb', 'app/views/arpa/roles/edit.html.erb'
|
14
|
+
copy_file 'views/roles/_form.html.erb', 'app/views/arpa/roles/_form.html.erb'
|
15
|
+
|
16
|
+
copy_file 'views/profiles/index.html.erb', 'app/views/arpa/profiles/index.html.erb'
|
17
|
+
copy_file 'views/profiles/show.html.erb', 'app/views/arpa/profiles/show.html.erb'
|
18
|
+
copy_file 'views/profiles/new.html.erb', 'app/views/arpa/profiles/new.html.erb'
|
19
|
+
copy_file 'views/profiles/edit.html.erb', 'app/views/arpa/profiles/edit.html.erb'
|
20
|
+
copy_file 'views/profiles/_form.html.erb', 'app/views/arpa/profiles/_form.html.erb'
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_stylesheet_files
|
24
|
+
copy_file 'assets/stylesheets/arpa_accordion.scss', 'app/assets/stylesheets/arpa/arpa_accordion.scss'
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_controllers
|
28
|
+
copy_file 'controllers/resources_controller.rb', 'app/controllers/arpa/resources_controller.rb'
|
29
|
+
copy_file 'controllers/roles_controller.rb', 'app/controllers/arpa/roles_controller.rb'
|
30
|
+
copy_file 'controllers/profiles_controller.rb', 'app/controllers/arpa/profiles_controller.rb'
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_routes
|
34
|
+
route <<-RUBY
|
35
|
+
scope module: :arpa do
|
36
|
+
resources :resources do
|
37
|
+
collection do
|
38
|
+
get 'generate_resources_and_actions'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
resources :roles do
|
43
|
+
collection do
|
44
|
+
delete ':id', to: 'roles#remove'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
resources :profiles do
|
49
|
+
collection do
|
50
|
+
delete ':id', to: 'profiles#remove'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
RUBY
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -5,64 +5,36 @@ module Arpa
|
|
5
5
|
|
6
6
|
source_root File.expand_path("..", __FILE__)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
11
|
-
end
|
8
|
+
desc <<-DESC.strip_heredoc
|
9
|
+
The Name of table to create the associate table.
|
12
10
|
|
13
|
-
|
14
|
-
migration_template 'templates/migration.rb', 'db/migrate/create_arpa_tables.rb'
|
15
|
-
end
|
11
|
+
E.g. users, admins.
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
copy_file '../../arpa/views/resources/show.html.erb', 'app/views/arpa/resources/show.html.erb'
|
13
|
+
By default is 'users'
|
14
|
+
DESC
|
20
15
|
|
21
|
-
|
22
|
-
copy_file '../../arpa/views/roles/show.html.erb', 'app/views/arpa/roles/show.html.erb'
|
23
|
-
copy_file '../../arpa/views/roles/new.html.erb', 'app/views/arpa/roles/new.html.erb'
|
24
|
-
copy_file '../../arpa/views/roles/edit.html.erb', 'app/views/arpa/roles/edit.html.erb'
|
25
|
-
copy_file '../../arpa/views/roles/_form.html.erb', 'app/views/arpa/roles/_form.html.erb'
|
16
|
+
argument :associate_table, required: false
|
26
17
|
|
27
|
-
|
28
|
-
|
29
|
-
copy_file '../../arpa/views/profiles/new.html.erb', 'app/views/arpa/profiles/new.html.erb'
|
30
|
-
copy_file '../../arpa/views/profiles/edit.html.erb', 'app/views/arpa/profiles/edit.html.erb'
|
31
|
-
copy_file '../../arpa/views/profiles/_form.html.erb', 'app/views/arpa/profiles/_form.html.erb'
|
32
|
-
end
|
18
|
+
desc <<-DESC.strip_heredoc
|
19
|
+
The Primary key to create the associate table.
|
33
20
|
|
34
|
-
|
35
|
-
copy_file '../../arpa/assets/stylesheets/arpa_accordion.scss', 'app/assets/stylesheets/arpa/arpa_accordion.scss'
|
36
|
-
end
|
21
|
+
E.g. user_id, admin_id.
|
37
22
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
copy_file '../../arpa/controllers/profiles_controller.rb', 'app/controllers/arpa/profiles_controller.rb'
|
42
|
-
end
|
23
|
+
By default is 'user_id'
|
24
|
+
DESC
|
25
|
+
argument :associate_primary_key, required: false
|
43
26
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
resources :resources do
|
48
|
-
collection do
|
49
|
-
get 'generate_resources_and_actions'
|
27
|
+
def self.next_migration_number(dirname)
|
28
|
+
return Time.new.utc.strftime("%Y%m%d%H%M%S") if ActiveRecord::Base.timestamped_migrations
|
29
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
50
30
|
end
|
51
|
-
end
|
52
31
|
|
53
|
-
|
54
|
-
collection do
|
55
|
-
delete ':id', to: 'roles#remove'
|
56
|
-
end
|
57
|
-
end
|
32
|
+
desc "Create a migrate file with all necessery tables including the associate table."
|
58
33
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
RUBY
|
34
|
+
def create_migrate_files
|
35
|
+
@associate_table ||= 'users'
|
36
|
+
@associate_primary_key ||= "#{@associate_table.singularize}_id"
|
37
|
+
migration_template 'templates/migration.rb', 'db/migrate/create_arpa_tables.rb'
|
66
38
|
end
|
67
39
|
|
68
40
|
def copy_locales
|
File without changes
|
@@ -39,10 +39,12 @@ class CreateArpaTables < ActiveRecord::Migration
|
|
39
39
|
t.index :repository_profile_id, name: 'profile_role_ids'
|
40
40
|
end
|
41
41
|
|
42
|
-
create_join_table :repository_profiles,
|
42
|
+
create_join_table :repository_profiles, <%= ":#{@associate_table}" %>, :force => true do |t|
|
43
43
|
t.index :repository_profile_id, name: 'profile_user_id'
|
44
|
-
t.index
|
44
|
+
t.index <%= ":#{@associate_primary_key}" %>, name: 'user_profile_id'
|
45
45
|
end
|
46
46
|
|
47
|
+
add_column <%= ":#{@associate_table}" %>, :is_arpa_admin, :boolean, default: false
|
48
|
+
|
47
49
|
end
|
48
50
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Arpa::Services::Verifier do
|
4
4
|
let(:session) { {} }
|
5
|
-
let(:current_user) { double profile_ids: [1,2,3] }
|
5
|
+
let(:current_user) { double is_arpa_admin?: false, profile_ids: [1,2,3] }
|
6
6
|
|
7
7
|
subject(:verifier) { Arpa::Services::Verifier.new(session, current_user) }
|
8
8
|
|
@@ -17,6 +17,15 @@ describe Arpa::Services::Verifier do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '#has_access?' do
|
20
|
+
|
21
|
+
context 'when current_user is a arpa admin' do
|
22
|
+
let(:current_user) { double is_arpa_admin?: true, profile_ids: [1,2,3] }
|
23
|
+
|
24
|
+
it 'should has access' do
|
25
|
+
expect(subject.has_access?('home', 'some_action')).to be_truthy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
20
29
|
context 'when pass a free action which begin with "_"' do
|
21
30
|
it 'should has access' do
|
22
31
|
expect(subject.has_access?('home', '_some_action')).to be_truthy
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arpa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rachid Calazans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,20 +142,6 @@ dependencies:
|
|
142
142
|
- - "<"
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '5'
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: responders
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '2.0'
|
152
|
-
type: :runtime
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "~>"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '2.0'
|
159
145
|
description: Authorization Gem for Ruby and Ruby on Rails projects
|
160
146
|
email:
|
161
147
|
- rachidcalazans@gmail.com
|
@@ -176,10 +162,6 @@ files:
|
|
176
162
|
- arpa.gemspec
|
177
163
|
- lib/arpa.rb
|
178
164
|
- lib/arpa/additions/resource.rb
|
179
|
-
- lib/arpa/assets/stylesheets/arpa_accordion.scss
|
180
|
-
- lib/arpa/controllers/profiles_controller.rb
|
181
|
-
- lib/arpa/controllers/resources_controller.rb
|
182
|
-
- lib/arpa/controllers/roles_controller.rb
|
183
165
|
- lib/arpa/data_mappers/action_mapper.rb
|
184
166
|
- lib/arpa/data_mappers/base.rb
|
185
167
|
- lib/arpa/data_mappers/profile_mapper.rb
|
@@ -235,21 +217,26 @@ files:
|
|
235
217
|
- lib/arpa/validators/resource_validator.rb
|
236
218
|
- lib/arpa/validators/role_validator.rb
|
237
219
|
- lib/arpa/version.rb
|
238
|
-
- lib/arpa/views/profiles/_form.html.erb
|
239
|
-
- lib/arpa/views/profiles/edit.html.erb
|
240
|
-
- lib/arpa/views/profiles/index.html.erb
|
241
|
-
- lib/arpa/views/profiles/new.html.erb
|
242
|
-
- lib/arpa/views/profiles/show.html.erb
|
243
|
-
- lib/arpa/views/resources/index.html.erb
|
244
|
-
- lib/arpa/views/resources/show.html.erb
|
245
|
-
- lib/arpa/views/roles/_form.html.erb
|
246
|
-
- lib/arpa/views/roles/edit.html.erb
|
247
|
-
- lib/arpa/views/roles/index.html.erb
|
248
|
-
- lib/arpa/views/roles/new.html.erb
|
249
|
-
- lib/arpa/views/roles/show.html.erb
|
250
220
|
- lib/config/locales/arpa.en.yml
|
221
|
+
- lib/generators/arpa/controllers_generator.rb
|
251
222
|
- lib/generators/arpa/install_generator.rb
|
223
|
+
- lib/generators/arpa/templates/assets/stylesheets/arpa_accordion.scss
|
224
|
+
- lib/generators/arpa/templates/controllers/profiles_controller.rb
|
225
|
+
- lib/generators/arpa/templates/controllers/resources_controller.rb
|
226
|
+
- lib/generators/arpa/templates/controllers/roles_controller.rb
|
252
227
|
- lib/generators/arpa/templates/migration.rb
|
228
|
+
- lib/generators/arpa/templates/views/profiles/_form.html.erb
|
229
|
+
- lib/generators/arpa/templates/views/profiles/edit.html.erb
|
230
|
+
- lib/generators/arpa/templates/views/profiles/index.html.erb
|
231
|
+
- lib/generators/arpa/templates/views/profiles/new.html.erb
|
232
|
+
- lib/generators/arpa/templates/views/profiles/show.html.erb
|
233
|
+
- lib/generators/arpa/templates/views/resources/index.html.erb
|
234
|
+
- lib/generators/arpa/templates/views/resources/show.html.erb
|
235
|
+
- lib/generators/arpa/templates/views/roles/_form.html.erb
|
236
|
+
- lib/generators/arpa/templates/views/roles/edit.html.erb
|
237
|
+
- lib/generators/arpa/templates/views/roles/index.html.erb
|
238
|
+
- lib/generators/arpa/templates/views/roles/new.html.erb
|
239
|
+
- lib/generators/arpa/templates/views/roles/show.html.erb
|
253
240
|
- spec/factories/repository_actions.rb
|
254
241
|
- spec/factories/repository_profiles.rb
|
255
242
|
- spec/factories/repository_resources.rb
|