Module: Beaker::Options::OptionsFileParser
- Defined in:
- lib/beaker/options/options_file_parser.rb
Overview
A set of functions to read options files
Class Method Summary collapse
-
.parse_options_file(options_file_path) ⇒ OptionsHash
Eval the contents of options_file_path, return as an OptionsHash.
Class Method Details
.parse_options_file(options_file_path) ⇒ OptionsHash
Note:
Since the options_file is Eval’ed, any other Ruby commands will also be executed, this can be used to set additional environment variables
Eval the contents of options_file_path, return as an OptionsHash
Options file is assumed to contain extra options stored in a Hash
ie,
{
:debug => true,
:tests => "test.rb",
}
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/beaker/options/options_file_parser.rb', line 26 def self.() result = Beaker::Options::OptionsHash.new if = File.() raise ArgumentError, "Specified options file '#{}' does not exist!" unless File.exist?() # This eval will allow the specified options file to have access to our # scope. It is important that the variable 'options_file_path' is # accessible, because some existing options files (e.g. puppetdb) rely on # that variable to determine their own location (for use in 'require's, etc.) result = result.merge(eval(File.read())) end result end |