Sha256: 49c1b5d452afd86c2b189aa8be4a13130e5079ce3b1e2d7d64abfe45c3f7d6b8

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

require 'blazing/logger'
require 'active_support/inflector'

class Blazing::Recipe

  include Blazing::Logger

  attr_reader :options

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

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

  class << self

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

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

    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 }
    end

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blazing-0.2.11 lib/blazing/recipe.rb