From 0d0dd7d0e49ae9d9b0767debeff6d36bb3ea0ee1 Mon Sep 17 00:00:00 2001 From: Kevin Faustino Date: Thu, 13 Jan 2011 22:05:58 -0500 Subject: [PATCH] Clean up formatting of questions --- lib/template/core_extensions.rb | 17 +++++++++++------ lib/template/recipes/design.rb | 2 +- lib/template/templater.rb | 4 +++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/template/core_extensions.rb b/lib/template/core_extensions.rb index 1467617..226ef26 100644 --- a/lib/template/core_extensions.rb +++ b/lib/template/core_extensions.rb @@ -9,22 +9,27 @@ def initialize_templater @post_bundler_strategies = [] @template_options = {} end - + def execute_post_bundler_strategies post_bundler_strategies.each {|strategy| strategy.call } end def load_options - @template_options[:design] = ask("Which design framework? [none(default), compass]: ").downcase - @template_options[:design] = "none" if @template_options[:design].nil? + say "Would you like to use a design framework?\n", Thor::Shell::Color::BLUE + print_table [ ['Option','Framework'], ['1', 'Compass with blueprint semantic'] ], :ident => 2 + design_input = ask("Option: ", Thor::Shell::Color::BLUE) + @template_options[:design] = case design_input + when "1" + :compass + else + :none + end end def recipe(name) File.join File.dirname(__FILE__), 'recipes', "#{name}.rb" end - # TODO: Refactor loading of files - def load_snippet(name, group) path = File.expand_path name, snippet_path(group) File.read path @@ -33,7 +38,7 @@ def load_snippet(name, group) def load_template(name, group) path = File.expand_path name, template_path(group) File.read path - end + end def snippet_path(name) File.join(File.dirname(__FILE__), 'snippets', name) diff --git a/lib/template/recipes/design.rb b/lib/template/recipes/design.rb index 00d25de..ce90107 100644 --- a/lib/template/recipes/design.rb +++ b/lib/template/recipes/design.rb @@ -1,4 +1,4 @@ -if template_options[:design] == "compass" +if template_options[:design] == :compass gem 'compass' # TODO: support more than one framework from compass diff --git a/lib/template/templater.rb b/lib/template/templater.rb index 6db245d..9875427 100644 --- a/lib/template/templater.rb +++ b/lib/template/templater.rb @@ -5,8 +5,10 @@ required_recipes = %w(default mongoid jquery haml rspec factory_girl remarkable) required_recipes.each {|required_recipe| apply recipe(required_recipe)} +say("\nInitial generation complete\n", Thor::Shell::Color::YELLOW) + load_options -apply(recipe('cucumber')) if yes?("Would you like to add integration testing with Cucumber? [y|n]: ", Thor::Shell::Color::GREEN) +apply(recipe('cucumber')) if yes?("\nWould you like to add integration testing with Cucumber? [y|n]: ", Thor::Shell::Color::BLUE) apply recipe('design') run 'bundle install'