{"id":13483239,"url":"https://github.com/rodrigopinto/can_use","last_synced_at":"2025-04-24T07:39:17.936Z","repository":{"id":140561022,"uuid":"172082001","full_name":"rodrigopinto/can_use","owner":"rodrigopinto","description":"🤔 Can I use? CanUse is a minimalist feature toggle/flag for crystal, based on yaml file.","archived":false,"fork":false,"pushed_at":"2019-08-30T21:59:17.000Z","size":8,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-30T08:11:04.444Z","etag":null,"topics":["canuse","crystal","feature-flags","feature-toggle","toggle-switches","yaml"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/rodrigopinto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2019-02-22T14:41:41.000Z","updated_at":"2023-08-02T10:56:50.000Z","dependencies_parsed_at":"2024-01-21T10:49:13.582Z","dependency_job_id":"898cffbf-67ee-48df-b22f-193676e086da","html_url":"https://github.com/rodrigopinto/can_use","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigopinto%2Fcan_use","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigopinto%2Fcan_use/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigopinto%2Fcan_use/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigopinto%2Fcan_use/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodrigopinto","download_url":"https://codeload.github.com/rodrigopinto/can_use/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250584540,"owners_count":21454203,"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":["canuse","crystal","feature-flags","feature-toggle","toggle-switches","yaml"],"created_at":"2024-07-31T17:01:09.339Z","updated_at":"2025-04-24T07:39:17.895Z","avatar_url":"https://github.com/rodrigopinto.png","language":"Crystal","funding_links":[],"categories":["Feature Flipping"],"sub_categories":[],"readme":"# can_use\n\n🤔Can I use this feature? Hmm, let me see.\n\n\u003e CanUse is a minimalist feature toggle/flag for crystal, based on yaml file.\n\n[![GitHub release](https://img.shields.io/github/release/rodrigopinto/can_use.svg)](https://github.com/rodrigopinto/can_use/releases) [![Build Status](https://travis-ci.org/rodrigopinto/can_use.svg?branch=master)](https://travis-ci.org/rodrigopinto/can_use)\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n```yaml\ndependencies:\n  can_use:\n    github: rodrigopinto/can_use\n```\n2. Run `shards install`\n\n## Usage\n\n1. Require the library on your code base.\n\n```crystal\nrequire \"can_use\"\n```\n\n2. Create a file with the features toggle definitions.\nWe suggest to name it as `featutes.yaml`, but it is up to you.\n\n\t**Note:** The `defaults` block is mandatory, as it will be used as fallback when values are not defined on the environment set on `configuration`. Example:\n\n```yaml\ndefaults:\n  new_payment_flow: false\n  rating_service: false\n\ndevelopment:\n  new_payment_flow: true\n  rating_service: false\n\nyour_environment:\n  new_payment_flow: true\n```\n\n3. Configure the environment and the path to the yaml.\n\n```crystal\nCanUse.configure do |config|\n  config.file = \"path/to/features.yaml\"\n  config.environment = \"your_environment\"\nend\n```\n\n4. Verify if a feature is toggled on/off\n\n```crystal\nif CanUse.feature?(\"new_payment_flow\")\n  # do_something\nend\n```\n\n5. Enabling or Disabling a feature is simple as\n\n\u003e Enabling\n\n```crystal\nCanUse.feature?(\"feature_a\") # =\u003e false\n\nCanUse.enable(\"feature_a\") # =\u003e true\n\nCanUse.feature?(\"feature_a\") # =\u003e true\n```\n\n\u003e Disabling\n\n```crystal\nCanUse.feature?(\"feature_b\") # =\u003e true\n\nCanUse.disable(\"feature_b\") # =\u003e false\n\nCanUse.feature?(\"feature_b\") # =\u003e false\n```\n\n## Development\n\n1. Install the dependencies.\n\n```bash\n$ shards install\n```\n\n2. Implement and test your changes.\n\n```bash\n$ crystal spec\n```\n\n3. Run fomart tool to verify code style.\n\n```bash\n$ crystal tool format\n```\n\n## TODO\n\n- [ ] Allows ENVIRONMENT variables to set/override a value for a key.\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/rodrigopinto/can_use/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Rodrigo Pinto](https://github.com/rodrigopinto) - creator and maintainer\n\n## Credits\n\nThis shard was initially inspired by [can_do](https://github.com/blacklane/can_do).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigopinto%2Fcan_use","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrigopinto%2Fcan_use","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigopinto%2Fcan_use/lists"}