Class | Capistrano::Deploy::RemoteDependency |
In: |
lib/capistrano/recipes/deploy/remote_dependency.rb
lib/capistrano/recipes/deploy/remote_dependency.rb |
Parent: | Object |
configuration | [R] | |
configuration | [R] | |
hosts | [R] | |
hosts | [R] |
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 9 9: def initialize(configuration) 10: @configuration = configuration 11: @success = true 12: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 9 9: def initialize(configuration) 10: @configuration = configuration 11: @success = true 12: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 32 32: def command(command, options={}) 33: @message ||= "`#{command}' could not be found in the path" 34: try("which #{command}", options) 35: self 36: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 32 32: def command(command, options={}) 33: @message ||= "`#{command}' could not be found in the path" 34: try("which #{command}", options) 35: self 36: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 14 14: def directory(path, options={}) 15: @message ||= "`#{path}' is not a directory" 16: try("test -d #{path}", options) 17: self 18: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 14 14: def directory(path, options={}) 15: @message ||= "`#{path}' is not a directory" 16: try("test -d #{path}", options) 17: self 18: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 20 20: def file(path, options={}) 21: @message ||= "`#{path}' is not a file" 22: try("test -f #{path}", options) 23: self 24: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 20 20: def file(path, options={}) 21: @message ||= "`#{path}' is not a file" 22: try("test -f #{path}", options) 23: self 24: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 38 38: def gem(name, version, options={}) 39: @message ||= "gem `#{name}' #{version} could not be found" 40: gem_cmd = configuration.fetch(:gem_command, "gem") 41: try("#{gem_cmd} specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'", options) 42: self 43: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 38 38: def gem(name, version, options={}) 39: @message ||= "gem `#{name}' #{version} could not be found" 40: gem_cmd = configuration.fetch(:gem_command, "gem") 41: try("#{gem_cmd} specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'", options) 42: self 43: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 45 45: def match(command, expect, options={}) 46: expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp) 47: 48: output_per_server = {} 49: try("#{command} ", options) do |ch, stream, out| 50: output_per_server[ch[:server]] ||= '' 51: output_per_server[ch[:server]] += out 52: end 53: 54: # It is possible for some of these commands to return a status != 0 55: # (for example, rake --version exits with a 1). For this check we 56: # just care if the output matches, so we reset the success flag. 57: @success = true 58: 59: errored_hosts = [] 60: output_per_server.each_pair do |server, output| 61: next if output =~ expect 62: errored_hosts << server 63: end 64: 65: if errored_hosts.any? 66: @hosts = errored_hosts.join(', ') 67: output = output_per_server[errored_hosts.first] 68: @message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}" 69: @success = false 70: end 71: 72: self 73: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 45 45: def match(command, expect, options={}) 46: expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp) 47: 48: output_per_server = {} 49: try("#{command} ", options) do |ch, stream, out| 50: output_per_server[ch[:server]] ||= '' 51: output_per_server[ch[:server]] += out 52: end 53: 54: # It is possible for some of these commands to return a status != 0 55: # (for example, rake --version exits with a 1). For this check we 56: # just care if the output matches, so we reset the success flag. 57: @success = true 58: 59: errored_hosts = [] 60: output_per_server.each_pair do |server, output| 61: next if output =~ expect 62: errored_hosts << server 63: end 64: 65: if errored_hosts.any? 66: @hosts = errored_hosts.join(', ') 67: output = output_per_server[errored_hosts.first] 68: @message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}" 69: @success = false 70: end 71: 72: self 73: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 84 84: def message 85: s = @message.dup 86: s << " (#{@hosts})" if @hosts && @hosts.any? 87: s 88: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 84 84: def message 85: s = @message.dup 86: s << " (#{@hosts})" if @hosts && @hosts.any? 87: s 88: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 75 75: def or(message) 76: @message = message 77: self 78: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 75 75: def or(message) 76: @message = message 77: self 78: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 80 80: def pass? 81: @success 82: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 80 80: def pass? 81: @success 82: end
# File lib/capistrano/recipes/deploy/remote_dependency.rb, line 26 26: def writable(path, options={}) 27: @message ||= "`#{path}' is not writable" 28: try("test -w #{path}", options) 29: self 30: end