Class: Blazing::Recipe

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/blazing/recipe.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Recipe

Returns a new instance of Recipe.



10
11
12
# File 'lib/blazing/recipe.rb', line 10

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/blazing/recipe.rb', line 8

def options
  @options
end

Class Method Details

.init_by_name(name, options = {}) ⇒ Object



20
21
22
# File 'lib/blazing/recipe.rb', line 20

def init_by_name(name, options = {})
  "Blazing::Recipe::#{name.to_s.camelize}".constantize.new(options)
end

.listObject



24
25
26
27
28
29
30
31
# File 'lib/blazing/recipe.rb', line 24

def list
  load_recipes!
  descendants = []
  ObjectSpace.each_object(Class) do |k|
    descendants.unshift k if k < self
  end
  descendants
end

.load_recipes!Object



33
34
35
36
37
38
# File 'lib/blazing/recipe.rb', line 33

def load_recipes!
  gems = $:.select{|p| p.match /blazing-\w+(|-\d\.\d\.\d)\/lib/}.map { |r| r.scan(/blazing-\w+/)[0] }
  gems.each { |gem| require gem }
rescue LoadError
  # Here because using blazing from git now produces a match like 'blazing-269ee17d65d1'
end

.pretty_listObject



40
41
42
# File 'lib/blazing/recipe.rb', line 40

def pretty_list
  list.each { |r| puts r.to_s.demodulize.underscore }
end

Instance Method Details

#run(target_options = {}) ⇒ Object



14
15
16
# File 'lib/blazing/recipe.rb', line 14

def run(target_options = {})
  @options.merge! target_options
end