module RailsWizard::Recipes
Public Class Methods
[](key)
click to toggle source
# File lib/rails_wizard/recipes.rb, line 22 def self.[](key) @@list[key.to_s] end
add(recipe)
click to toggle source
# File lib/rails_wizard/recipes.rb, line 6 def self.add(recipe) RailsWizard::Recipes.const_set ActiveSupport::Inflector.camelize(recipe.key), recipe @@list[recipe.key] = recipe (@@categories[recipe.category.to_s] ||= []) << recipe.key @@categories[recipe.category.to_s].uniq! recipe end
add_from_directory(directory)
click to toggle source
# File lib/rails_wizard/recipes.rb, line 46 def self.add_from_directory(directory) Dir.foreach(directory) do |file| path = File.join(directory, file) next unless path.match /\.rb$/ key = File.basename(path, '.rb') recipe = Recipe.generate(key, File.open(path)) add(recipe) end end
categories()
click to toggle source
# File lib/rails_wizard/recipes.rb, line 34 def self.categories @@categories.keys.sort end
clear()
click to toggle source
# File lib/rails_wizard/recipes.rb, line 14 def self.clear self.list.each do |recipe_key| send(:remove_const, ActiveSupport::Inflector.camelize(recipe_key)) end @@categories = {} @@list = {} end
for(category)
click to toggle source
# File lib/rails_wizard/recipes.rb, line 38 def self.for(category) (@@categories[category.to_s] || []).sort end
list()
click to toggle source
# File lib/rails_wizard/recipes.rb, line 26 def self.list @@list.keys.sort end
list_classes()
click to toggle source
# File lib/rails_wizard/recipes.rb, line 30 def self.list_classes @@list.values.sort_by{|c| c.key} end
remove_from_category(category, recipe)
click to toggle source
# File lib/rails_wizard/recipes.rb, line 42 def self.remove_from_category(category, recipe) (@@categories[category.to_s] ||= []).delete(recipe.key) end