class Swat::Script
An executable script
Loads the script from file system using ruby's `require` command, then creates a ::Swat::Command and then calls `run` on it
If a Swat::Command object cannot be found (NameError) the command is considered bogus.
Public Class Methods
new(parameters, scripts_path = ENV["SCRIPTS_LOCAL_PATH"])
click to toggle source
# File lib/swat.rb, line 104 def initialize(parameters, scripts_path = ENV["SCRIPTS_LOCAL_PATH"]) @parameters = parameters @scripts_path = Pathname.new(scripts_path || "scripts") end
Public Instance Methods
run()
click to toggle source
# File lib/swat.rb, line 109 def run CommandExecution.new(create_command, @parameters.execution_mode).run end
Private Instance Methods
command_file()
click to toggle source
# File lib/swat.rb, line 115 def command_file @command_file ||= @scripts_path.join("#{@parameters.command}.rb") end
create_command()
click to toggle source
# File lib/swat.rb, line 119 def create_command fail "Could not find command #{@parameters.command} in #{command_file.expand_path}" unless command_file.file? require command_file.expand_path ::Swat::Command.new(@parameters.args) rescue NameError raise "#{@parameters.command} does not define a Swat::Command object" end