papers_please 0.0.3.beta → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +7 -3
- data/README.md +68 -41
- data/Rakefile +3 -3
- data/bin/console +4 -3
- data/lib/papers_please/errors.rb +5 -0
- data/lib/papers_please/permission.rb +42 -6
- data/lib/papers_please/policy.rb +28 -2
- data/lib/papers_please/rails/controller_methods.rb +25 -0
- data/lib/papers_please/railtie.rb +23 -0
- data/lib/papers_please/role.rb +19 -7
- data/lib/papers_please/version.rb +1 -1
- data/lib/papers_please.rb +38 -1
- data/papers_please.gemspec +16 -15
- metadata +36 -21
- data/.byebug_history +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c2eae718044ec1bc5ae95e4a7cadb9bd5046cd8e
|
4
|
+
data.tar.gz: '0759782832b9706d6c59cdde394035731372d1d8'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc8356f4e7dc50c80a9d754a5b6e411448dcaad7e1a3f05d4016f3d89a6999837b0528b74b584648367f6b233589fcfea0994e5e6116dd7daef580138e4f2b98
|
7
|
+
data.tar.gz: e13e12d51105db39fb14c72d6999e80d5d099f511afc4bcabc82c668bc018f5c414ecd33f0fbc146f12430e328739c364bd2ed5f869b37b460cd4907f90030c6
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in papers_please.gemspec
|
6
6
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
papers_please (0.0
|
4
|
+
papers_please (0.1.0)
|
5
|
+
terminal-table
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
@@ -29,12 +30,15 @@ GEM
|
|
29
30
|
json (>= 1.8, < 3)
|
30
31
|
simplecov-html (~> 0.10.0)
|
31
32
|
simplecov-html (0.10.2)
|
33
|
+
terminal-table (1.8.0)
|
34
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
35
|
+
unicode-display_width (1.4.0)
|
32
36
|
|
33
37
|
PLATFORMS
|
34
38
|
ruby
|
35
39
|
|
36
40
|
DEPENDENCIES
|
37
|
-
bundler (~>
|
41
|
+
bundler (~> 2.0)
|
38
42
|
byebug
|
39
43
|
papers_please!
|
40
44
|
rake (~> 10.0)
|
@@ -42,4 +46,4 @@ DEPENDENCIES
|
|
42
46
|
simplecov
|
43
47
|
|
44
48
|
BUNDLED WITH
|
45
|
-
|
49
|
+
2.0.1
|
data/README.md
CHANGED
@@ -4,41 +4,40 @@ A roles and permissions gem from Apsis Labs.
|
|
4
4
|
|
5
5
|
**NOTE**: Still under heavy development, definitely not suitable for anything remotely resembling production usage. Very unlikely to even work.
|
6
6
|
|
7
|
+
|
7
8
|
## Example
|
8
9
|
|
9
10
|
```ruby
|
10
11
|
# app/policies/access_policy.rb
|
11
12
|
class AccessPolicy < PapersPlease::Policy
|
12
13
|
def configure
|
13
|
-
# Define
|
14
|
-
role :
|
15
|
-
|
14
|
+
# Define your roles
|
15
|
+
role :super, (proc { |u| u.super? })
|
16
|
+
role :admin, (proc { |u| u.admin? })
|
17
|
+
role :member, (proc { |u| u.member? })
|
18
|
+
role :guest
|
19
|
+
|
20
|
+
permit :super do |role|
|
21
|
+
role.grant [:manage], User
|
16
22
|
end
|
17
23
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# Define a role with no predicate
|
22
|
-
role :guest do
|
23
|
-
grant [:read], Post, predicate: (proc { |u, post| !post.archived? })
|
24
|
+
permit :admin, :super do |role|
|
25
|
+
role.grant [:manage, :archive], Post
|
24
26
|
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# app/policies/roles/member_role.rb
|
29
|
-
class MemberRole < PapersPlease::Role
|
30
|
-
predicate { |user| user.member? }
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
permit :member do |role|
|
29
|
+
role.grant [:create], Post
|
30
|
+
role.grant [:update, :read], Post, query: (proc { |u| u.posts })
|
31
|
+
role.grant [:archive], Post, query: (proc { |u| u.posts }), predicate: (proc { |u, post| !post.archived? })
|
32
|
+
end
|
37
33
|
|
38
|
-
|
34
|
+
permit :guest do |role|
|
35
|
+
role.grant [:read], Post, predicate: (proc { |u, post| !post.archived? })
|
36
|
+
end
|
39
37
|
|
40
|
-
|
41
|
-
|
38
|
+
permit :member, :guest do |role|
|
39
|
+
role.grant [:read], Attachment, granted_by: [Post, (proc { |u, attachment| attachment.post })]
|
40
|
+
end
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
@@ -67,6 +66,16 @@ class PostsController < ApplicationController
|
|
67
66
|
render json: @post
|
68
67
|
end
|
69
68
|
end
|
69
|
+
|
70
|
+
class AttachmentsController < ApplicationController
|
71
|
+
# GET /attachments/:id
|
72
|
+
def show
|
73
|
+
@attachment = Attachment.find([:id])
|
74
|
+
policy.authorize! :read, @attachment # => proxied to Post permission check
|
75
|
+
|
76
|
+
send_data @attachment.data, type: @attachment.content_type
|
77
|
+
end
|
78
|
+
end
|
70
79
|
```
|
71
80
|
|
72
81
|
## A helpful CLI
|
@@ -75,24 +84,34 @@ end
|
|
75
84
|
$ rails papers_please:roles
|
76
85
|
|
77
86
|
# =>
|
78
|
-
#
|
79
|
-
# |
|
80
|
-
#
|
81
|
-
# |
|
82
|
-
# | |
|
83
|
-
# | |
|
84
|
-
# | |
|
85
|
-
# | |
|
86
|
-
# |
|
87
|
-
# | |
|
88
|
-
# | |
|
89
|
-
#
|
90
|
-
# |
|
91
|
-
# |
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
#
|
87
|
+
# +---------+------------+------------+------------+----------------+-------------------+
|
88
|
+
# | role | subject | permission | has query? | has predicate? | granted by other? |
|
89
|
+
# +---------+------------+------------+------------+----------------+-------------------+
|
90
|
+
# | admin | Post | create | yes | yes | no |
|
91
|
+
# | | Post | read | yes | yes | no |
|
92
|
+
# | | Post | update | yes | yes | no |
|
93
|
+
# | | Post | destroy | yes | yes | no |
|
94
|
+
# | | Attachment | create | yes | yes | no |
|
95
|
+
# | | Attachment | read | yes | yes | no |
|
96
|
+
# | | Attachment | update | yes | yes | no |
|
97
|
+
# | | Attachment | destroy | yes | yes | no |
|
98
|
+
# +---------+------------+------------+------------+----------------+-------------------+
|
99
|
+
# | manager | Post | create | yes | yes | no |
|
100
|
+
# | | Post | read | yes | yes | no |
|
101
|
+
# | | Post | update | yes | yes | no |
|
102
|
+
# | | Post | destroy | yes | yes | no |
|
103
|
+
# | | Attachment | create | yes | yes | yes |
|
104
|
+
# | | Attachment | read | yes | yes | yes |
|
105
|
+
# | | Attachment | update | yes | yes | yes |
|
106
|
+
# | | Attachment | destroy | yes | yes | yes |
|
107
|
+
# +---------+------------+------------+------------+----------------+-------------------+
|
108
|
+
# | member | Post | create | yes | yes | no |
|
109
|
+
# | | Post | read | yes | yes | no |
|
110
|
+
# | | Post | update | yes | yes | no |
|
111
|
+
# | | Attachment | create | yes | yes | yes |
|
112
|
+
# | | Attachment | read | yes | yes | yes |
|
113
|
+
# | | Attachment | update | yes | yes | yes |
|
114
|
+
# +---------+------------+------------+------------+----------------+-------------------+
|
96
115
|
```
|
97
116
|
|
98
117
|
## Installation
|
@@ -141,3 +160,11 @@ This owes its existence to [`AccessGranted`](https://github.com/chaps-io/access-
|
|
141
160
|
## License
|
142
161
|
|
143
162
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
163
|
+
|
164
|
+
---
|
165
|
+
|
166
|
+
# Built by Apsis
|
167
|
+
|
168
|
+
[![apsis](https://s3-us-west-2.amazonaws.com/apsiscdn/apsis.png)](https://www.apsis.io)
|
169
|
+
|
170
|
+
`papers_please` was built by Apsis Labs. We love sharing what we build! Check out our [other libraries on Github](https://github.com/apsislabs), and if you like our work you can [hire us](https://www.apsis.io/work-with-us/) to build your vision.
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'papers_please'
|
5
|
+
Dir['spec/fixtures/**/*.rb'].each { |f| require File.expand_path(f) }
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "papers_please"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/lib/papers_please/errors.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
module PapersPlease
|
2
2
|
class Permission
|
3
|
-
attr_accessor :key, :subject, :query, :predicate
|
3
|
+
attr_accessor :key, :subject, :query, :predicate, :granted_by, :granting_class
|
4
4
|
|
5
|
-
def initialize(key, subject, query: nil, predicate: nil)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def initialize(key, subject, query: nil, predicate: nil, granted_by: nil, granting_class: nil)
|
6
|
+
self.key = key
|
7
|
+
self.subject = subject
|
8
|
+
self.query = query
|
9
|
+
self.predicate = predicate
|
10
|
+
self.granted_by = granted_by
|
11
|
+
self.granting_class = granting_class
|
12
|
+
end
|
13
|
+
|
14
|
+
def granted_by_other?
|
15
|
+
@granting_class.is_a?(Class) && @granted_by.is_a?(Proc)
|
10
16
|
end
|
11
17
|
|
12
18
|
def matches?(key, subject)
|
@@ -15,14 +21,44 @@ module PapersPlease
|
|
15
21
|
|
16
22
|
def granted?(*args)
|
17
23
|
return predicate.call(*args) if predicate.is_a? Proc
|
24
|
+
|
25
|
+
# :nocov:
|
26
|
+
# as far as we can tell this line is unreachable, but just in case...
|
18
27
|
false
|
28
|
+
# :nocov:
|
19
29
|
end
|
20
30
|
|
21
31
|
def fetch(*args)
|
22
32
|
return query.call(*args) if query.is_a? Proc
|
33
|
+
|
23
34
|
nil
|
24
35
|
end
|
25
36
|
|
37
|
+
# Setters
|
38
|
+
def query=(val)
|
39
|
+
raise ArgumentError, "query must be a Proc, #{val.class} given" if val && !val.is_a?(Proc)
|
40
|
+
|
41
|
+
@query = val
|
42
|
+
end
|
43
|
+
|
44
|
+
def predicate=(val)
|
45
|
+
raise ArgumentError, "predicate must be a Proc, #{val.class} given" if val && !val.is_a?(Proc)
|
46
|
+
|
47
|
+
@predicate = val
|
48
|
+
end
|
49
|
+
|
50
|
+
def granted_by=(val)
|
51
|
+
raise ArgumentError, "granted_by must be a Proc, #{val.class} given" if val && !val.is_a?(Proc)
|
52
|
+
|
53
|
+
@granted_by = val
|
54
|
+
end
|
55
|
+
|
56
|
+
def granting_class=(val)
|
57
|
+
raise ArgumentError, "granting_class must be a Class, #{val.class} given" if val && !val.is_a?(Class)
|
58
|
+
|
59
|
+
@granting_class = val
|
60
|
+
end
|
61
|
+
|
26
62
|
private
|
27
63
|
|
28
64
|
def key_matches?(key)
|
data/lib/papers_please/policy.rb
CHANGED
@@ -12,7 +12,7 @@ module PapersPlease
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def configure
|
15
|
-
raise NotImplementedError,
|
15
|
+
raise NotImplementedError, 'The #configure method of the access policy was not implemented'
|
16
16
|
end
|
17
17
|
|
18
18
|
# Add a role to the Policy
|
@@ -27,11 +27,35 @@ module PapersPlease
|
|
27
27
|
end
|
28
28
|
alias role add_role
|
29
29
|
|
30
|
+
# Add permissions to the Role
|
31
|
+
def add_permissions(keys)
|
32
|
+
return unless block_given?
|
33
|
+
|
34
|
+
Array(keys).each do |key|
|
35
|
+
raise MissingRole unless roles.key?(key)
|
36
|
+
|
37
|
+
yield roles[key]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
alias permit add_permissions
|
41
|
+
|
30
42
|
# Look up a stored permission block and call with
|
31
43
|
# the current user and subject
|
32
44
|
def can?(action, subject = nil)
|
33
45
|
applicable_roles.each do |_, role|
|
34
46
|
permission = role.find_permission(action, subject)
|
47
|
+
next if permission.nil?
|
48
|
+
|
49
|
+
# Proxy permission check if granted by other
|
50
|
+
if permission.granted_by_other?
|
51
|
+
# Get proxied subject
|
52
|
+
subject = subject.is_a?(Class) ? permission.granting_class : permission.granted_by.call(user, subject)
|
53
|
+
|
54
|
+
# Get proxied permission
|
55
|
+
permission = role.find_permission(action, subject)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Check permission
|
35
59
|
return permission.granted?(user, subject, action) unless permission.nil?
|
36
60
|
end
|
37
61
|
|
@@ -43,7 +67,8 @@ module PapersPlease
|
|
43
67
|
end
|
44
68
|
|
45
69
|
def authorize!(action, subject)
|
46
|
-
raise AccessDenied
|
70
|
+
raise AccessDenied, "Access denied for #{action} on #{subject}" if cannot?(action, subject)
|
71
|
+
|
47
72
|
subject
|
48
73
|
end
|
49
74
|
|
@@ -57,6 +82,7 @@ module PapersPlease
|
|
57
82
|
|
58
83
|
nil
|
59
84
|
end
|
85
|
+
alias query scope_for
|
60
86
|
|
61
87
|
# Fetch roles that apply to the current user
|
62
88
|
def applicable_roles
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module PapersPlease
|
2
|
+
module Rails
|
3
|
+
module ControllerMethods
|
4
|
+
def self.included(base)
|
5
|
+
base.helper_method :can?, :cannot?, :policy if base.respond_to? :helper_method
|
6
|
+
end
|
7
|
+
|
8
|
+
def policy
|
9
|
+
@policy ||= ::PapersPlease.new(current_user)
|
10
|
+
end
|
11
|
+
|
12
|
+
def can?(*args)
|
13
|
+
policy.can?(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def cannot?(*args)
|
17
|
+
policy.cannot?(*args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorize!(*args)
|
21
|
+
policy.authorize!(*args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
|
3
|
+
module PapersPlease
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
rake_tasks do
|
6
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/*.rake')].each { |f| load f }
|
7
|
+
end
|
8
|
+
|
9
|
+
initializer :papers_plesae do
|
10
|
+
if defined? ActionController::Base
|
11
|
+
ActionController::Base.class_eval do
|
12
|
+
include PapersPlease::Rails::ControllerMethods
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if defined? ActionController::API
|
17
|
+
ActionController::API.class_eval do
|
18
|
+
include PapersPlease::Rails::ControllerMethods
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/papers_please/role.rb
CHANGED
@@ -6,23 +6,28 @@ module PapersPlease
|
|
6
6
|
@name = name
|
7
7
|
@predicate = predicate
|
8
8
|
@permissions = []
|
9
|
-
|
10
|
-
instance_eval(&definition) unless definition.nil?
|
11
9
|
end
|
12
10
|
|
13
11
|
def applies_to?(user)
|
14
12
|
return @predicate.call(user) if @predicate.is_a? Proc
|
13
|
+
|
15
14
|
true
|
16
15
|
end
|
17
16
|
|
18
|
-
def add_permission(actions, klass, query: nil, predicate: nil)
|
17
|
+
def add_permission(actions, klass, query: nil, predicate: nil, granted_by: nil)
|
19
18
|
prepare_actions(actions).each do |action|
|
20
19
|
raise DuplicatePermission if permission_exists?(action, klass)
|
20
|
+
raise InvalidGrant, 'granted_by must be an array of [Class, Proc]' if !granted_by.nil? && !valid_grant?(granted_by)
|
21
21
|
|
22
22
|
has_query = query.is_a?(Proc)
|
23
23
|
has_predicate = predicate.is_a?(Proc)
|
24
24
|
permission = Permission.new(action, klass)
|
25
25
|
|
26
|
+
if granted_by
|
27
|
+
permission.granting_class = granted_by[0]
|
28
|
+
permission.granted_by = granted_by[1]
|
29
|
+
end
|
30
|
+
|
26
31
|
if has_query && has_predicate
|
27
32
|
# Both query & predicate provided
|
28
33
|
|
@@ -30,7 +35,6 @@ module PapersPlease
|
|
30
35
|
permission.predicate = predicate
|
31
36
|
elsif has_query && !has_predicate
|
32
37
|
# Only query provided
|
33
|
-
|
34
38
|
permission.query = query
|
35
39
|
|
36
40
|
if action == :create && actions == :manage
|
@@ -47,7 +51,6 @@ module PapersPlease
|
|
47
51
|
end
|
48
52
|
elsif !has_query && has_predicate
|
49
53
|
# Only predicate provided
|
50
|
-
|
51
54
|
permission.predicate = predicate
|
52
55
|
else
|
53
56
|
# Neither provided
|
@@ -72,10 +75,19 @@ module PapersPlease
|
|
72
75
|
|
73
76
|
private
|
74
77
|
|
78
|
+
def valid_grant?(tuple)
|
79
|
+
return false unless tuple.is_a? Array
|
80
|
+
return false unless tuple.length == 2
|
81
|
+
return false unless tuple[0].is_a? Class
|
82
|
+
return false unless tuple[1].is_a? Proc
|
83
|
+
|
84
|
+
true
|
85
|
+
end
|
86
|
+
|
75
87
|
# Wrap actions, translating :manage into :crud
|
76
88
|
def prepare_actions(action)
|
77
|
-
Array(
|
78
|
-
a == :manage ? [
|
89
|
+
Array(action).flat_map do |a|
|
90
|
+
a == :manage ? %i[create read update destroy] : [a]
|
79
91
|
end
|
80
92
|
end
|
81
93
|
end
|
data/lib/papers_please.rb
CHANGED
@@ -3,7 +3,44 @@ require 'papers_please/errors'
|
|
3
3
|
require 'papers_please/policy'
|
4
4
|
require 'papers_please/role'
|
5
5
|
require 'papers_please/permission'
|
6
|
+
require 'papers_please/railtie' if defined? Rails
|
6
7
|
|
7
8
|
module PapersPlease
|
8
|
-
|
9
|
+
def self.permissions_table(policy_klass)
|
10
|
+
require 'terminal-table'
|
11
|
+
|
12
|
+
policy = policy_klass.new(:system)
|
13
|
+
|
14
|
+
table = ::Terminal::Table.new do |t|
|
15
|
+
t.headings = [
|
16
|
+
'role',
|
17
|
+
'subject',
|
18
|
+
'permission',
|
19
|
+
'has query?',
|
20
|
+
'has predicate?',
|
21
|
+
'granted by other?'
|
22
|
+
]
|
23
|
+
|
24
|
+
policy.roles.each_with_index do |(name, role), index|
|
25
|
+
t.add_separator unless index.zero?
|
26
|
+
first_line_of_role = true
|
27
|
+
|
28
|
+
role.permissions.group_by(&:subject).each do |subject, permissions|
|
29
|
+
permissions.each do |permission|
|
30
|
+
t.add_row [
|
31
|
+
first_line_of_role ? name : nil,
|
32
|
+
subject,
|
33
|
+
permission.key,
|
34
|
+
permission.query ? 'yes' : 'no',
|
35
|
+
permission.predicate ? 'yes' : 'no',
|
36
|
+
permission.granted_by_other? ? 'yes' : 'no',
|
37
|
+
]
|
38
|
+
|
39
|
+
first_line_of_role = false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
puts table
|
45
|
+
end
|
9
46
|
end
|
data/papers_please.gemspec
CHANGED
@@ -1,29 +1,30 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require 'papers_please/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'papers_please'
|
8
7
|
spec.version = PapersPlease::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['Apsis Labs']
|
9
|
+
spec.email = ['wyatt@apsis.io']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
11
|
+
spec.summary = 'A roles & permissions gem for ruby applications.'
|
12
|
+
spec.homepage = 'http://apsis.io'
|
13
|
+
spec.license = 'MIT'
|
15
14
|
|
16
15
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
16
|
f.match(%r{^(test|spec|features)/})
|
18
17
|
end
|
19
18
|
|
20
|
-
spec.bindir =
|
19
|
+
spec.bindir = 'exe'
|
21
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'terminal-table'
|
23
24
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
25
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
|
+
spec.add_development_dependency 'byebug'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
29
|
spec.add_development_dependency 'simplecov'
|
29
30
|
end
|
metadata
CHANGED
@@ -1,71 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: papers_please
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apsis Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: terminal-table
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '2.0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '2.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: byebug
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '10.0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '10.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
75
|
+
version: '3.0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
82
|
+
version: '3.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: simplecov
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,7 +101,6 @@ executables: []
|
|
87
101
|
extensions: []
|
88
102
|
extra_rdoc_files: []
|
89
103
|
files:
|
90
|
-
- ".byebug_history"
|
91
104
|
- ".gitignore"
|
92
105
|
- ".rspec"
|
93
106
|
- ".travis.yml"
|
@@ -102,6 +115,8 @@ files:
|
|
102
115
|
- lib/papers_please/errors.rb
|
103
116
|
- lib/papers_please/permission.rb
|
104
117
|
- lib/papers_please/policy.rb
|
118
|
+
- lib/papers_please/rails/controller_methods.rb
|
119
|
+
- lib/papers_please/railtie.rb
|
105
120
|
- lib/papers_please/role.rb
|
106
121
|
- lib/papers_please/version.rb
|
107
122
|
- papers_please.gemspec
|
@@ -120,12 +135,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
135
|
version: '0'
|
121
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
137
|
requirements:
|
123
|
-
- - "
|
138
|
+
- - ">="
|
124
139
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
140
|
+
version: '0'
|
126
141
|
requirements: []
|
127
142
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.6.13
|
129
144
|
signing_key:
|
130
145
|
specification_version: 4
|
131
146
|
summary: A roles & permissions gem for ruby applications.
|
data/.byebug_history
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
q
|
2
|
-
@policy
|
3
|
-
q
|
4
|
-
permission
|
5
|
-
c
|
6
|
-
permission
|
7
|
-
c
|
8
|
-
permission
|
9
|
-
c
|
10
|
-
permission
|
11
|
-
q
|
12
|
-
res.include?(obj)
|
13
|
-
posts.include?(obj)
|
14
|
-
posts.include(obj)
|
15
|
-
res
|
16
|
-
obj
|
17
|
-
c
|
18
|
-
obj
|
19
|
-
res.include?(obj)
|
20
|
-
res.include?
|
21
|
-
res
|
22
|
-
c
|
23
|
-
u.posts
|
24
|
-
u
|
25
|
-
c
|
26
|
-
u
|
27
|
-
c
|
28
|
-
role
|
29
|
-
q
|
30
|
-
role
|
31
|
-
q
|
32
|
-
applicable_roles.count
|
33
|
-
applicable_roles
|
34
|
-
c
|
35
|
-
q
|
36
|
-
@user
|
37
|
-
role.applies_to?(@user)
|
38
|
-
role
|
39
|
-
c
|
40
|
-
q
|
41
|
-
applicable_roles
|
42
|
-
c
|
43
|
-
q
|
44
|
-
klass
|
45
|
-
action
|
46
|
-
permissions
|
47
|
-
permission_exists?(action, klass)
|
48
|
-
action
|
49
|
-
q
|
50
|
-
n
|
51
|
-
s
|
52
|
-
actions
|
53
|
-
c
|
54
|
-
n
|
55
|
-
role
|
56
|
-
c
|
57
|
-
n
|
58
|
-
roles.key?(:admin)
|
59
|
-
roles
|
60
|
-
name
|