voltex 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +154 -0
  3. data/Rakefile +1 -1
  4. data/lib/voltex/version.rb +1 -1
  5. metadata +22 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e670d0917034aa52407212065d3d8e21a1b7308
4
- data.tar.gz: 2ff3dc581a86984951ae557d94f90d09ad3dd922
3
+ metadata.gz: 5cfc96e3f591dcffa4d5118a19ba8f93a577b562
4
+ data.tar.gz: 8b5c5e101cf8a4f00d22ad5f21b1b57452749394
5
5
  SHA512:
6
- metadata.gz: 66a73c70bed244afb603325830c81845beefc9829292b359aa01c3978a48a693d359ab6cc10c187b56eeaea6a446d66d7627355da67381ec031dfb5df9639760
7
- data.tar.gz: 8f1ed3f14937ca80439990b87c136929313dd9d849e31f76ebe22cf2d58193485379cf8ec3702925222b1f6cbb9876dcbfe263f7c2c79a251ed773000b8e0b33
6
+ metadata.gz: 0158489ca3fbde74c60bb58466505f225fff4fbdb22057b0741a36def2dbbcd3cfbfcd67888b2375fe3fb091d0b80eea1b35a20eff5be5c837bff74f7ef60646
7
+ data.tar.gz: ec5e3f9f3c11128579353550178373272c193f8af1ac2706f9df3072f0b71ac65decc31a12e6b4a6900ce46b004d9ec1430aeecf44083b5c239f5640447fa4a4
@@ -0,0 +1,154 @@
1
+ # Voltex
2
+ This engine aims to provide an easy way to work with dynamic permissions.
3
+
4
+
5
+ ## Compatibility
6
+ * Rails 4+
7
+ * ActiveRecord 4+
8
+ * Ruby 2+
9
+
10
+
11
+ ## Installation
12
+ 1. Add Voltex to your Gemfile.
13
+
14
+ ```ruby
15
+ gem 'voltex'
16
+ ```
17
+
18
+ 2. Generate voltex initializer.
19
+
20
+ ```
21
+ bundle exec rails g voltex:install
22
+ ```
23
+
24
+ 3. Update initializer according your needs.
25
+
26
+ ```ruby
27
+ Voltex.setup do |config|
28
+ # Voltex classes configuration.
29
+ # config.user_class = 'User'
30
+ # config.role_class = 'Role'
31
+ # config.permission_class = 'Permission'
32
+ ...
33
+ end
34
+ ```
35
+
36
+ 4. Generate voltex resources.
37
+
38
+ ```
39
+ bundle exec rails g voltex:resources
40
+ ```
41
+
42
+ 5. Migrate your database.
43
+
44
+ ```
45
+ bundle exec rake db:migrate
46
+ ```
47
+
48
+ 6. Create default permissions.
49
+
50
+ ```
51
+ bundle exec rake voltex
52
+ ```
53
+
54
+ 7. Load current user permissions in your application controller.
55
+
56
+ ```ruby
57
+ class ApplicationController < ActionController::Base
58
+ ...
59
+ before_action :set_current_permissions
60
+ end
61
+ ```
62
+
63
+ By default this callback preloads permissions for `current_user` if this
64
+ is defined. If you need that this callback preloads permission for
65
+ another user just overwrite `voltex_user` method.
66
+
67
+ Example:
68
+ ```ruby
69
+ class ApplicationController < ActionController::Base
70
+ ...
71
+ def voltex_user
72
+ # Default is current_user.
73
+ another_awesome_user
74
+ end
75
+ end
76
+ ```
77
+
78
+
79
+ ## Using Voltex with Pundit
80
+ Include voltex in your application policy.
81
+ ```ruby
82
+ require 'voltex/pundit'
83
+
84
+ class ApplicationPolicy
85
+ include Voltex::Pundit
86
+ end
87
+ ```
88
+ Now a new helper is available in your policies.
89
+ ```ruby
90
+ class PostPolicy
91
+ def index?
92
+ permission?(Post, :index)
93
+ end
94
+ end
95
+ ```
96
+
97
+
98
+ ## Using Voltex with CanCan
99
+ Include voltex in your ability class.
100
+ ```ruby
101
+ require 'voltex/cancan/ability'
102
+
103
+ class Ability
104
+ include CanCan::Ability
105
+ include Voltex::CanCan::Ability
106
+
107
+ def initialize(user)
108
+ define_voltex_abilities(user)
109
+ end
110
+ end
111
+ ```
112
+
113
+
114
+ ## Including and Excluding permissions
115
+ Update your voltex initializer:
116
+ ```ruby
117
+ Voltex.setup do |config|
118
+ # Voltex classes configuration.
119
+ # config.user_class = 'User'
120
+ # config.role_class = 'Role'
121
+ # config.permission_class = 'Permission'
122
+ #
123
+ # Excluding default permissions.
124
+ config.exclude = [
125
+ { resource: 'Payment', action: 'destroy' },
126
+ { resource: 'Post', action: 'update' },
127
+ ]
128
+ #
129
+ # Including other permissions.
130
+ config.include = [
131
+ { resource: 'User', action: 'enable' },
132
+ { resource: 'User', action: 'disable' },
133
+ ]
134
+ end
135
+ ```
136
+ And run voltex rake task again:
137
+ ```
138
+ bundle exec rake voltex
139
+ ```
140
+
141
+
142
+ ## Defining role permissions
143
+ Mount voltex engine in your application:
144
+ ```ruby
145
+ Rails.application.routes.draw do
146
+ mount Voltex::Engine => '/voltex'
147
+ end
148
+ ```
149
+ Run voltex views generator:
150
+ ```
151
+ bundle exec rails g voltex:views
152
+ ```
153
+ This will define a route `/voltex/roles/:id/edit` where
154
+ permissions can be defined for each role.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
10
10
  rdoc.rdoc_dir = 'rdoc'
11
11
  rdoc.title = 'Voltex'
12
12
  rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
13
+ rdoc.rdoc_files.include('README.md')
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module Voltex
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voltex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erick Fabian
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-01 00:00:00.000000000 Z
12
+ date: 2016-03-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,98 +17,98 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: '4.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: '4.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: request_store
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 1.1.0
34
+ version: '1.3'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 1.1.0
41
+ version: '1.3'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: sqlite3
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: '1.3'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: '1.3'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec-rails
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '3.2'
62
+ version: '3.4'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '3.2'
69
+ version: '3.4'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: cucumber
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 2.0.0
76
+ version: '2.3'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 2.0.0
83
+ version: '2.3'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: aruba
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 0.6.2
90
+ version: '0.14'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 0.6.2
97
+ version: '0.14'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: cancan
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 1.6.10
104
+ version: '1.6'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 1.6.10
111
+ version: '1.6'
112
112
  description: This engine aims to provide an easy way to work with dynamic permissions.
113
113
  email:
114
114
  - fabianerickalfonso@gmail.com
@@ -118,6 +118,7 @@ extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
120
  - MIT-LICENSE
121
+ - README.md
121
122
  - Rakefile
122
123
  - app/controllers/voltex/application_controller.rb
123
124
  - app/controllers/voltex/roles_controller.rb
@@ -148,7 +149,7 @@ files:
148
149
  - lib/voltex/scope.rb
149
150
  - lib/voltex/setup.rb
150
151
  - lib/voltex/version.rb
151
- homepage: ''
152
+ homepage: https://github.com/SyeSoftware/voltex
152
153
  licenses:
153
154
  - MIT
154
155
  metadata: {}
@@ -160,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
161
  requirements:
161
162
  - - ">="
162
163
  - !ruby/object:Gem::Version
163
- version: '0'
164
+ version: 2.0.0
164
165
  required_rubygems_version: !ruby/object:Gem::Requirement
165
166
  requirements:
166
167
  - - ">="
@@ -168,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  version: '0'
169
170
  requirements: []
170
171
  rubyforge_project:
171
- rubygems_version: 2.4.8
172
+ rubygems_version: 2.5.1
172
173
  signing_key:
173
174
  specification_version: 4
174
175
  summary: Dynamic permissions authorization.