{"id":15407441,"url":"https://github.com/wojtha/simple_flag","last_synced_at":"2025-03-28T02:28:03.550Z","repository":{"id":56895734,"uuid":"259616043","full_name":"wojtha/simple_flag","owner":"wojtha","description":"Simple but powerful feature flag implementation in 90 LOC","archived":false,"fork":false,"pushed_at":"2023-11-01T22:07:10.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-03T08:16:58.211Z","etag":null,"topics":["feature-flags","ruby","ruby-gem","ruby-library"],"latest_commit_sha":null,"homepage":null,"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/wojtha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"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":"2020-04-28T11:21:34.000Z","updated_at":"2023-10-31T23:12:45.000Z","dependencies_parsed_at":"2024-10-19T12:37:34.394Z","dependency_job_id":"0355d58b-6cdf-48cd-a219-f9100fa2070e","html_url":"https://github.com/wojtha/simple_flag","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"3161e652046c03a073ab56974cc0db1c485e60de"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wojtha%2Fsimple_flag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wojtha%2Fsimple_flag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wojtha%2Fsimple_flag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wojtha%2Fsimple_flag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wojtha","download_url":"https://codeload.github.com/wojtha/simple_flag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245956737,"owners_count":20700149,"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","ruby","ruby-gem","ruby-library"],"created_at":"2024-10-01T16:28:47.404Z","updated_at":"2025-03-28T02:28:03.518Z","avatar_url":"https://github.com/wojtha.png","language":"Ruby","readme":"# SimpleFlag\n\nSimple but powerful feature flag implementation in 90 LOC.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'simple_flag'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install simple_flag\n\n## Usage\n\n### Configuration\n\n```ruby\nFEATURE = SimpleFlag.new do |feature|\n  feature.define(:new_user_profile) do |user_id:|\n    Admin.where(user_id: user_id).exists?\n  end\n  feature.define(:third_party_analytics) do\n    not Rails.env.production?\n  end\nend\n```\n\n### Usage in app code\n\n```ruby\nclass ProfilesController \u003c ApplicationController\n  def show\n    FEATURE.with(:new_user_profile, user_id: current_user.id) do\n      return render :new_user_profile, locals: { user: NewUserProfilePresenterV2.new(current_user) }\n    end\n    render :show, locals: { user: UserProfilePresenterV1.new(current_user) }\n  end\nend\n```\n\n### Testing with before...after\n\n```ruby\ndescribe \"User profiles\" do\n  after { FEATURE.reset_all_overrides }\n\n  context \"with new_user_profile feature enabled\" do\n    before { FEATURE.override(:new_user_profile, true) }\n    it \"renders new profile\"\n  end\n\n  context \"with new_user_profile feature disabled\" do\n    before { FEATURE.override(:new_user_profile, false) }\n    it \"renders old profile\"\n  end\nend\n```\n\n### Testing with inline block\n\n```ruby\nit \"shows new user profile\" do\n  FEATURE.override_with(:new_user_profile, true) do\n    expect( FEATURE.active?(:new_user_profile) ).to be_truthy\n  end\n  expect( FEATURE.active?(:new_user_profile) ).to be_falsy\nend\n```\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\nalso 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\nversion number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,\npush 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/wojtha/simple_flag.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwojtha%2Fsimple_flag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwojtha%2Fsimple_flag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwojtha%2Fsimple_flag/lists"}