Project

configfile

0.0
No commit activity in last 3 years
No release in over 3 years
A simple reloadable config file system with defaults
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0
 Project Readme

ConfigFile

ConfigFile is a simple gem designed to make Configuration Files with defaults that can be read from the FileSystem. ConfigFile supports both YAML and JSON formats.

Getting Started

Getting started with Go.rb is very simple. First, install the Gem:

  gem install configfile

or, in your gem file:

  gem 'configfile'

Using the gem is very simple.

require 'configfile'
cfg = ConfigFile.new "myfile.yaml", {:my => "defaults"}
cfg.load
puts cfg[:my]

# => "defaults"

If the user adds something to their config file, it will be accessable through the same means once it has been loaded. If a default is overridden in the final file, that value will be used instead of the default.

Manipulating the defaults can be very simple, as shown here:

require 'configfile'
cfg = ConfigFile.new "myfile.yaml", {:my => "defaults"}

cfg.defaults {:my => "new_defaults"}
cfg.load
puts cfg[:my]

# => "new_defaults"

Additionally, the format of the file can be changed:

require 'configfile'
cfg = ConfigFile.new "myfile.yaml", {:my => "defaults"}
cfg.format :json
cfg.load

This will cause the resultant file to be in JSON format.