Sha256: 8d9431bb879229633979e1721021e9458190d066a693176585ba69d60cd45ec4

Contents?: true

Size: 738 Bytes

Versions: 18

Compression:

Stored size: 738 Bytes

Contents

module Aruba
  class Config
    attr_reader :hooks
    
    def initialize
      @hooks = Hooks.new
    end
    
    # Register a hook to be called before Aruba runs a command
    def before_cmd(&block)
      @hooks.append(:before_cmd, block)
    end
  end
  
  #nodoc
  class Hooks
    def initialize
      @store = Hash.new do |hash, key|
        hash[key] = []
      end
    end
    
    def append(label, block)
      @store[label] << block
    end
    
    def execute(label, context, *args)
      @store[label].each do |block|
        context.instance_exec(*args, &block)
      end
    end
  end
  
  class << self
    attr_accessor :config

    def configure
      yield config
    end
    
  end
  
  self.config = Config.new
end

Version data entries

18 entries across 18 versions & 5 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/aruba-0.6.1/lib/aruba/config.rb
aruba-0.6.1 lib/aruba/config.rb
aruba-0.6.0 lib/aruba/config.rb
aruba-0.5.4 lib/aruba/config.rb
aruba-0.5.3 lib/aruba/config.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/aruba-0.5.1/lib/aruba/config.rb
aruba-0.5.2 lib/aruba/config.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/aruba-0.5.1/lib/aruba/config.rb
aruba-0.5.1 lib/aruba/config.rb
aruba-0.5.0 lib/aruba/config.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/aruba-0.4.11/lib/aruba/config.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/aruba-0.4.11/lib/aruba/config.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/aruba-0.4.11/lib/aruba/config.rb
ftl-0.2.0 vendor/bundle/gems/aruba-0.4.11/lib/aruba/config.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/aruba-0.4.11/lib/aruba/config.rb
aruba-0.4.11 lib/aruba/config.rb
aruba-0.4.10 lib/aruba/config.rb
aruba-0.4.9 lib/aruba/config.rb