Sha256: 0ae6d429017fe7c38a48438ffbc86602ff560c41f5255b88ea46f8bf37fca754

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

require 'capistrano/cli'
require 'pp'

module Sprinkle
  module Actors
    class Dummy < Actor #:nodoc:

      def initialize(&block) #:nodoc:
        # @config.set(:_sprinkle_actor, self)
        @roles={}
        self.instance_eval &block
      end

      def role(role, server, opts={})
        @roles[role]||=[]
        @roles[role] << [ server, opts ]
      end
      
      # Determines if there are any servers for the given roles
      def servers_for_role?(roles)
        roles=Array(roles)
        roles.any? { |r| @roles.keys.include?(r) }
      end
      
      def install(installer, roles, opts={})
        if per_host=opts.delete(:per_host)
          servers_per_role(roles).each do |server|
            installer.reconfigure_for(server)
            installer.announce
            process(installer.package.name, installer.install_sequence, server, opts)
          end
        else
          process(installer.package, installer.install_sequence, roles, opts)
        end
      end
      
      def verify(verifier, roles, opts = {})
        process(verifier.package.name, verifier.commands, roles, opts = {})
      end
      
      def servers_per_role(role)
        @roles[role]
      end

      def process(name, commands, roles, opts = {}) #:nodoc:
        # puts "PROCESS: #{name} on #{roles}"
        pp commands
        # return false if suppress_and_return_failures
        true
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sprinkle-0.6.2 lib/sprinkle/actors/dummy.rb
sprinkle-0.6.1.1 lib/sprinkle/actors/dummy.rb
sprinkle-0.6.1 lib/sprinkle/actors/dummy.rb
sprinkle-0.6.0 lib/sprinkle/actors/dummy.rb