0.01
No commit activity in last 3 years
No release in over 3 years
Library for flexible specifying of application settings different ways
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.5
>= 0
 Project Readme

Sexy Settings

[Build Status][travis] [travis]: https://travis-ci.org/romikoops/sexy_settings

Application settings are specified in a flexible way.

What is Sexy Settings?

It is a Ruby-based library used to specify application settings in different ways:

  • Using the YAML file (default and custom settings).
  • Using the command line.

What's new in 0.1.0

What's new in 0.0.2

  • Ability to override delimiter on fly for command line settings
  • Hidden sensitive data in logging
  • Changed default environment variable name with options

Getting Started

Prerequisites

Ruby 2.2.2+

Installation

gem install sexy_settings

Configuration

Create 2 configuration files, one for default settings and the other one – for custom settings, e.g.:

config\
    default.yml
    custom.yml

Insert the following code to the boot executable ruby file:

require 'sexy_settings'

Specify a shortcut method for the Settings object:

def settings
  SexySettings::Base.instance
end

Usage

There are 3 possible settings values. The priority ranks with respect to the settings location are as follows:

command line < custom < default

Thus, specifying some setting in the command line will override the same setting value specified in the <default config file> or <custom config file>

Example:

default.yml

  foo: bar
  foo1: default ${foo}
  foo2: default value

custom.yml

  foo1: custom ${foo}

Set an environment variable:

SEXY_SETTINGS="foo2=10,foo3=:hi,foo4=true"

puts settings.foo # returns 'bar'
puts settings.foo1 # returns 'custom foo'
puts settings.foo2 # returns 10
puts settings.foo3 # returns :hi
puts settings.foo4 # returns true

Hints

  • Add <default config file> under the version control system.
  • Add <custom config file> to ignore the list.
  • Use the command line with an Environment Variable for fast specifying setting in your Continuous Integration System.
  • Specify custom delimiter with SEXY_SETTINGS_DELIMITER environment variable in case you need unique delimiter for command line mode
  • Use the following code to output all settings as a pretty formatted text:
puts settings.as_formatted_text

Note, all sensitive data will be masked.

Advanced settings

You have ability to change some default settings:

SexySettings.configure do |config|
   config.path_to_default_settings = File.expand_path("config.yaml", File.join(File.dirname(__FILE__), '..', 'config')) # 'default.yml' by default
   config.path_to_custom_settings = File.expand_path("overwritten.yaml", File.join(File.dirname(__FILE__), '..', 'config')) # 'custom.yml' by default
   config.path_to_project = File.dirname(__FILE__) # '.' by default
   config.env_variable_with_options = 'OPTIONS' # 'SEXY_SETTINGS' by default
   cmd_line_option_delimiter = '$$$' # ',' by default
end

Contributing

Please see CONTRIBUTING.md.

SexySettings was originally designed and is now maintained by Roman Parashchenko. You can find list of contributors here open source community.

License

SexySettngs is Copyright © 2011-2017 Roman Parashchenko. It is free software, and may be redistributed under the terms specified in the LICENSE file.