Parent

Class Index [+]

Quicksearch

Capistrano::Deploy::RemoteDependency

Attributes

configuration[R]
hosts[R]

Public Class Methods

new(configuration) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 9
 9:       def initialize(configuration)
10:         @configuration = configuration
11:         @success = true
12:         @hosts = nil
13:       end

Public Instance Methods

command(command, options={}) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 33
33:       def command(command, options={})
34:         @message ||= "`#{command}' could not be found in the path"
35:         try("which #{command}", options)
36:         self
37:       end
deb(name, version, options={}) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 46
46:       def deb(name, version, options={})
47:         @message ||= "package `#{name}' #{version} could not be found"
48:         try("dpkg -s #{name} | grep '^Version: #{version}'", options)
49:         self
50:       end
directory(path, options={}) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 15
15:       def directory(path, options={})
16:         @message ||= "`#{path}' is not a directory"
17:         try("test -d #{path}", options)
18:         self
19:       end
file(path, options={}) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 21
21:       def file(path, options={})
22:         @message ||= "`#{path}' is not a file"
23:         try("test -f #{path}", options)
24:         self
25:       end
gem(name, version, options={}) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 39
39:       def gem(name, version, options={})
40:         @message ||= "gem `#{name}' #{version} could not be found"
41:         gem_cmd = configuration.fetch(:gem_command, "gem")
42:         try("#{gem_cmd} specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'", options)
43:         self
44:       end
match(command, expect, options={}) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 58
58:       def match(command, expect, options={})
59:         expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp)
60: 
61:         output_per_server = {} 
62:         try("#{command} ", options) do |ch, stream, out| 
63:           output_per_server[ch[:server]] ||= '' 
64:           output_per_server[ch[:server]] += out 
65:         end 
66: 
67:         # It is possible for some of these commands to return a status != 0
68:         # (for example, rake --version exits with a 1). For this check we
69:         # just care if the output matches, so we reset the success flag.
70:         @success = true
71: 
72:         errored_hosts = [] 
73:         output_per_server.each_pair do |server, output| 
74:           next if output =~ expect
75:           errored_hosts << server 
76:         end 
77: 
78:         if errored_hosts.any?
79:           @hosts = errored_hosts.join(', ')
80:           output = output_per_server[errored_hosts.first]
81:           @message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}"
82:           @success = false
83:         end 
84: 
85:         self 
86:       end
message() click to toggle source
     # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 97
 97:       def message
 98:         s = @message.dup
 99:         s << " (#{@hosts})" if @hosts
100:         s
101:       end
or(message) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 88
88:       def or(message)
89:         @message = message
90:         self
91:       end
pass?() click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 93
93:       def pass?
94:         @success
95:       end
rpm(name, version, options={}) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 52
52:       def rpm(name, version, options={})
53:         @message ||= "package `#{name}' #{version} could not be found"
54:         try("rpm -q #{name} | grep '#{version}'", options)
55:         self
56:       end
writable(path, options={}) click to toggle source
    # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 27
27:       def writable(path, options={})
28:         @message ||= "`#{path}' is not writable"
29:         try("test -w #{path}", options)
30:         self
31:       end

Private Instance Methods

try(command, options) click to toggle source
     # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 105
105:       def try(command, options)
106:         return unless @success # short-circuit evaluation
107:         configuration.invoke_command(command, options) do |ch,stream,out|
108:           warn "#{ch[:server]}: #{out}" if stream == :err
109:           yield ch, stream, out if block_given?
110:         end
111:       rescue Capistrano::CommandError => e
112:         @success = false
113:         @hosts = e.hosts.join(', ')
114:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.