Class: ScriptRunner::Main
- Inherits:
-
Object
- Object
- ScriptRunner::Main
- Defined in:
- lib/script-runner/main.rb
Instance Method Summary collapse
-
#initialize(logger) ⇒ Main
constructor
A new instance of Main.
-
#run(paths, env_vars, error_handler = nil, &block) ⇒ Object
Run a set of scripts.
Constructor Details
#initialize(logger) ⇒ Main
Returns a new instance of Main.
7 8 9 |
# File 'lib/script-runner/main.rb', line 7 def initialize(logger) @logger = logger end |
Instance Method Details
#run(paths, env_vars, error_handler = nil, &block) ⇒ Object
Run a set of scripts
Note: non executable files are skipped and a warning is sent to the console
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/script-runner/main.rb', line 20 def run( paths, env_vars, error_handler = nil, &block) all_paths = all_files(paths).select{ |p| File.file? p } @logger.debug all_paths runnable = all_paths.select{ |p| File.executable? p } set_env(env_vars) if runnable.length > 0 non_runnable = all_paths - runnable @logger.debug "runnable: #{runnable}" non_runnable.each{ |nr| @logger.warn "#{nr} is not runnable - skipping" } runnable.each{ |p| exec(p, error_handler, &block) } end |