Class: Sabre::Release

Inherits:
Command show all
Defined in:
lib/sabre/release.rb

Instance Method Summary collapse

Methods inherited from Command

#indent, #initialize, #method_missing, #on, #on_error, #on_host, #run, #to_s, #unindent

Methods included from Base

#cd, #cp, #echo, #mv, #set, #synchronize

Constructor Details

This class inherits a constructor from Sabre::Command

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sabre::Command

Instance Method Details

#create(directory, options = Hash.new, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sabre/release.rb', line 4

def create(directory, options = Hash.new, &block)
  current = options[:current] || "#{ directory }/current"
  releases = options[:releases] || "#{ directory }/releases"

  set "RELEASE", "#{ releases }/`date +%s`"
  run %{ mkdir -p "$RELEASE" }

  run(&block)

  run %{ rm -f "#{ current }" }
  run %{ ln -s "$RELEASE" "#{ current }" }

  on_error do
    run %{ rm -rf "$RELEASE" }
  end
end