Sha256: d3ff2ec360dabea0582607885a57c228b8c8db21792a040da03e1eb1fe0a3e46
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require 'pathname' require 'engineyard-serverside/spawner' class EY::Serverside::Source attr_reader :uri, :opts, :source_cache, :ref, :shell alias repository_cache source_cache class << self attr_reader :required_opts def require_opts(*names) @required_opts ||= [] @required_opts += names end end 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] @uri = @opts[:uri].to_s if @opts[:uri] @source_cache = Pathname.new(@opts[:repository_cache]) if @opts[:repository_cache] end protected def in_source_cache(&block) raise ArgumentError, "Block required" unless block source_cache.mkpath Dir.chdir(source_cache, &block) end def escape(*shell_commands) Escape.shell_command(shell_commands) end def runner EY::Serverside::Spawner end # Internal: Run a command. # # cmd - A string command. # # Returns an instance of Spawner. def run(cmd) runner.run(cmd, shell, nil) end # Internal: Run a command and return the output. # # cmd - A string command. # # Returns the output of the command. def run_and_output(cmd) run(cmd).output end # Internal: Run a command and check if it was successful. # # cmd - A string command. # # Returns success. def run_and_success?(cmd) run(cmd).success? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
engineyard-serverside-2.3.0 | lib/engineyard-serverside/source.rb |