Module Rudy::Routines::Handlers::Depends

  1. lib/rudy/routines/handlers/depends.rb

Methods

public instance

  1. execute
  2. execute_all
  3. raise_early_exceptions

Public instance methods

execute (routine_name, argv=[])

A simple wrapper for executing a routine.

  • routine_name should be a Symbol representing a routine available to the current machine group.

This method finds the handler for the given routine, creates an instance, calls raise_early_exceptions, and finally executes the routine.

[show source]
    # File lib/rudy/routines/handlers/depends.rb, line 30
30:     def execute(routine_name, argv=[])
31:       routine_obj = Rudy::Routines.get_routine routine_name
32:       ld "Executing dependency: #{routine_name} (#{routine_obj}) (argv: #{argv})"
33:       routine = routine_obj.new routine_name, {}, argv
34:       routine.raise_early_exceptions
35:       routine.execute
36:     end
execute_all (depends, argv=[])

Calls execute for each routine name in depends (an Array). Does nothing if given an empty Array or nil.

[show source]
    # File lib/rudy/routines/handlers/depends.rb, line 40
40:     def execute_all(depends, argv=[])
41:       return if depends.nil? || depends.empty?
42:       depends = depends.flatten.compact
43:       ld "Found depenencies: #{depends.join(', ')}"
44:       depends.each { |routine| execute(routine, argv) }
45:     end
raise_early_exceptions (type, depends, rset, lbox, argv=nil)
[show source]
    # File lib/rudy/routines/handlers/depends.rb, line 12
12:     def raise_early_exceptions(type, depends, rset, lbox, argv=nil)
13:       unless depends.kind_of? Array
14:         raise Rudy::Error, "#{type} must be a kind of Array (#{depends.class})" 
15:       end
16:       raise Rudy::Routines::EmptyDepends, type if depends.nil? || depends.empty?
17:       depends.flatten.compact.each do |name|
18:         raise Rudy::Routines::NoRoutine, name unless valid_routine?(name)
19:       end
20:     end