Module: Minestrone::Deploy::Strategy

Defined in:
lib/minestrone/recipes/deploy/strategy.rb,
lib/minestrone/recipes/deploy/strategy/base.rb,
lib/minestrone/recipes/deploy/strategy/copy.rb,
lib/minestrone/recipes/deploy/strategy/remote_cache.rb

Defined Under Namespace

Classes: Base, Copy, RemoteCache

Class Method Summary collapse

Class Method Details

.new(strategy, config = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/minestrone/recipes/deploy/strategy.rb', line 6

def self.new(strategy, config = {})
  strategy_file = "minestrone/recipes/deploy/strategy/#{strategy}"
  strategy_const = strategy.to_s.capitalize.gsub(/_(.)/) { $1.upcase }

  require(strategy_file) unless const_defined?(strategy_const)

  if const_defined?(strategy_const)
    const_get(strategy_const).new(config)
  else
    raise Minestrone::Error, "could not find `#{name}::#{strategy_const}' in `#{strategy_file}'"
  end
rescue LoadError
  raise Minestrone::Error, "could not find any strategy named `#{strategy}'"
end