Skip to content

Latest commit

 

History

History
67 lines (43 loc) · 1.76 KB

README.md

File metadata and controls

67 lines (43 loc) · 1.76 KB

Gem Version Code Climate Test Coverage

Constantizer

Constantizer helps you manage your ruby constants to be used through out your application.

Features

  • Constants are added using YAML files.

Installation

Add this line to your application's Gemfile:

gem 'constantizer'

And then execute:

$ bundle

And then execute:

$ bundle exec constantizer install

Constants directory will be created:

└── config
    └── constants
        └── common.yml

Configurations

You can configure the gem to use a specific directory other than the default. To achive that, in constantizer.rb file add the following:

Constantizer.configure do |config|
  config.directory = 'special_directory'
end

now put the YAML files contaning the constants under that special_directory

Usage

Constantizer allow you to create constants that are accessible from everywhere in your app.

Given the following YAML file

currencies:
  - USD
  - EUR
default_currency: USD

You can go to anywhere in your app and do the following:

CURRENCIES.include?('USD')     #=> true

Contributing

  1. Fork it
  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