All Projects → manuelmeurer → Gem_config

manuelmeurer / Gem_config

Licence: mit
A nifty way to make your gem configurable.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Gem config

Dots
Dotfiles for Arch Linux and OS X (branched)
Stars: ✭ 54 (-28.95%)
Mutual labels:  configuration
Ins sandstorm
[INS] Config setting for our sandstorm server
Stars: ✭ 61 (-19.74%)
Mutual labels:  configuration
Dotfile
Simple version control made for tracking single files
Stars: ✭ 71 (-6.58%)
Mutual labels:  configuration
.emacs.d
My emacs config
Stars: ✭ 56 (-26.32%)
Mutual labels:  configuration
Aspnetcore.services
Examples for ASP.NET Core webservices
Stars: ✭ 59 (-22.37%)
Mutual labels:  configuration
Umatrix Rules Domain
uMatrix ruleset unbreaks all Alexa 100 and more at domain level
Stars: ✭ 66 (-13.16%)
Mutual labels:  configuration
Totem
Crystal configuration with spirit. Load and parse configuration in JSON, YAML, dotenv formats.
Stars: ✭ 52 (-31.58%)
Mutual labels:  configuration
Rime pure
【rime小狼毫\trime同文】手机/PC一站式配置【简约皮肤\拼音搜狗词库\原创trime同文四叶草九宫格拼音方案\四叶草拼音、小鹤双拼、极品五笔、徐码、郑码】 rime配置
Stars: ✭ 73 (-3.95%)
Mutual labels:  configuration
Pioneer Console Boilerplate
Dependency injection, logging and configuration in a .NET Core console application.
Stars: ✭ 60 (-21.05%)
Mutual labels:  configuration
Conf
Go package for loading program configuration from multiple sources.
Stars: ✭ 70 (-7.89%)
Mutual labels:  configuration
Arcticfox Config
Configuration Tool for Vape Battery Mods with Arcticfox Firmware. ☁️ 🔧 Works on MacOS and Linux.
Stars: ✭ 58 (-23.68%)
Mutual labels:  configuration
Dotfiles
🖥️ Automated Configuration, Preferences and Software Installation for macOS
Stars: ✭ 1,103 (+1351.32%)
Mutual labels:  configuration
Vimfiles
My .vim folder
Stars: ✭ 66 (-13.16%)
Mutual labels:  configuration
Mac config
Scripted installation and configuration of Mac OS X apps and preferences
Stars: ✭ 55 (-27.63%)
Mutual labels:  configuration
Archlinux Installer
Arch Linux Installer,Install your Arch Linux more quickly
Stars: ✭ 72 (-5.26%)
Mutual labels:  configuration
Config
Yii2 application runtime configuration support
Stars: ✭ 54 (-28.95%)
Mutual labels:  configuration
Pureconfig
A boilerplate-free library for loading configuration files
Stars: ✭ 1,114 (+1365.79%)
Mutual labels:  configuration
Cfg4k
Flexible and easy to use config library written in kotlin
Stars: ✭ 73 (-3.95%)
Mutual labels:  configuration
Server Qa Checks
A bunch of QA checks to run against one or more servers to make sure they are built to a specific standard.
Stars: ✭ 72 (-5.26%)
Mutual labels:  configuration
Common Env
🔑 The only configuration library you will ever need
Stars: ✭ 67 (-11.84%)
Mutual labels:  configuration

GemConfig

Gem Version Build Status

A nifty way to make your gem configurable.

Usage

As a gem author

Include the gem and add configuration options like this:

# awesomeness.gemspec
Gem::Specification.new do |gem|
  ...
  gem.add_runtime_dependency 'gem_config'
end
# lib/awesomeness.rb
require 'gem_config'

module Awesomeness
  include GemConfig::Base

  with_configuration do
    has :api_key, classes: String
    has :format, values: [:json, :xml], default: :json
    has :region, values: ['us-west', 'us-east', 'eu'], default: 'us-west'
  end
end

Access the configuration values in the gem's code like this:

Awesomeness.configuration.api_key # Whatever the user set

To execute something after the gem is configured:

module Awesomeness
  include GemConfig::Base
  
  # ...
  
  after_configuration_change do
    # configure some other gem you're using, perhaps
  end
end

As a gem user

Include and configure a gem like this:

# Gemfile
gem 'awesomeness'
# config/initializers/awesomeness.rb
Awesomeness.configure do |config|
  config.api_key = 'foobarbaz'
  config.format  = :xml
  config.region  = 'eu'
end
# or
Awesomeness.configuration.api_key = 'foobarbaz'

Of course configuration values are checked against the allowed classes and values, and the default is used if no value is provided.

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 new Pull Request

Support

If you like this project, consider buying me a coffee! :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].