{"id":15431789,"url":"https://github.com/corenzan/scopable","last_synced_at":"2026-03-03T08:10:10.437Z","repository":{"id":29019715,"uuid":"32546941","full_name":"corenzan/scopable","owner":"corenzan","description":"Easy parametric query building in Rails.","archived":false,"fork":false,"pushed_at":"2019-12-06T17:41:05.000Z","size":92,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-25T17:45:40.483Z","etag":null,"topics":["activerecord","query","ruby","ruby-on-rails","scope"],"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/corenzan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-19T21:23:30.000Z","updated_at":"2020-02-28T12:06:49.000Z","dependencies_parsed_at":"2022-09-05T12:01:22.613Z","dependency_job_id":null,"html_url":"https://github.com/corenzan/scopable","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/corenzan/scopable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corenzan%2Fscopable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corenzan%2Fscopable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corenzan%2Fscopable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corenzan%2Fscopable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corenzan","download_url":"https://codeload.github.com/corenzan/scopable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corenzan%2Fscopable/sbom","scorecard":{"id":304782,"data":{"date":"2025-08-11","repo":{"name":"github.com/corenzan/scopable","commit":"1d1576d5eda5b6118594fd7dca37175f7de6092f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}}]},"last_synced_at":"2025-08-17T21:46:17.536Z","repository_id":29019715,"created_at":"2025-08-17T21:46:17.536Z","updated_at":"2025-08-17T21:46:17.536Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30036999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T06:58:30.252Z","status":"ssl_error","status_checked_at":"2026-03-03T06:58:15.329Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["activerecord","query","ruby","ruby-on-rails","scope"],"created_at":"2024-10-01T18:24:04.917Z","updated_at":"2026-03-03T08:10:10.408Z","avatar_url":"https://github.com/corenzan.png","language":"Ruby","readme":"[![RubyGems](https://img.shields.io/gem/dt/scopable.svg?style=flat-square)](https://rubygems.org/gems/scopable)\n[![Build](https://img.shields.io/travis/corenzan/scopable.svg?style=flat-square)](https://travis-ci.org/corenzan/scopable)\n[![Maintainability](https://img.shields.io/codeclimate/maintainability/corenzan/scopable.svg?style=flat-square)](https://codeclimate.com/github/corenzan/scopable/maintainability)\n[![Test Coverage](https://img.shields.io/codeclimate/c/corenzan/scopable.svg?style=flat-square)](https://codeclimate.com/github/corenzan/scopable/test_coverage)\n\n# Scopable\n\n\u003e Easy parametric query building in Rails.\n\n## Installation\n\nSimply add it to your Gemfile.\n\n```ruby\ngem 'scopable'\n```\n\nAnd update your Gems.\n\n```shell\n$ bundle update\n```\n\nPlease note that as of version 2.0 **the API has drastically changed**. If you're **already using version 1.x** and don't want to update your application right now, you should stick with it:\n\n```ruby\ngem 'scopable', '~\u003e 1.0'\n```\n\n## About\n\n**Scopable** is useful when you need to build one or more queries based on incoming parameters in the request. Very much like [has_scope](https://github.com/plataformatec/has_scope) except it's decoupled from the controller, making it easier to test and much more flexible.\n\n### Example\n\nSay you have a model and a controller for your blog. Something like this:\n\n```\n└── app\n    ├── models\n        └── post.rb\n    └── controllers\n        └── posts_controller.rb\n```\n\nFirst let's create a new directory named `scopes` along with `models` and `controllers`. There you create a file called `post_scope.rb`, and inside it you define a class that inherits from `Scopable`.\n\n```ruby\nclass PostScope \u003c Scopable\n  model Post\n\n  scope :search do\n    where('title LIKE ?', value)\n  end\n\n  scope :published_on do\n    where(published_at: value.to_time)\n  end\nend\n```\n\nFinally, in `PostsController` you use `PostScope.resolve` to conditionally resolve the scopes based on given parameters.\n\n```ruby\nclass PostsController \u003c ApplicationController\n  def index\n    @posts = PostScope.resolve(scope_params)\n  end\n\n  private\n\n  def scope_params\n    params.permit(:search, :published_on).to_h\n  end\nend\n```\n\nNow when any combination of the parameters `search` and `published_on` are present, their respective conditions are going to be applied on the relation. i.e. If your request path looks like this:\n\n```\n/?search=bananas\u0026published_on=2007-07-19\n```\n\n`@posts` will look like this:\n\n```\nPost.where('title LIKE ?', 'bananas').where(published_on: '2007-07-19 00:00:00 +0000')\n```\n\nYou can also pass some options when you're defining scopes for more advanced use cases. Read on.\n\n#### Options\n\nKey         | Description\n------------|--------------------------------------------------------------------------------------------------------------\n`:param`    | Name of the parameter that activates the scope.\n`:default`  | Default value for the scope in case the parameter is missing.\n`:value`    | Force a value to the scope regardless of the request parameters.\n`:required` | Calls `#none` on the model if parameter is absent (blank or nil) and there's no default value set.\n`:if`       | ...\n`:unless`   | ...\n`\u0026block`    | Block will be executed in the context of the relation plus two local methods `value` and `params`.\n\n## Collaboration\n\nIf you'd like to contribute to the project, in any form, you're most welcome, but please bear in mind that as it is with any open-source software your suggestions are subject to the discretion of the project maintainers, and what you see as an issue, someone else may see as a feature.\n\nWe encourage you to:\n\n- Open a new issue with suggestions, concerns, or problems you may have.\n- Chip in existing discussions and present your opinion on the subject.\n- Send pull-requests with test covered bug fixes or new features.\n- Send pull-requests with new tests you miss in the suite.\n\nRemember to:\n\n- Be respectful.\n- Use proper grammar in discussions and in commit messages.\n- Follow the established coding style.\n- Explain why you're making the changes in a pull-request.\n\n## License\n\n[The MIT License](LICENSE.md) © 2013 Arthur Corenzan\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorenzan%2Fscopable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorenzan%2Fscopable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorenzan%2Fscopable/lists"}