Class: Blazing::Recipe
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .init_by_name(name, options = {}) ⇒ Object
- .list ⇒ Object
- .load_recipes! ⇒ Object
- .pretty_list ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Recipe
constructor
A new instance of Recipe.
- #run(target_options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Recipe
Returns a new instance of Recipe.
10 11 12 |
# File 'lib/blazing/recipe.rb', line 10 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/blazing/recipe.rb', line 8 def @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, = {}) "Blazing::Recipe::#{name.to_s.camelize}".constantize.new() end |
.list ⇒ Object
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_list ⇒ Object
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( = {}) @options.merge! end |