Module: Rudy::Routines::HelperBase

Includes:
Huxtable
Included in:
DependsHelper, DiskHelper, SCMHelper, ScriptHelper, UserHelper
Defined in:
lib/rudy/routines/helper.rb

Instance Method Summary collapse

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

#command_separator(cmd, user) ⇒ Object

Returns a formatted string for printing command info



34
35
36
37
38
39
# File 'lib/rudy/routines/helper.rb', line 34

def command_separator(cmd, user)
  cmd ||= ""
  cmd, user = cmd.to_s, user.to_s
  prompt = user == "root" ? "#" : "$"
  ("%s%s%s %s" % [$/, user, prompt, cmd.bright])
end

#execute_rbox_command(ret = nil, &command) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rudy/routines/helper.rb', line 8

def execute_rbox_command(ret=nil, &command)
  begin
    ret = command.call if command
    return unless ret.is_a?(Rye::Rap)
    puts '  ' << ret.stdout.join("#{$/}  ") if !ret.stdout.empty?
    print_response(ret)
  rescue IOError => ex
    STDERR.puts "  Connection Error (#{ex.message})".color(:red)
    exit 12 unless keep_going?
  rescue Rye::CommandError => ex
    print_response(ex)
    exit 12 unless keep_going?
  rescue Rye::CommandNotFound => ex
    STDERR.puts "  CommandNotFound: #{ex.message}".color(:red)
    STDERR.puts ex.backtrace if Rudy.debug?
    exit 12 unless keep_going?
  end
  
  ret
end

#keep_going?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rudy/routines/helper.rb', line 29

def keep_going?
  Annoy.pose_question("  Keep going?\a ", /yes|y|ya|sure|you bet!/i, STDERR)
end