class Taketo::Constructs::Command
Attributes
command[RW]
description[RW]
Public Class Methods
default()
click to toggle source
# File lib/taketo/constructs/command.rb, line 11 def self.default new(:default).tap { |cmd| cmd.command = "bash" } end
explicit_command(command_string)
click to toggle source
# File lib/taketo/constructs/command.rb, line 15 def self.explicit_command(command_string) new(:explicit_command).tap { |cmd| cmd.command = command_string.to_s } end
Public Instance Methods
render(server, options = {})
click to toggle source
# File lib/taketo/constructs/command.rb, line 19 def render(server, options = {}) %Q[#{location(server, options)} #{environment_variables(server)} #{command}].strip.squeeze(" ") end
to_s()
click to toggle source
# File lib/taketo/constructs/command.rb, line 23 def to_s command.to_s end
Private Instance Methods
environment_variables(server)
click to toggle source
# File lib/taketo/constructs/command.rb, line 34 def environment_variables(server) server.environment_variables.map { |k, v| %Q[#{k}=#{shellescape v}] }.join(" ") end
location(server, options = {})
click to toggle source
# File lib/taketo/constructs/command.rb, line 29 def location(server, options = {}) directory = options.fetch(:directory) { server.default_location } %Q[cd #{shellescape directory};] if directory end