Class: Capistrano::Deploy::RemoteDependency

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/recipes/deploy/remote_dependency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ RemoteDependency

Returns a new instance of RemoteDependency.



7
8
9
10
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 7

def initialize(configuration)
  @configuration = configuration
  @success = true
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



4
5
6
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 4

def configuration
  @configuration
end

#hostsObject (readonly)

Returns the value of attribute hosts.



5
6
7
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 5

def hosts
  @hosts
end

Instance Method Details

#command(command, options = {}) ⇒ Object



24
25
26
27
28
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 24

def command(command, options={})
  @message ||= "`#{command}' could not be found in the path"
  try("which #{command}", options)
  self
end

#directory(path, options = {}) ⇒ Object



12
13
14
15
16
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 12

def directory(path, options={})
  @message ||= "`#{path}' is not a directory"
  try("test -d #{path}", options)
  self
end

#gem(name, version, options = {}) ⇒ Object



30
31
32
33
34
35
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 30

def gem(name, version, options={})
  @message ||= "gem `#{name}' #{version} could not be found"
  gem_cmd = configuration.fetch(:gem_command, "gem")
  try("#{gem_cmd} specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'", options)
  self
end

#messageObject



46
47
48
49
50
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 46

def message
  s = @message.dup
  s << " (#{@hosts})" if @hosts && @hosts.any?
  s
end

#or(message) ⇒ Object



37
38
39
40
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 37

def or(message)
  @message = message
  self
end

#pass?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 42

def pass?
  @success
end

#writable(path, options = {}) ⇒ Object



18
19
20
21
22
# File 'lib/capistrano/recipes/deploy/remote_dependency.rb', line 18

def writable(path, options={})
  @message ||= "`#{path}' is not writable"
  try("test -w #{path}", options)
  self
end