Class: Heroku::Bartender::Sandbox

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku/bartender/sandbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sha) ⇒ Sandbox

Returns a new instance of Sandbox.



9
10
11
12
13
14
# File 'lib/heroku/bartender/sandbox.rb', line 9

def initialize(sha)
  @sha         = sha
  @name        = gen_sandbox_name
  @sandbox_dir = "#{Dir.tmpdir}/#{@name}/"
  @current_dir = "#{Dir.pwd}/"
end

Instance Attribute Details

#current_dirObject

Returns the value of attribute current_dir.



7
8
9
# File 'lib/heroku/bartender/sandbox.rb', line 7

def current_dir
  @current_dir
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/heroku/bartender/sandbox.rb', line 7

def name
  @name
end

#sandbox_dirObject

Returns the value of attribute sandbox_dir.



7
8
9
# File 'lib/heroku/bartender/sandbox.rb', line 7

def sandbox_dir
  @sandbox_dir
end

#shaObject

Returns the value of attribute sha.



7
8
9
# File 'lib/heroku/bartender/sandbox.rb', line 7

def sha
  @sha
end

Instance Method Details

#predeploy(command) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/heroku/bartender/sandbox.rb', line 16

def predeploy(command)
  copy_current_repo_to_me
  Dir.chdir(@sandbox_dir) do
    `git checkout #{@sha}`
    rc = system(command)
    if rc.nil? || ! rc
      raise "Error executing pre-deploy command '#{command}': #{$?}"
    end
  end
end