Coder Social home page Coder Social logo

rodrigopinto / can_use Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 0.0 8 KB

πŸ€” Can I use? CanUse is a minimalist feature toggle/flag for crystal, based on yaml file.

License: MIT License

Crystal 100.00%
crystal feature-flags feature-toggle yaml canuse toggle-switches

can_use's Introduction

can_use

πŸ€”Can I use this feature? Hmm, let me see.

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"
  1. 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
  1. Configure the environment and the path to the yaml.
CanUse.configure do |config|
  config.file = "path/to/features.yaml"
  config.environment = "your_environment"
end
  1. Verify if a feature is toggled on/off
if CanUse.feature?("new_payment_flow")
  # do_something
end
  1. Enabling or Disabling a feature is simple as

Enabling

CanUse.feature?("feature_a") # => false

CanUse.enable("feature_a") # => true

CanUse.feature?("feature_a") # => true

Disabling

CanUse.feature?("feature_b") # => true

CanUse.disable("feature_b") # => false

CanUse.feature?("feature_b") # => false

Development

  1. Install the dependencies.
$ shards install
  1. Implement and test your changes.
$ crystal spec
  1. Run fomart tool to verify code style.
$ crystal tool format

TODO

  • 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

Contributors

Credits

This shard was initially inspired by can_do.

can_use's People

Contributors

rodrigopinto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

can_use's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.