class Console::Event::Spawn

Attributes

arguments[R]
environment[R]
options[R]

Public Class Methods

for(*arguments, **options) click to toggle source
# File lib/console/event/spawn.rb, line 26
def self.for(*arguments, **options)
        # Extract out the command environment:
        if arguments.first.is_a?(Hash)
                self.new(*arguments, **options)
        else
                self.new(nil, arguments, **options)
        end
end
new(environment, *arguments, **options) click to toggle source
# File lib/console/event/spawn.rb, line 35
def initialize(environment, *arguments, **options)
        @environment = environment
        @arguments = arguments
        @options = options
end
register(terminal) click to toggle source
# File lib/console/event/spawn.rb, line 51
def self.register(terminal)
        terminal[:shell_command] ||= terminal.style(:blue, nil, :bold)
end

Public Instance Methods

chdir_string(options) click to toggle source
# File lib/console/event/spawn.rb, line 45
def chdir_string(options)
        if options and chdir = options[:chdir]
                " in #{chdir}"
        end
end
format(output, terminal, verbose) click to toggle source
# File lib/console/event/spawn.rb, line 59
def format(output, terminal, verbose)
        arguments = @arguments.flatten.collect(&:to_s)
        
        output.puts "  #{terminal[:shell_command]}#{arguments.join(' ')}#{terminal.reset}#{chdir_string(options)}"
        
        if verbose and @environment
                @environment.each do |key, value|
                        output.puts "    export #{key}=#{value}"
                end
        end
end
to_h() click to toggle source
# File lib/console/event/spawn.rb, line 55
def to_h
        {environment: @environment, arguments: @arguments, options: @options}
end