class EY::Serverside::Source

Attributes

required_opts[R]
opts[R]
ref[R]
repository_cache[R]
shell[R]
source_cache[R]
uri[R]

Public Class Methods

new(shell, opts={}) click to toggle source
# File lib/engineyard-serverside/source.rb, line 16
def initialize(shell, opts={})
  @shell = shell
  @opts = opts

  missing = self.class.required_opts && self.class.required_opts.reject {|name| @opts[name] }
  if missing and missing.any?
    raise ArgumentError,
      "Internal error: Missing keys #{missing.join(',')}. Required: #{self.class.required_opts.join(', ')}"
  end

  @ref = @opts[:ref].to_s.strip
  @uri = @opts[:uri].to_s if @opts[:uri]
  @source_cache = Pathname.new(@opts[:repository_cache]) if @opts[:repository_cache]
end
require_opts(*names) click to toggle source
# File lib/engineyard-serverside/source.rb, line 10
def require_opts(*names)
  @required_opts ||= []
  @required_opts += names
end

Protected Instance Methods

escape(*shell_commands) click to toggle source
# File lib/engineyard-serverside/source.rb, line 39
def escape(*shell_commands)
  Escape.shell_command(shell_commands)
end
in_source_cache(&block) click to toggle source
# File lib/engineyard-serverside/source.rb, line 33
def in_source_cache(&block)
  raise ArgumentError, "Block required" unless block
  source_cache.mkpath
  Dir.chdir(source_cache, &block)
end
run(cmd) click to toggle source

Internal: Run a command.

cmd - A string command.

Returns an instance of Spawner.

# File lib/engineyard-serverside/source.rb, line 52
def run(cmd)
  runner.run(cmd, shell, nil)
end
run_and_output(cmd) click to toggle source

Internal: Run a command and return the output.

cmd - A string command.

Returns the output of the command.

# File lib/engineyard-serverside/source.rb, line 61
def run_and_output(cmd)
  run(cmd).output
end
run_and_success?(cmd) click to toggle source

Internal: Run a command and check if it was successful.

cmd - A string command.

Returns success.

# File lib/engineyard-serverside/source.rb, line 70
def run_and_success?(cmd)
  run(cmd).success?
end
runner() click to toggle source
# File lib/engineyard-serverside/source.rb, line 43
def runner
  EY::Serverside::Spawner
end