permisi 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +46 -0
- data/.rubocop.yml +9 -0
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +25 -0
- data/Gemfile.lock +7 -7
- data/README.md +2 -8
- data/lib/generators/permisi/install_generator.rb +6 -6
- data/lib/generators/permisi/templates/initializer.rb +2 -0
- data/lib/permisi.rb +13 -19
- data/lib/permisi/actable.rb +2 -0
- data/lib/permisi/backend.rb +27 -0
- data/lib/permisi/backend/active_record.rb +17 -13
- data/lib/permisi/backend/active_record/actor.rb +18 -9
- data/lib/permisi/backend/active_record/actor_role.rb +17 -3
- data/lib/permisi/backend/active_record/role.rb +31 -17
- data/lib/permisi/backend/mongoid.rb +6 -2
- data/lib/permisi/config.rb +8 -6
- data/lib/permisi/permission_util.rb +22 -16
- data/lib/permisi/version.rb +1 -1
- data/permisi.gemspec +2 -2
- metadata +8 -8
- data/.github/workflows/main.yml +0 -18
- data/lib/permisi/backend/base.rb +0 -6
- data/lib/permisi/backend/invalid_backend.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50d92f00f694bb0b93a36125736bbd3afae15446c6fe5c71e0a83027a136c5e8
|
4
|
+
data.tar.gz: f214d63982175a708e99f7c9238a778b10ec4b599b8baed0dbf09e62a3ad0ae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea1cedd52afd42383027297028974947aa338eff64d0bb12daee7f3e73663dc054c983f792f6ec8a917f2273745cbb212ea17d12271d11de003a509f53111803
|
7
|
+
data.tar.gz: 395586b6b62fdedfe3c9ffc0ea824868cf27d76922af4a7501f161eabd06561c9d44d251a114685552e4d5a37c50923b721621d212ef3d956f98a025e93f4649
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Lint and test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
|
16
|
+
- name: Set up Ruby 2.7
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.7
|
20
|
+
|
21
|
+
- name: Generate lockfile for cache key
|
22
|
+
run: bundle lock
|
23
|
+
|
24
|
+
- name: Cache gems
|
25
|
+
uses: actions/cache@v1
|
26
|
+
with:
|
27
|
+
path: vendor/bundle
|
28
|
+
key: ${{ runner.os }}-rspec-${{ hashFiles('**/Gemfile.lock') }}
|
29
|
+
restore-keys: |
|
30
|
+
${{ runner.os }}-rspec-
|
31
|
+
|
32
|
+
- name: Install gems
|
33
|
+
run: |
|
34
|
+
bundle config path vendor/bundle
|
35
|
+
bundle install --jobs 4 --retry 3
|
36
|
+
|
37
|
+
- name: Run RuboCop
|
38
|
+
uses: reviewdog/action-rubocop@v1
|
39
|
+
with:
|
40
|
+
rubocop_version: gemfile
|
41
|
+
rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile
|
42
|
+
github_token: ${{ secrets.github_token }}
|
43
|
+
reporter: github-pr-check # Default is github-pr-check
|
44
|
+
|
45
|
+
- name: Run RSpec
|
46
|
+
run: bundle exec rake spec
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.4
|
3
|
+
NewCops: enable
|
4
|
+
Exclude:
|
5
|
+
- "lib/generators/**/*"
|
6
|
+
- "spec/**/*" # stuff for later
|
7
|
+
- "lib/permisi/permission_util.rb" # The necessary evil (for now)
|
3
8
|
|
4
9
|
Style/StringLiterals:
|
5
10
|
Enabled: true
|
@@ -11,3 +16,7 @@ Style/StringLiteralsInInterpolation:
|
|
11
16
|
|
12
17
|
Layout/LineLength:
|
13
18
|
Max: 120
|
19
|
+
|
20
|
+
# Stuff for later
|
21
|
+
Documentation:
|
22
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# How to contribute
|
2
|
+
|
3
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ukazap/permisi/blob/master/CODE_OF_CONDUCT.md).
|
4
|
+
|
5
|
+
## Found a bug?
|
6
|
+
|
7
|
+
- Search the [issues labeled "bug"](https://github.com/ukazap/permisi/issues?q=is%3Aissue+label%3Abug) to see if it's already reported.
|
8
|
+
- Make sure you are using the latest version of Permisi [](https://badge.fury.io/rb/permisi)
|
9
|
+
- If you are still having an issue, create an issue including:
|
10
|
+
- Ruby version
|
11
|
+
- Gemfile.lock contents or at least major gem versions, such as Rails version
|
12
|
+
- Steps to reproduce the issue
|
13
|
+
- Full backtrace for any errors encountered
|
14
|
+
|
15
|
+
## Submitting changes
|
16
|
+
|
17
|
+
If you want to contribute an enhancement or a fix:
|
18
|
+
|
19
|
+
- Fork the project on GitHub
|
20
|
+
- After checking out the repo, run `bin/setup` to install dependencies
|
21
|
+
- Make your changes with tests
|
22
|
+
- Run `bundle exec rubocop -A` to auto-format your code
|
23
|
+
- Run `rake spec` to run the tests
|
24
|
+
- Commit the changes without making changes to the Rakefile or any other files that aren't related to your enhancement or fix
|
25
|
+
- Send a pull request
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
permisi (0.1.
|
4
|
+
permisi (0.1.1)
|
5
5
|
activemodel (>= 3.2.0)
|
6
6
|
activerecord (>= 3.2.0)
|
7
7
|
activesupport (>= 3.2.0)
|
@@ -10,12 +10,12 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activemodel (6.1.
|
14
|
-
activesupport (= 6.1.
|
15
|
-
activerecord (6.1.
|
16
|
-
activemodel (= 6.1.
|
17
|
-
activesupport (= 6.1.
|
18
|
-
activesupport (6.1.
|
13
|
+
activemodel (6.1.3)
|
14
|
+
activesupport (= 6.1.3)
|
15
|
+
activerecord (6.1.3)
|
16
|
+
activemodel (= 6.1.3)
|
17
|
+
activesupport (= 6.1.3)
|
18
|
+
activesupport (6.1.3)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
20
|
i18n (>= 1.6, < 2)
|
21
21
|
minitest (>= 5.1)
|
data/README.md
CHANGED
@@ -172,15 +172,9 @@ user.permisi.has_role? :admin # == true
|
|
172
172
|
user.permisi.may? "books.delete" # == true
|
173
173
|
```
|
174
174
|
|
175
|
-
## Development
|
176
|
-
|
177
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
178
|
-
|
179
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
180
|
-
|
181
175
|
## Contributing
|
182
176
|
|
183
|
-
|
177
|
+
For development and how to submit improvements, please refer to the [contribution guide](https://github.com/ukazap/permisi/blob/main/CONTRIBUTING.md).
|
184
178
|
|
185
179
|
## License
|
186
180
|
|
@@ -188,4 +182,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
188
182
|
|
189
183
|
## Code of Conduct
|
190
184
|
|
191
|
-
Everyone interacting in the Permisi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ukazap/permisi/blob/
|
185
|
+
Everyone interacting in the Permisi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ukazap/permisi/blob/main/CODE_OF_CONDUCT.md).
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators"
|
2
4
|
require "rails/generators/migration"
|
3
5
|
require "rails/generators/active_record"
|
@@ -7,26 +9,24 @@ module Permisi
|
|
7
9
|
class InstallGenerator < Rails::Generators::Base
|
8
10
|
include Rails::Generators::Migration
|
9
11
|
|
10
|
-
source_root File.expand_path(
|
12
|
+
source_root File.expand_path("templates", __dir__)
|
11
13
|
|
12
14
|
def self.next_migration_number(path)
|
13
15
|
ActiveRecord::Generators::Base.next_migration_number(path)
|
14
16
|
end
|
15
17
|
|
16
18
|
def create_initializer
|
17
|
-
template
|
19
|
+
template "initializer.rb", "config/initializers/permisi.rb"
|
18
20
|
end
|
19
21
|
|
20
22
|
def create_migrations
|
21
|
-
migration_template
|
23
|
+
migration_template "migration.rb", "db/migrate/create_permisi_tables.rb", migration_version: migration_version
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
28
|
def migration_version
|
27
|
-
if ActiveRecord.version.version >
|
28
|
-
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
29
|
-
end
|
29
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" if ActiveRecord.version.version > "5"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/permisi.rb
CHANGED
@@ -1,41 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_model/type"
|
4
|
+
require "active_support/hash_with_indifferent_access"
|
3
5
|
require "zeitwerk"
|
4
|
-
$permisi_loader = Zeitwerk::Loader.for_gem
|
5
|
-
$permisi_loader.ignore("#{__dir__}/generators")
|
6
|
-
$permisi_loader.ignore("#{__dir__}/permisi/backend/mongoid.rb") # todo
|
7
|
-
$permisi_loader.setup
|
8
6
|
|
9
7
|
module Permisi
|
8
|
+
LOADER = Zeitwerk::Loader.for_gem
|
9
|
+
|
10
10
|
class << self
|
11
|
-
def init
|
11
|
+
def init
|
12
12
|
yield config if block_given?
|
13
13
|
end
|
14
14
|
|
15
15
|
def config
|
16
|
-
|
16
|
+
@config ||= Config.new
|
17
17
|
end
|
18
18
|
|
19
19
|
def actors
|
20
|
-
|
20
|
+
config.backend.actors
|
21
21
|
end
|
22
22
|
|
23
23
|
def actor(aka)
|
24
|
-
|
24
|
+
config.backend.findsert_actor(aka)
|
25
25
|
end
|
26
26
|
|
27
27
|
def roles
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def __backend
|
34
|
-
if config.backend.nil? || !(config.backend <= Backend::Base)
|
35
|
-
raise Backend::InvalidBackend
|
36
|
-
end
|
37
|
-
|
38
|
-
config.backend
|
28
|
+
config.backend.roles
|
39
29
|
end
|
40
30
|
end
|
41
31
|
end
|
32
|
+
|
33
|
+
Permisi::LOADER.ignore("#{__dir__}/generators")
|
34
|
+
Permisi::LOADER.ignore("#{__dir__}/permisi/backend/mongoid.rb") # todo
|
35
|
+
Permisi::LOADER.setup
|
data/lib/permisi/actable.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Permisi
|
4
|
+
module Backend
|
5
|
+
class InvalidBackend < StandardError
|
6
|
+
def initialize(message = "Please check https://github.com/ukazap/permisi#configuring-backend")
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module NullBackend
|
12
|
+
class << self
|
13
|
+
def findsert_actor(_aka)
|
14
|
+
raise InvalidBackend
|
15
|
+
end
|
16
|
+
|
17
|
+
def actors
|
18
|
+
raise InvalidBackend
|
19
|
+
end
|
20
|
+
|
21
|
+
def roles
|
22
|
+
raise InvalidBackend
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,22 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_record"
|
2
4
|
|
3
5
|
module Permisi
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
module Backend
|
7
|
+
module ActiveRecord
|
8
|
+
class << self
|
9
|
+
def table_name_prefix
|
10
|
+
"permisi_"
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
def findsert_actor(aka)
|
14
|
+
Actor.find_or_create_by(aka: aka)
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
def actors
|
18
|
+
Actor.all
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
21
|
+
def roles
|
22
|
+
Role.all
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
@@ -1,15 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Permisi
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
module Backend
|
5
|
+
module ActiveRecord
|
6
|
+
class Actor < ::ActiveRecord::Base
|
7
|
+
belongs_to :aka, polymorphic: true, touch: true
|
8
|
+
has_many :actor_roles, dependent: :destroy
|
9
|
+
has_many :roles, through: :actor_roles
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
def role?(role_slug)
|
12
|
+
roles.load.any? { |role| role.slug == role_slug.to_s }
|
13
|
+
end
|
14
|
+
|
15
|
+
def may?(action_path)
|
16
|
+
roles.load.any? { |role| role.allows?(action_path) }
|
17
|
+
end
|
10
18
|
|
11
|
-
|
12
|
-
|
19
|
+
alias may_i? may?
|
20
|
+
alias has_role? role?
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
15
24
|
end
|
@@ -1,6 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Permisi
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
module Backend
|
5
|
+
module ActiveRecord
|
6
|
+
class ActorRole < ::ActiveRecord::Base
|
7
|
+
belongs_to :actor, touch: true
|
8
|
+
belongs_to :role
|
9
|
+
|
10
|
+
after_destroy :touch_actor
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def touch_actor
|
15
|
+
actor.touch
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
5
19
|
end
|
6
20
|
end
|
@@ -1,27 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Permisi
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
module Backend
|
5
|
+
module ActiveRecord
|
6
|
+
class Role < ::ActiveRecord::Base
|
7
|
+
has_many :actor_roles, dependent: :destroy
|
8
|
+
has_many :actors, through: :actor_roles
|
9
|
+
has_many :akas, through: :actors
|
6
10
|
|
7
|
-
|
8
|
-
|
11
|
+
validates_presence_of :name, :slug
|
12
|
+
validates_uniqueness_of :name, :slug
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
after_initialize :set_default_permissions
|
15
|
+
before_validation :sanitize_attributes
|
16
|
+
after_update :touch_actor_roles
|
12
17
|
|
13
|
-
|
18
|
+
serialize :permissions, Permisi::PermissionUtil::Serializer
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
def allows?(action_path)
|
21
|
+
Permisi::PermissionUtil.allows?(permissions, action_path)
|
22
|
+
end
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
private
|
25
|
+
|
26
|
+
def set_default_permissions
|
27
|
+
self.permissions ||= HashWithIndifferentAccess.new if new_record?
|
28
|
+
end
|
29
|
+
|
30
|
+
def sanitize_attributes
|
31
|
+
self.name ||= slug.try(:titleize)
|
32
|
+
self.permissions = Permisi::PermissionUtil.sanitize_permissions(self.permissions)
|
33
|
+
end
|
22
34
|
|
23
|
-
|
24
|
-
|
35
|
+
def touch_actor_roles
|
36
|
+
actor_roles.each(&:touch)
|
37
|
+
end
|
38
|
+
end
|
25
39
|
end
|
26
40
|
end
|
27
41
|
end
|
data/lib/permisi/config.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/class/attribute_accessors"
|
2
4
|
|
3
5
|
module Permisi
|
4
6
|
class Config
|
5
|
-
|
6
|
-
attr_reader :default_permissions
|
7
|
+
attr_reader :permissions, :default_permissions
|
7
8
|
|
8
9
|
def initialize
|
9
10
|
@permissions = ::HashWithIndifferentAccess.new
|
@@ -11,15 +12,16 @@ module Permisi
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def backend=(chosen_backend)
|
14
|
-
if chosen_backend.is_a? Symbol
|
15
|
-
chosen_backend = "::Permisi::Backend::#{chosen_backend.to_s.classify}".constantize
|
16
|
-
end
|
17
|
-
|
15
|
+
chosen_backend = "::Permisi::Backend::#{chosen_backend.to_s.classify}".constantize if chosen_backend.is_a? Symbol
|
18
16
|
@backend = chosen_backend
|
19
17
|
rescue NameError
|
20
18
|
raise Backend::InvalidBackend
|
21
19
|
end
|
22
20
|
|
21
|
+
def backend
|
22
|
+
@backend || Backend::NullBackend
|
23
|
+
end
|
24
|
+
|
23
25
|
def permissions=(permissions_hash)
|
24
26
|
permissions_hash = HashWithIndifferentAccess.new(permissions_hash)
|
25
27
|
@default_permissions = PermissionUtil.transform_namespace(permissions_hash)
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require "active_support/hash_with_indifferent_access"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module Permisi
|
5
4
|
module PermissionUtil
|
@@ -7,32 +6,39 @@ module Permisi
|
|
7
6
|
|
8
7
|
class << self
|
9
8
|
def allows?(hash, action_path)
|
10
|
-
return false unless hash.
|
9
|
+
return false unless hash.is_a?(Hash)
|
11
10
|
|
12
11
|
action_path_arr = action_path.split(".")
|
13
|
-
|
12
|
+
begin
|
13
|
+
!Permisi.config.default_permissions.dig(*action_path_arr).nil?
|
14
|
+
rescue StandardError
|
15
|
+
false
|
16
|
+
end &&
|
14
17
|
hash.dig(*action_path_arr) == true
|
15
18
|
end
|
16
19
|
|
17
20
|
def transform_namespace(namespace, current_path: nil)
|
18
21
|
HashWithIndifferentAccess.new.tap do |transformed|
|
19
22
|
namespace.each_pair do |key, value|
|
20
|
-
|
21
|
-
|
23
|
+
unless value.is_a? Array
|
24
|
+
raise InvalidNamespace,
|
25
|
+
"`#{[current_path, key].compact.join(".")}` should be an array"
|
26
|
+
end
|
22
27
|
|
23
28
|
value.each.with_index do |arr_v, arr_i|
|
24
|
-
|
29
|
+
case arr_v
|
30
|
+
when Symbol
|
25
31
|
transformed[key] ||= ::HashWithIndifferentAccess.new
|
26
|
-
if transformed[key].
|
32
|
+
if transformed[key].key? arr_v
|
27
33
|
raise InvalidNamespace, "duplicate entry: `#{[current_path, key, arr_v].compact.join(".")}`"
|
28
34
|
end
|
29
35
|
|
30
36
|
transformed[key][arr_v] = false
|
31
|
-
|
37
|
+
when Hash
|
32
38
|
transform_namespace(arr_v,
|
33
39
|
current_path: [current_path, key].compact.join(".")).each_pair do |ts_k, ts_v|
|
34
40
|
transformed[key] ||= ::HashWithIndifferentAccess.new
|
35
|
-
if transformed[key].
|
41
|
+
if transformed[key].key? ts_k
|
36
42
|
raise InvalidNamespace, "duplicate entry: `#{[current_path, key, ts_k].compact.join(".")}`"
|
37
43
|
end
|
38
44
|
|
@@ -56,13 +62,13 @@ module Permisi
|
|
56
62
|
def __deeply_sanitize_permissions(permission_hash, template: {})
|
57
63
|
HashWithIndifferentAccess.new.tap do |sanitized|
|
58
64
|
permission_hash.each_pair do |key, value|
|
59
|
-
next unless template.
|
65
|
+
next unless template.key?(key)
|
60
66
|
|
61
|
-
if value.is_a?(Hash)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
67
|
+
sanitized[key] = if value.is_a?(Hash)
|
68
|
+
__deeply_sanitize_permissions(value, template: template[key])
|
69
|
+
else
|
70
|
+
__cast_value_to_boolean(value)
|
71
|
+
end
|
66
72
|
end
|
67
73
|
end
|
68
74
|
end
|
data/lib/permisi/version.rb
CHANGED
data/permisi.gemspec
CHANGED
@@ -33,9 +33,9 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ["lib"]
|
35
35
|
|
36
|
-
spec.add_dependency "activesupport", ">= 3.2.0"
|
37
|
-
spec.add_dependency "activerecord", ">= 3.2.0"
|
38
36
|
spec.add_dependency "activemodel", ">= 3.2.0"
|
37
|
+
spec.add_dependency "activerecord", ">= 3.2.0"
|
38
|
+
spec.add_dependency "activesupport", ">= 3.2.0"
|
39
39
|
spec.add_dependency "zeitwerk", ["~> 2.4", ">= 2.4.2"]
|
40
40
|
|
41
41
|
# For more information and examples about making a new gem, checkout our
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: permisi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ukaza Perdana
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -82,12 +82,13 @@ executables: []
|
|
82
82
|
extensions: []
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
|
-
- ".github/workflows/
|
85
|
+
- ".github/workflows/ci.yml"
|
86
86
|
- ".gitignore"
|
87
87
|
- ".rspec"
|
88
88
|
- ".rubocop.yml"
|
89
89
|
- CHANGELOG.md
|
90
90
|
- CODE_OF_CONDUCT.md
|
91
|
+
- CONTRIBUTING.md
|
91
92
|
- Gemfile
|
92
93
|
- Gemfile.lock
|
93
94
|
- LICENSE.txt
|
@@ -100,12 +101,11 @@ files:
|
|
100
101
|
- lib/generators/permisi/templates/migration.rb
|
101
102
|
- lib/permisi.rb
|
102
103
|
- lib/permisi/actable.rb
|
104
|
+
- lib/permisi/backend.rb
|
103
105
|
- lib/permisi/backend/active_record.rb
|
104
106
|
- lib/permisi/backend/active_record/actor.rb
|
105
107
|
- lib/permisi/backend/active_record/actor_role.rb
|
106
108
|
- lib/permisi/backend/active_record/role.rb
|
107
|
-
- lib/permisi/backend/base.rb
|
108
|
-
- lib/permisi/backend/invalid_backend.rb
|
109
109
|
- lib/permisi/backend/mongoid.rb
|
110
110
|
- lib/permisi/config.rb
|
111
111
|
- lib/permisi/permission_util.rb
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
136
|
+
rubygems_version: 3.1.4
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Simple and dynamic role-based access control for Rails
|
data/.github/workflows/main.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
name: Ruby
|
2
|
-
|
3
|
-
on: [push,pull_request]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
build:
|
7
|
-
runs-on: ubuntu-latest
|
8
|
-
steps:
|
9
|
-
- uses: actions/checkout@v2
|
10
|
-
- name: Set up Ruby
|
11
|
-
uses: ruby/setup-ruby@v1
|
12
|
-
with:
|
13
|
-
ruby-version: 3.0.0
|
14
|
-
- name: Run the default task
|
15
|
-
run: |
|
16
|
-
gem install bundler -v 2.2.5
|
17
|
-
bundle install
|
18
|
-
bundle exec rake
|
data/lib/permisi/backend/base.rb
DELETED