Module: Rudy::Routines::Handlers::Depends
- Extended by:
- Depends
- Includes:
- Base
- Included in:
- Depends
- Defined in:
- lib/rudy/routines/handlers/depends.rb
Instance Method Summary collapse
-
#before ⇒ Object
NOTE: Dependencies don’t use Rudy::Routines.add_handler but we define them ehere anyway so raise_early_exceptions passes.
-
#execute(routine_name) ⇒ Object
A simple wrapper for executing a routine.
-
#execute_all(depends) ⇒ Object
Calls execute for each routine name in
depends(an Array). - #raise_early_exceptions(type, depends, rset, lbox, argv = nil) ⇒ Object
Methods included from Base
#keep_going?, #trap_rbox_errors
Methods included from Huxtable
config, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_bucket, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_os, #current_machine_size, #current_machine_user, #current_user_keypairname, #current_user_keypairpath, #defined_keypairpath, domain, domain_exists?, global, keypair_path_to_name, #known_machine_group?, ld, #ld, #le, le, li, #li, logger, reset_config, reset_global, #root_keypairname, #root_keypairpath, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath
Instance Method Details
#before ⇒ Object
NOTE: Dependencies don’t use Rudy::Routines.add_handler but we define them ehere anyway so raise_early_exceptions passes.
9 |
# File 'lib/rudy/routines/handlers/depends.rb', line 9 Rudy::Routines.add_handler :before, self |
#execute(routine_name) ⇒ Object
A simple wrapper for executing a routine.
-
routine_nameshould 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.
30 31 32 33 34 35 36 |
# File 'lib/rudy/routines/handlers/depends.rb', line 30 def execute(routine_name) routine_obj = Rudy::Routines.get_routine routine_name ld "Executing dependency: #{routine_name} (#{routine_obj})" routine = routine_obj.new routine_name routine.raise_early_exceptions routine.execute end |
#execute_all(depends) ⇒ Object
Calls execute for each routine name in depends (an Array). Does nothing if given an empty Array or nil.
40 41 42 43 44 45 |
# File 'lib/rudy/routines/handlers/depends.rb', line 40 def execute_all(depends) return if depends.nil? || depends.empty? depends = depends.flatten.compact ld "Found depenencies: #{depends.join(', ')}" depends.each { |routine| execute(routine) } end |
#raise_early_exceptions(type, depends, rset, lbox, argv = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/rudy/routines/handlers/depends.rb', line 12 def raise_early_exceptions(type, depends, rset, lbox, argv=nil) unless depends.kind_of? Array raise Rudy::Error, "#{type} must be a kind of Array (#{depends.class})" end raise Rudy::Routines::EmptyDepends, type if depends.nil? || depends.empty? depends.flatten.compact.each do |name| raise Rudy::Routines::NoRoutine, name unless valid_routine?(name) end end |