Class: RailsWizard::Command
- Inherits:
-
Thor
- Object
- Thor
- RailsWizard::Command
- Includes:
- Thor::Actions
- Defined in:
- lib/rails_wizard/command.rb
Instance Method Summary collapse
Instance Method Details
#list(category = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails_wizard/command.rb', line 32 def list(category = nil) if category recipes = RailsWizard::Recipes.for(category).map{|r| RailsWizard::Recipe.from_mongo(r) } else recipes = RailsWizard::Recipes.list_classes end recipes.each do |recipe| puts recipe.key.ljust(15) + "# #{recipe.description}" end end |
#new(name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_wizard/command.rb', line 9 def new(name) if [:recipes] run_template(name, [:recipes]) else @recipes = [] while recipe = ask("#{print_recipes}#{bold}Which recipe would you like to add? #{clear}#{yellow}(blank to finish)#{clear}") if recipe == '' run_template(name, @recipes) break elsif RailsWizard::Recipes.list.include?(recipe) @recipes << recipe puts puts "> #{green}Added '#{recipe}' to template.#{clear}" else puts puts "> #{red}Invalid recipe, please try again.#{clear}" end end end end |