Module: Rudy::Routines::ScriptHelper

Extended by:
ScriptHelper
Includes:
HelperBase
Included in:
ScriptHelper
Defined in:
lib/rudy/routines/helpers/scripthelper.rb

Overview

– TODO: Rename to ShellHelper ++

Constant Summary collapse

@@script_types =
[:after, :before, :after_local, :before_local, :script, :script_local]
@@script_config_file =
"rudy-config.yml"

Instance Method Summary collapse

Methods included from HelperBase

#command_separator, #execute_rbox_command, #keep_going?

Methods included from Huxtable

change_environment, change_position, change_region, change_role, change_zone, #check_keys, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_size, #current_user, #current_user_keypairpath, debug?, #debug?, domain, domain_exists?, #group_metadata, #has_keypair?, #has_keys?, #has_pem_keys?, #has_root_keypair?, keypair_path_to_name, #known_machine_group?, #root_keypairname, #root_keypairpath, #switch_user, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath

Instance Method Details

#after(routine, sconf, machine, rbox) ⇒ Object



55
56
57
58
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 55

def after(routine, sconf, machine, rbox)
  raise "ScriptHelper: Not a Rudy::Machine" unless machine.is_a?(Rudy::Machine)
  execute_command(:after, routine, sconf, machine.name, rbox)
end

#after?(routine) ⇒ Boolean

Returns:

  • (Boolean)


59
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 59

def after?(routine); execute_command?(:after, routine); end

#after_local(routine, sconf, rbox) ⇒ Object



39
40
41
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 39

def after_local(routine, sconf, rbox)
  execute_command(:after_local, routine, sconf, 'localhost', rbox)
end

#after_local?(routine) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 42

def after_local?(routine)
  routine[:after_local] = {                 # See before_local note
    Rudy.sysinfo.user.to_sym => routine.delete(:after_local) 
  } if routine[:after_local].is_a?(Proc)
  execute_command?(:after_local, routine)
end

#before(routine, sconf, machine, rbox) ⇒ Object



49
50
51
52
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 49

def before(routine, sconf, machine, rbox)
  raise "ScriptHelper: Not a Rudy::Machine" unless machine.is_a?(Rudy::Machine)
  execute_command(:before, routine, sconf, machine.name, rbox)
end

#before?(routine) ⇒ Boolean

Returns:

  • (Boolean)


53
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 53

def before?(routine); execute_command?(:before, routine); end

#before_local(routine, sconf, rbox) ⇒ Object

TODO: refactor using this_method



16
17
18
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 16

def before_local(routine, sconf, rbox)
  execute_command(:before_local, routine, sconf, 'localhost', rbox)
end

#before_local?(routine) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 19

def before_local?(routine)
  # before_local generally doesn't take a user name like the remote
  # before block so we add it here (unless the user did specify it)
  routine[:before_local] = { 
    Rudy.sysinfo.user.to_sym => routine.delete(:before_local) 
  } if routine[:before_local].is_a?(Proc)
  execute_command?(:before_local, routine)
end

#script(routine, sconf, machine, rbox) ⇒ Object



61
62
63
64
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 61

def script(routine, sconf, machine, rbox)
  raise "ScriptHelper: Not a Rudy::Machine" unless machine.is_a?(Rudy::Machine)
  execute_command(:script, routine, sconf, machine.name, rbox)
end

#script?(routine) ⇒ Boolean

Returns:

  • (Boolean)


65
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 65

def script?(routine); execute_command?(:script, routine); end

#script_local(routine, sconf, rbox) ⇒ Object



27
28
29
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 27

def script_local(routine, sconf, rbox)
  execute_command(:script_local, routine, sconf, 'localhost', rbox)
end

#script_local?(routine) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/rudy/routines/helpers/scripthelper.rb', line 30

def script_local?(routine)
  # before_local generally doesn't take a user name like the remote
  # before block so we add it here (unless the user did specify it)
  routine[:script_local] = { 
    Rudy.sysinfo.user.to_sym => routine.delete(:script_local) 
  } if routine[:script_local].is_a?(Proc)
  execute_command?(:script_local, routine)
end