Skip to content
🤔Can I use this feature? CanUse is a minimalist feature toggle for crystal, based on yaml.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec
src
.editorconfig
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
shard.yml

README.md

can_use

🤔 Can I use this feature? Yes, sure!

CanUse is a minimalist feature toggle/flag for crystal, based on yaml file.

GitHub release

Build Status

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  can_use:
    github: rodrigopinto/can_use
  1. Run shards install

Usage

  1. Require the library on your code base.

    require "can_use"
  2. Create a file with the features toggle definitions. We suggest to name it as featutes.yaml, but it is up to you.

    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:

    defaults:
      new_payment_flow: false
      rating_service: false
    
    development:
      new_payment_flow: true
      rating_service: false
    
    your_environment:
      new_payment_flow: true
  3. Configure the environment and the path to the yaml.

    CanUse.configure do |config|
      config.file = "path/to/features.yaml"
      config.environment = "your_environment"
    end
  4. Verify if a feature is toggled on/off

    if CanUse.feature?("new_payment_flow")
      # do_something
    end

Development

  1. Install the dependencies.

    $ shards install
  2. Implement and test your changes.

    $ crystal spec
  3. Run fomart tool to verify code style.

    $ crystal tool format

TODO

  • Add ability to toggle on/off a feature programatically, ex: CanUse.enable("feature").
  • Allows ENVIRONMENT variables to set/override a value for a key.

Contributing

  1. Fork it (https://github.com/rodrigopinto/can_use/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Credits

This shard was initially inspired by can_do (Ruby).

Contributors

You can’t perform that action at this time.