Class: Capistrano::Deploy::RemoteDependency

Class | Capistrano::Deploy::RemoteDependency
In: | lib/capistrano/recipes/deploy/remote_dependency.rb lib/capistrano/recipes/deploy/remote_dependency.rb
Parent: | Object

### Methods

command command directory directory file file gem gem match match message message new new or or pass? pass? writable writable

### Attributes

configuration | [R] |
configuration | [R] |
hosts | [R] |
hosts | [R] |

### Public Class methods

new(configuration)

[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

new(configuration)

[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={})

[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

command(command, options={})

[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

directory(path, options={})

[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

directory(path, options={})

[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={})

[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

file(path, options={})

[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={})

[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

gem(name, version, options={})

[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={})

[Source]

        # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 46
    46:       def match(command, expect, options={})
    47:         expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp)
    48:
    49:         output_per_server = {}
    50:         try("#{command} ", options) do |ch, stream, out|
    51:           output_per_server[ch[:server]] ||= ''
    52:           output_per_server[ch[:server]] += out
    53:         end
    54:
    55:         # It is possible for some of these commands to return a status != 0
    56:         # (for example, rake --version exits with a 1). For this check we
    57:         # just care if the output matches, so we reset the success flag.
    58:         @success = true
    59:
    60:         errored_hosts = []
    61:         output_per_server.each_pair do |server, output|
    62:           next if output =~ expect
    63:           errored_hosts << server
    64:         end
    65:
    66:         if errored_hosts.any?
    67:           @hosts = errored_hosts.join(', ')
    68:           output = output_per_server[errored_hosts.first]
    69:           @message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}"
    70:           @success = false
    71:         end
    72:
    73:         self
    74:       end

match(command, expect, options={})

[Source]

        # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 46
    46:       def match(command, expect, options={})
    47:         expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp)
    48:
    49:         output_per_server = {}
    50:         try("#{command} ", options) do |ch, stream, out|
    51:           output_per_server[ch[:server]] ||= ''
    52:           output_per_server[ch[:server]] += out
    53:         end
    54:
    55:         # It is possible for some of these commands to return a status != 0
    56:         # (for example, rake --version exits with a 1). For this check we
    57:         # just care if the output matches, so we reset the success flag.
    58:         @success = true
    59:
    60:         errored_hosts = []
    61:         output_per_server.each_pair do |server, output|
    62:           next if output =~ expect
    63:           errored_hosts << server
    64:         end
    65:
    66:         if errored_hosts.any?
    67:           @hosts = errored_hosts.join(', ')
    68:           output = output_per_server[errored_hosts.first]
    69:           @message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}"
    70:           @success = false
    71:         end
    72:
    73:         self
    74:       end

message()

[Source]

        # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 85
    85:       def message
    86:         s = @message.dup
    87:         s << " (#{@hosts})" if @hosts
    88:         s
    89:       end

message()

[Source]

        # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 85
    85:       def message
    86:         s = @message.dup
    87:         s << " (#{@hosts})" if @hosts
    88:         s
    89:       end

or(message)

[Source]

        # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 76
    76:       def or(message)
    77:         @message = message
    78:         self
    79:       end

or(message)

[Source]

        # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 76
    76:       def or(message)
    77:         @message = message
    78:         self
    79:       end

pass?()

[Source]

        # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 81
    81:       def pass?
    82:         @success
    83:       end

pass?()

[Source]

        # File lib/capistrano/recipes/deploy/remote_dependency.rb, line 81
    81:       def pass?
    82:         @success
    83:       end

writable(path, options={})

[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

writable(path, options={})

[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

[Validate]