Class: Pulsar::Helpers::Capistrano::DSL

Inherits:
Object
  • Object
show all
Includes:
Pulsar::Helpers::Clamp
Defined in:
lib/pulsar/helpers/capistrano.rb

Instance Method Summary collapse

Methods included from Pulsar::Helpers::Clamp

included

Constructor Details

#initialize(cap_conf, &dsl_code) ⇒ DSL

Returns a new instance of DSL.



9
10
11
12
# File 'lib/pulsar/helpers/capistrano.rb', line 9

def initialize(cap_conf, &dsl_code)
  @cap_conf = cap_conf
  instance_eval(&dsl_code)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pulsar/helpers/capistrano.rb', line 14

def method_missing(meth, *args, &block)
  recipes = "#{ENV['CONFIG_PATH']}/recipes/#{meth}"

  File.directory?(recipes) || raise("There are no recipes of type #{meth}")

  args.each do |arg|
    recipe = "#{recipes}/#{arg}.rb"
    File.exists?(recipe) || raise("There is no #{arg} recipe")

    @cap_conf.send(:load, recipe)
  end
end