Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7386

Show
Ignore:
Timestamp:
09/01/07 02:10:45 (10 months ago)
Author:
minam
Message:

Add a "match" remote dependency method (closes #9379)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/capistrano/CHANGELOG

    r7384 r7386  
    11*SVN* 
     2 
     3* Add a "match" remote dependency method [Adam Greene] 
    24 
    35* Allow auth-caching of subversion credentials to be enabled via :scm_auth_cache [tsmith] 
  • tools/capistrano/lib/capistrano/recipes/deploy/remote_dependency.rb

    r7129 r7386  
    3535      end 
    3636 
     37      def match(command, expect, options={}) 
     38        expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp) 
     39 
     40        output_per_server = {}  
     41        try("#{command} ", options) do |ch, stream, out|  
     42          output_per_server[ch[:server]] ||= ''  
     43          output_per_server[ch[:server]] += out  
     44        end  
     45 
     46        # It is possible for some of these commands to return a status != 0 
     47        # (for example, rake --version exits with a 1). For this check we 
     48        # just care if the output matches, so we reset the success flag. 
     49        @success = true 
     50 
     51        errored_hosts = []  
     52        output_per_server.each_pair do |server, output|  
     53          next if output =~ expect 
     54          errored_hosts << server  
     55        end  
     56 
     57        if errored_hosts.any? 
     58          @hosts = errored_hosts.join(', ') 
     59          output = output_per_server[errored_hosts.first] 
     60          @message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}" 
     61          @success = false 
     62        end  
     63 
     64        self  
     65      end 
     66 
    3767      def or(message) 
    3868        @message = message 
     
    5686        configuration.run(command, options) do |ch,stream,out| 
    5787          warn "#{ch[:server]}: #{out}" if stream == :err 
     88          yield ch, stream, out if block_given? 
    5889        end 
    5990      rescue Capistrano::CommandError => e