class KrakenMobile::CommandHelper

Public Instance Methods

build_command(commands) click to toggle source
# File lib/kraken-mobile/helpers/command_helper.rb, line 11
def build_command commands
        commands.compact*' '
end
build_export_env_command(env_variables) click to toggle source

Exports a list of environment variables to the users computer.

# File lib/kraken-mobile/helpers/command_helper.rb, line 16
def build_export_env_command env_variables
        commands = env_variables.map { |key, value|
                user_is_using_windows ? "(SET \"#{key}=#{value}\")" : "#{key}=#{value};export #{key}"
        }
        commands.join(terminal_command_separator)
end
execute_command(process_number, command) click to toggle source
# File lib/kraken-mobile/helpers/command_helper.rb, line 23
def execute_command process_number, command
        output = open("|#{command}", 'r') { |output| show_output(output, process_number)  }
        exitstatus = $?.exitstatus
end
show_output(output, process_number) click to toggle source
# File lib/kraken-mobile/helpers/command_helper.rb, line 28
def show_output(output, process_number)
        loop do
                begin
                        line = output.readline()
                        $stdout.print "#{process_number}> #{line}"
                        $stdout.flush
                end
        end rescue EOFError
end
terminal_command_separator() click to toggle source
# File lib/kraken-mobile/helpers/command_helper.rb, line 7
def terminal_command_separator
        user_is_using_windows ? ' & ' : ';'
end
user_is_using_windows() click to toggle source
# File lib/kraken-mobile/helpers/command_helper.rb, line 3
def user_is_using_windows
        RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
end