class WhirledPeas::Command::ConfigCommand
Abstract command that expects a config file as an argument and then requires the specified file. All implementing classes must call `super` if they override `start` or `validate!`
Attributes
config_file[R]
Public Instance Methods
start()
click to toggle source
# File lib/whirled_peas/command/config_command.rb, line 9 def start require config_file rescue LoadError => e puts e puts e.backtrace.join("\n") exit(1) end
Private Instance Methods
options_usage()
click to toggle source
# File lib/whirled_peas/command/config_command.rb, line 38 def options_usage '<config file>' end
validate!()
click to toggle source
Calls superclass method
WhirledPeas::Command::Base#validate!
# File lib/whirled_peas/command/config_command.rb, line 21 def validate! super # Note that the main script consumes the <command> argument from ARGV, so we # expect the config file to be at index 0. config_file = args.shift if config_file.nil? @error_text = "#{command_name} requires a config file" elsif !File.exist?(config_file) @error_text = "File not found: #{config_file}" elsif config_file[-3..-1] != '.rb' @error_text = 'Config file should be a .rb file' else # We think we have a valid ruby config file, set the absolute path to @config @config_file = config_file[0] == '/' ? config_file : File.join(Dir.pwd, config_file) end end