class EY::Serverside::Callbacks::Collection::Base

Public Class Methods

load(paths) click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 10
def self.load(paths)
  new(paths)
end
new(paths) click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 14
def initialize(paths)
  @paths = paths
  load_hooks
end

Public Instance Methods

all() click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 19
def all
  hooks
end
distribute(runner, callback) click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 34
def distribute(runner, callback)
  Distributor.distribute(
    runner,
    minimize_ruby(
      matching(callback)
    )
  )
end
empty?() click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 23
def empty?
  hooks.empty?
end
execute(config, shell, callback) click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 43
def execute(config, shell, callback)
  matches = matching(callback)

  if matches.empty?
    shell.info("No hooks detected for #{callback}. Skipping.")
    return
  end

  Executor.execute(config, shell, matches)
end
matching(callback) click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 27
def matching(callback)
  favor(
    :ruby,
    all.select {|hook| hook.matches?(callback.to_sym)}
  )
end

Private Instance Methods

favor(flavor, hooks) click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 55
def favor(flavor, hooks)
  (
    hooks.select {|hook| hook.flavor == flavor} + 
    hooks.reject {|hook| hook.flavor == flavor}
  ).first(1)
end
hooks() click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 78
def hooks
  @hooks ||= []
end
load_hooks() click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 70
def load_hooks
  raise "Unimplemented"
end
minimize_ruby(hooks) click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 62
def minimize_ruby(hooks)
  first_ruby = hooks.select {|hook| hook.flavor == :ruby}.first

  return hooks unless first_ruby

  ([first_ruby] + hooks.select {|hook| hook.flavor != :ruby}).flatten
end
paths() click to toggle source
# File lib/engineyard-serverside/callbacks/collection/base.rb, line 74
def paths
  @paths
end