{"id":14969824,"url":"https://github.com/digitalnz/plug","last_synced_at":"2025-10-06T09:31:18.969Z","repository":{"id":26527059,"uuid":"108776573","full_name":"DigitalNZ/plug","owner":"DigitalNZ","description":"🔌 A Rails engine to turn on/off features (Feature flipper).","archived":false,"fork":false,"pushed_at":"2024-07-25T01:35:18.000Z","size":286,"stargazers_count":4,"open_issues_count":7,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-01-16T19:16:13.841Z","etag":null,"topics":["feature-flags","feature-flipper","feature-toggles","flipper","gem","mysql","plug","rails","rails-engine","ruby","ruby-on-rails"],"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/DigitalNZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"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":"2017-10-29T22:27:11.000Z","updated_at":"2024-07-25T01:35:18.000Z","dependencies_parsed_at":"2024-07-23T04:07:34.246Z","dependency_job_id":"3fde2252-e53c-423c-a444-187a932be173","html_url":"https://github.com/DigitalNZ/plug","commit_stats":{"total_commits":101,"total_committers":11,"mean_commits":9.181818181818182,"dds":0.4653465346534653,"last_synced_commit":"f56d78a647898af9b750ca98137a271daffa79c4"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalNZ%2Fplug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalNZ%2Fplug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalNZ%2Fplug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalNZ%2Fplug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DigitalNZ","download_url":"https://codeload.github.com/DigitalNZ/plug/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235515428,"owners_count":19002481,"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":["feature-flags","feature-flipper","feature-toggles","flipper","gem","mysql","plug","rails","rails-engine","ruby","ruby-on-rails"],"created_at":"2024-09-24T13:42:27.236Z","updated_at":"2025-10-06T09:31:13.428Z","avatar_url":"https://github.com/DigitalNZ.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Plug [![Maintainability](https://api.codeclimate.com/v1/badges/6246b1cd8e42603c42f6/maintainability)](https://codeclimate.com/github/DigitalNZ/plug/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/6246b1cd8e42603c42f6/test_coverage)](https://codeclimate.com/github/DigitalNZ/plug/test_coverage)\n\nA Rails engine to turn on/off features (Feature flipper).\n\n### Features\n\n- Manage features with notices\n- Manage site notices with themes\n\n### Prerequisites\n\n- Rails version 5 and above\n- MySQL\n\n### Getting Started\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'plug'\n```\n\nExecute:\n\n```bash\n→ bundle\n```\n\nAnd run the install generator:\n\n```bash\n→ rails g plug:install\n→ rails plug:install:migrations\n→ rails db:migrate\n→ rails s\n```\n\n### Usage\n\nGo to `localhost:3000/plug` and start creating features.\n\nUse the provided method to check if the feature is enabled.\n\n```ruby\nPlug.enabled?('my-awesome-feature-slug')\n```\n\nIf you wanted to restrict routes, you can use `Plug::Constraint` class\n\n```ruby\nRails.application.routes.draw do\n  resources :blog, constraint: Plug::Constraint.new('my-awesome-feature-slug')\nend\n```\n\nNotices can be displayed using the `Plug.notice` method.\n\n```erb\n\u003c%= Plug.notice('my-awesome-feature-slug') %\u003e\n```\n\nIf you have custom HTML for notice, you can pass a block.\n\n\n```erb\n\u003c% Plug.notice('my-awesome-feature-slug') do |notice| %\u003e\n  \u003cdiv class=\"alert\"\u003e\n    \u003cp\u003e\u003c%= notice %\u003e\u003c/p\u003e\n  \u003c/div\u003e\n\u003c% end %\u003e\n```\n\n#### Buttons\nAdd buttons to the config block to perform rake tasks from the plug dashboard\n\n```ruby\n  config.buttons = [\n    { label: 'Clear cache', task: 'tmp:cache:clear' }\n  ]\n```\n\n#### Themes\nThemes can be added in Site Notices. Themes are just string stored in the database. You still need to style the theme.\n\nBy default, we have `default` and `dark` in `config/plug.rb`. Below is an example on how you can utilise the theme string.\n\n```haml\n- theme_class = \"site-notice--#{site_notice.theme}\"\n\n.site-notice{ class: theme_class }\n  %p My site notice\n```\n\n```scss\n// BEM\n.site-notice {\n  @include modifier('default') {\n    ...\n  }\n  \n  @include modifier('dark') {\n    ...\n  }\n}\n```\n\n### Creating new migrations\n\n```bash\n→ rails g migration MyAwesomeMigration\n→ rails g model MyModel name:string slug:string:index\n→ rails db:migrate\n→ rails db:migrate RAILS_ENV=test\n→ rake plug:install:migrations # Run this on the app to copy the new migrations\n```\n\n### Running the tests\n\n```bash\n→ bundle exec rspec spec\n```\n\n### Publishing to `rubygems.org`\n\nMake sure to **bump** the version. Rubygems don't accept version overrides.\n\n```bash\n→ gem build plug.gemspec\n→ gem push plug-\u003cversion\u003e.gem\n```\n\n### Publishing to `npmjs.com`\n\nMake sure to match the version with the Rubygems version.\n\n```bash\n→ npm login\n→ npm publish --access public\n```\n\n### TODOs\n\n- Ability to disable all features using one button\n- Add screenshot\n- Allow block parameters for `enabled?` method\n- Versioning of features\n- History of feature activities\n\n\n### Questions/Issues?\n\nFile a new [issue](https://github.com/digitalnz/plug/issues/new) if you have questions or issues.\n\n### Contributing\n\n1. Fork it ( https://github.com/boost/digitalnz/fork )\n2. Create your feature branch (`git checkout -b my-awesome-feature`)\n3. Commit your changes (`git commit -am 'Add my awesome feature!'`)\n4. Push to the branch (`git push origin my-awesome-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalnz%2Fplug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalnz%2Fplug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalnz%2Fplug/lists"}