lib/beaker/options/options_file_parser.rb in beaker-4.42.0 vs lib/beaker/options/options_file_parser.rb in beaker-5.0.0

- old
+ new

@@ -1,11 +1,10 @@ require 'open-uri' module Beaker module Options - #A set of functions to read options files + # A set of functions to read options files module OptionsFileParser - # Eval the contents of options_file_path, return as an OptionsHash # # Options file is assumed to contain extra options stored in a Hash # # ie, @@ -26,20 +25,18 @@ # to set additional environment variables def self.parse_options_file(options_file_path) result = Beaker::Options::OptionsHash.new if options_file_path options_file_path = File.expand_path(options_file_path) - unless File.exist?(options_file_path) - raise ArgumentError, "Specified options file '#{options_file_path}' does not exist!" - end + raise ArgumentError, "Specified options file '#{options_file_path}' does not exist!" unless File.exist?(options_file_path) + # 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(options_file_path))) end result end - end end end