Permalink
Browse files

Fixing a few last bugs, updating the README

  • Loading branch information...
1 parent d00772e commit b7c0b3064535dc276c645e779567bd757840a1b8 Michael Bleigh committed Mar 16, 2011
Showing with 92 additions and 7 deletions.
  1. +7 −0 bin/rails_wizard
  2. +78 −0 lib/rails_wizard/command.rb
  3. +5 −5 rails_wizard.gemspec
  4. +2 −2 recipes/heroku.rb
View
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+$:.push File.dirname(__FILE__) + '/../lib'
+
+require 'rubygems'
+require 'rails_wizard/command'
+
+RailsWizard::Command.start
@@ -0,0 +1,78 @@
+require 'rails_wizard'
+require 'thor'
+
+module RailsWizard
+ class Command < Thor
+ include Thor::Actions
+ desc "new APP_NAME", "create a new Rails app"
+ method_option :recipes, :type => :array, :aliases => "-r"
+ def new(name)
+ if options[:recipes]
+ run_template(name, options[: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)
+ 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
+
+ desc "list [CATEGORY]", "list available recipes (optionally by category)"
+ 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
+
+ no_tasks do
+ def cyan; "\033[36m" end
+ def clear; "\033[0m" end
+ def bold; "\033[1m" end
+ def red; "\033[31m" end
+ def green; "\033[32m" end
+ def yellow; "\033[33m" end
+
+ def print_recipes
+ puts
+ puts
+ puts
+ if @recipes && @recipes.any?
+ puts "#{green}#{bold}Your Recipes:#{clear} " + @recipes.join(", ")
+ puts
+ end
+ puts "#{bold}#{cyan}Available Recipes:#{clear} " + RailsWizard::Recipes.list.join(', ')
+ puts
+ end
+
+ def run_template(name, recipes)
+ puts
+ puts
+ puts "#{bold}Generating and Running Template..."
+ puts
+ file = Tempfile.new('template')
+ template = RailsWizard::Template.new(recipes)
+ file.write template.compile
+ file.close
+ system "rails new #{name} -m #{file.path} #{template.args.join(' ')}"
+ ensure
+ file.unlink
+ end
+ end
+ end
+end
View
@@ -9,18 +9,18 @@ Gem::Specification.new do |s|
s.authors = ["Michael Bleigh"]
s.email = ["michael@intridea.com"]
s.homepage = "http://railswizard.org/"
- s.summary = %q{The collection of recipes available on RailsWizard.org}
- s.description = %q{The collection of recipes available on RailsWizard.org}
+ s.summary = %q{A tool for quickly generating Rails application templates.}
+ s.description = %q{Quickly and easily create Rails application templates featuring dozens of popular libraries.}
s.rubyforge_project = "rails_wizard"
s.add_dependency "i18n"
s.add_dependency "activesupport", "~> 3.0.0"
s.add_development_dependency "rspec", "~> 2.5.0"
- s.files = Dir["lib/**/*.rb", "recipes/*.rb", "README.markdown", "version.rb", "templates/*"]
- s.test_files = Dir["spec/**/*"]
- s.executables = Dir["bin/*"]
+ s.files = Dir["lib/**/*.rb", "recipes/*.rb", "README.markdown", "version.rb", "templates/*"]
+ s.test_files = Dir["spec/**/*"]
+ s.executables = ["rails_wizard"]
s.require_paths = ["lib"]
end
View
@@ -54,5 +54,5 @@
if: create
- deploy:
prompt: "Deploy immediately?"
- type: boolean
- if_recipe: git
+ type: boolean
+ if: create

0 comments on commit b7c0b30

Please sign in to comment.