Class: Shuttle::Deploy
- Inherits:
-
Object
- Object
- Shuttle::Deploy
- Includes:
- Helpers, PathHelpers
- Defined in:
- lib/shuttle/deploy.rb
Direct Known Subclasses
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#ssh ⇒ Object
readonly
Returns the value of attribute ssh.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#available_releases ⇒ Array<Integer>
Get list of all existing releases.
-
#initialize(config, ssh, target, environment) ⇒ Deploy
constructor
A new instance of Deploy.
-
#last_version ⇒ Integer
Get current deploy version.
Methods included from PathHelpers
#current_path, #deploy_path, #release_path, #scm_path, #shared_path, #version_path
Methods included from Helpers
#deployer_hostname, #error, #git_installed?, #git_remote, #log, #release_exists?, #stream_output, #svn_installed?, #warn
Constructor Details
#initialize(config, ssh, target, environment) ⇒ Deploy
Returns a new instance of Deploy.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/shuttle/deploy.rb', line 12 def initialize(config, ssh, target, environment) @config = config @target = target @ssh = ssh @environment = environment if ssh.file_exists?(version_path) res = ssh.capture("cat #{version_path}") @version = (res.empty? ? 1 : Integer(res) + 1).to_s else @version = 1 end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/shuttle/deploy.rb', line 10 def config @config end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
8 9 10 |
# File 'lib/shuttle/deploy.rb', line 8 def environment @environment end |
#ssh ⇒ Object (readonly)
Returns the value of attribute ssh.
6 7 8 |
# File 'lib/shuttle/deploy.rb', line 6 def ssh @ssh end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
7 8 9 |
# File 'lib/shuttle/deploy.rb', line 7 def target @target end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
9 10 11 |
# File 'lib/shuttle/deploy.rb', line 9 def version @version end |
Instance Method Details
#available_releases ⇒ Array<Integer>
Get list of all existing releases
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/shuttle/deploy.rb', line 34 def available_releases if ssh.directory_exists?(deploy_path('releases')) releases = ssh.capture("ls --color=never #{deploy_path}/releases") releases. scan(/[\d]+/). map { |s| s.strip.to_i }. sort else [] end end |
#last_version ⇒ Integer
Get current deploy version
28 29 30 |
# File 'lib/shuttle/deploy.rb', line 28 def last_version @last_version ||= ssh.read_file(version_path).to_i end |