{"id":16871188,"url":"https://github.com/wilddima/pundit_kit","last_synced_at":"2025-04-11T11:13:25.259Z","repository":{"id":136292285,"uuid":"124590712","full_name":"wilddima/pundit_kit","owner":"wilddima","description":"Extension for pundit which allows to describe namespaces of policies in routes-like style","archived":false,"fork":false,"pushed_at":"2018-05-16T13:48:06.000Z","size":70,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T07:36:13.898Z","etag":null,"topics":["authorization","pundit","rails","srp"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wilddima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-09T20:37:50.000Z","updated_at":"2024-04-09T07:09:37.000Z","dependencies_parsed_at":"2023-04-09T03:35:49.249Z","dependency_job_id":null,"html_url":"https://github.com/wilddima/pundit_kit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddima%2Fpundit_kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddima%2Fpundit_kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddima%2Fpundit_kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddima%2Fpundit_kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wilddima","download_url":"https://codeload.github.com/wilddima/pundit_kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248381790,"owners_count":21094528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","pundit","rails","srp"],"created_at":"2024-10-13T15:06:41.307Z","updated_at":"2025-04-11T11:13:25.252Z","avatar_url":"https://github.com/wilddima.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PunditKit\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/edeb93a920e210fa3b85/maintainability)](https://codeclimate.com/github/WildDima/pundit_kit/maintainability)\n[![Build Status](https://travis-ci.org/wilddima/pundit_kit.svg?branch=master)](https://travis-ci.org/wilddima/pundit_kit)\n\n## Instalation\n\nAdd pundit_kit to your gemfile:\n\n```ruby\ngem 'pundit_kit'\n```\n\n## Usage\n\nExample of initializer routes:\n\n``` ruby\nclass ClientNotAllowedError \u003c StandardError; end\nclass UserNotAllowedError \u003c StandardError; end\n\nPunditKit.routes do\n  namespace :staff, if: -\u003e (user) { user.staff? }, presence: false do\n    namespace :admin, if: -\u003e (user) { user.admin? }\n    namespace :user, if: -\u003e (user) { user.user? }, error: UserNotAllowedError\n  end\n\n  namespace :client, if: -\u003e (user) { user.client? }, error: ClientNotAllowedError do\n    namespace :superclient,\n              if: -\u003e (user) { user.superclient? },\n              error: ClientNotAllowedError,\n              presence: false\n  end\nend\n\n```\n\nEach namespace has these options:\n\n|options|default|description|\n|-------|-------|-----------|\n|if:|-\u003e { true }| lamda(or any callable object) evaluation of which determines should be used this namespace or not|\n|presence:| true | if true then will raise error if policy in this namespace can't be found |\n|error:| Pundit::NotAuthorizedError | error which would be raised if authorize call will return false |\n\n## Example\n\nFor example yours application logic looks like this:\nInclude PunditKit to ApplicationController\n\n```\nclass ApplicationController \u003c  ActionController::Base\n  include PunditKit\nend\n```\n\nThis'll add helpers to yours controllers:\n* `authorize_all` - this method will call authorize on every namespace\n* `all_policies` - this method will return all namespaces matches to `pundit_namespace_matcher`\n\n## TODO\n* scope\n* fallbacks\n\n## Development\n\nAfter 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.\n\nTo 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wilddima/pundit_kit.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the PunditKit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/wilddima/pundit_kit/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilddima%2Fpundit_kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilddima%2Fpundit_kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilddima%2Fpundit_kit/lists"}