Minor improvement to the sub-command (git-style) module. Still not great.
Gemfile dependencies less aggressive.
Uses MultiJSON; removed strict dependency on JSON
- can now load JSON
- updated specs to run on Windows
- Only accepts things that are to_sym’bolizable as keys
- pings rdoc.info on commit
Unwittingly moved DeepHash’s alias_method(:merge,:update) above the redefinition of update, and so made merge be quietly broken. Fixed, and many more specs added.
- can now ask for
has_definition?(:my_param)
orhas_definition?(:my_param, :description)
. - validate! and define each returns self, so you can chain.
Killed many features for great justice. Configliere should now be much more predictable and lightweight, and has a much stricter API. Unfortunately, this will break backwards compatibility in some ways.
- Configliere no longer modifies any core classes
- All the hash gymnastics have been relocated to DeepHash.
- DeepHash now converts all keys to symbols, and transparently handles deep keys:
Settings['foo.bar'] = 1 Settings.merge! 'foo.bar' => 1 Settings[ [:foo, :bar] ] = 1 # => all give { :foo => { :bar => 1 } }
- DeepHash typeconverts objects of type Hash to DeepHash when merged or added.
- DeepHash added several convenience methods —
slice/slice!
,compact/compact!
,extract/extract!
,reverse_merge/reverse_merge!
,assert_valid_keys
.
- Configliere::Params
#defaults
,#resolve!
,#validate!
and#use
all return self, so you can say
Settings.defaults(:hi => :mom).use(:commandline).resolve!.validate!
- Configliere::Params.use now adds middleware only to the instance — you don’t get commandline params in your settings object just becaus some other class use’d it.
- Configliere::Params middlewares should supply a block to Configliere::Params.on_use to #extend the object, #use related middlewares, etc.
- The prepositional soup of accessor sugar is gone, replaced by three public methods:
–definition_of(param, aspect=nil)
(without arg, gives the definition hash; with arg, gives that value);
–params_with(aspect)
(hash of param => aspect_definition)
– has_definition?(param) (has #define been called for that param?)
see below for what’s gone. - Specs for the magical getter/setter given when you define a param, and for deep key handling.
- Commandline now tracks commandline arguments that haven’t been define’d in
unknown_argvs
. It adopts them all the same, but if you don’t like what you see there you’re free to raise a warning or error. - Single-character flags now take an argument:
-a=hello
or-a hello
- :encrypted keys are now stored as base64-encoded
- cleaned up handling of encrypt_pass — it’s no longer publicly readable; set it as a member (Settings[:encrypt_pass]) or through the ENCRYPT_PASS environment variable and it will be adopted in the course of action (and, if a member, deleted). Because of the #use method refactoring, you can have independent settings bundles use encrypted independently.
- Prompt is now its own middleware:
Settings.use :prompt pwd = Settings.prompt_for(:password)
- bin/configliere shows off the git-style-binaries aspect, and helps you set encrypted params.
- Specs documentation is now quite readable
- Cleaned up the STDERR-capturing part of the specs
- Added spork and watchr support to the specs.
- No modifications to core classes. Scripts that were secretly depending on Configliere for blank? etc might now break. deep_merge, deep_set and deep_delete have been moved to a DeepHash class, and the Sash class is gone.
- dashed commandline params are accepted but cause a warning — they do not serve as deep keys. By default Configliere happily accepts them. To change that, make a middleware to either convert —foo-bar to —foo.bar, or convert —foo-bar to —foo_bar.
- config_file now just takes a filename: Instead of a magic handle, scope a segment of the file with the :env option:
Settings.read('./config/foo.yaml', :env => ENV['RACK_ENV'])
Stripped out a whole raft of oversweet sugar:
- Settings.argv Settings.rest
- Settings.commands? Settings.params_with(:command).empty?
- Configliere.new Configliere::Param.new
- param_or_ask Settings.prompt_for (with Settings.use(:prompt))
- param_definitions Not publicly accessible, use definition_of(param)
- described_params Settings.params_with(:description)
- type_for Settings.definition_of(param, :type)
- typed_params Settings.params_with(:type)
- required_params Settings.params_with(:required)
- define with :no_help and :no_env_help (instead say
:internal
)
- Removed the long-deprecated :git_style_binaries synonym for :commands
The jump in minor version number was unintentional.
- handle case wehre file is empty on environment merge
- read returns self, so can chain
- Added a feature to load only production/development/etc subhash from a config file, so:
Settings.read(root_path('config/foo.yaml'), :env => ENV['RACK_ENV'])
- Missing required params include their definition in error message
- finally{} blocks don’t supply a parameter any more — use self instead.
- Settings.read now does expand_path on the file path
- Version 0.1 !!!
- Single-letter option flags
- Can give a ‘:finally’ proc (or hand a block to) Settings.define. Example:
Settings.define :key_pair_file, :description => 'AWS Key pair file', :finally => lambda{ Settings.key_pair_file = File.expand_path(Settings.key_pair_file.to_s) if Settings.key_pair_file } Settings.define :key_pair, :description => "AWS Key pair name. If not specified, it's taken from key_pair_file's basename", :finally => lambda{ Settings.key_pair ||= File.basename(Settings.key_pair_file.to_s, '.pem') if Settings.key_pair_file }
- Provisional implementation of git-style binaries (foo-ls and foo-chmod and so on)
- Minor fixes
- configliere/define and configliere/config_file are included by default.
- fixed a bug when ENV[‘HOME’] is missing (running as root)
Configliere.use will load all gems by default
- Cured a variety of issues noted by @monad — thanks for the feedback!
Settings.param
now only works for params that have been#define
’d :
Settings :no_yuo => 'oops' Settings.no_yuo #=> NoMethodError: undefined method `no_yuo' for { :no_yuo => "oops" } :Configliere::Param Settings.define :happy_param, :default => 'yay' Settings.happy_param #=> "yay"
- Note that you must use symbols as keys (except for dotted notation for deep keys). See the README.
- You must now define environment variables using
Settings.env_vars :param => 'ENV_VAR'
. The order was switched to consistently use param as the key. Also,environment
was renamed toenv_var
to avoid confusion with the “development/test/production” convention from rails and friends. - die takes an error code as option
- Added example scripts for encrypted and config_block scripts
- The directory path to a config_file will now be created automatically