module ActiveScripts class Recipe # INFO: ActiveScripts::Recipe contains code that is # for retrieving and validating recipes. RECIPES = Dir.entries("#{File.dirname(__FILE__)}/recipes") .drop(2) .reject { |f| ["base.rb"].include?(f) } .map { |f| File.basename(f, ".rb") } attr_accessor :recipes, :packages def initialize(recipes=[]) @recipes = recipes.strip @packages = [] end def self.find(recipes=[]) new(recipes).find end def find if @recipes.blank? say(" - Recipes skipped!") else assert_valid_recipes! generate_recipe_packages! end return(@packages.strip) end private def assert_valid_recipes! @recipes.each do |recipe| unless RECIPES.include?(recipe) raise ArgumentError, "Unknown recipe system: #{recipe.inspect}. Valid recipes are listed in the documentation." end end end def generate_recipe_packages! @recipes.each do |recipe| @packages << "ActiveScripts::Recipes::#{recipe.camelize}".constantize.packages end end end end