Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some new recipes, some fixes for old ones.

  • Loading branch information...
commit 3d72eaed9723be79b13d57d771be9054bac8e53e 1 parent 77345c5
@mbleigh mbleigh authored
View
1  lib/rails_wizard/command.rb
@@ -15,6 +15,7 @@ def new(name)
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
View
2  lib/rails_wizard/recipe.rb
@@ -11,7 +11,7 @@ class Recipe
def self.<=>(another)
return -1 if another.run_after.include?(self.key) || self.run_before.include?(another.key)
return 1 if another.run_before.include?(self.key) || self.run_after.include?(another.key)
- 0
+ self.key <=> another.key
end
ATTRIBUTES = %w(key args category name description template config exclusive tags run_before run_after requires)
View
2  recipes/capybara.rb
@@ -1,4 +1,4 @@
-gem 'capybara'
+gem 'capybara', :group => [:development, :test]
after_bundler do
create_file "spec/support/capybara.rb", <<-RUBY
View
4 recipes/cucumber.rb
@@ -1,5 +1,5 @@
-gem 'cucumber-rails', :group => :test
-gem 'capybara', :group => :test
+gem 'cucumber-rails', :group => [:development, :test]
+gem 'capybara', :group => [:development, :test]
after_bundler do
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}"
View
54 recipes/env_yaml.rb
@@ -0,0 +1,54 @@
+
+
+say_wizard "Generating config/env.yaml..."
+
+append_file "config/application.rb", <<-RUBY
+
+require 'env_yaml'
+RUBY
+
+create_file "lib/env_yaml.rb", <<-RUBY
+require 'yaml'
+begin
+ env_yaml = YAML.load_file(File.dirname(__FILE__) + '/../config/env.yml')
+ if env_hash = env_yaml[ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development']
+ puts env_hash.inspect
+ env_hash.each_pair do |k,v|
+ ENV[k] = v.to_s
+ end
+ end
+rescue StandardError => e
+end
+
+RUBY
+
+create_file "config/env.yml", <<-YAML
+defaults:
+ ENV_YAML: true
+
+development:
+ <<: *defaults
+
+test:
+ <<: *defaults
+
+production:
+ <<: *defaults
+YAML
+
+def env(k,v,rack_env='development')
+ inject_into_file "config/env.yml", :after => "#{rack_env}:\n <<: *defaults" do
+ <<-YAML
+#{k}: #{v.inspect}
+YAML
+ end
+end
+
+__END__
+
+name: EnvYAML
+description: "Allows you to set environment variables in a YAML file at config/env.yaml"
+author: mbleigh
+
+category: other
+tags: [utilities, configuration]
View
2  recipes/jammit.rb
@@ -39,5 +39,5 @@
config:
- pre_commit:
type: boolean
- prompt: "Do you a git pre-commit hook to generate assets for Heroku?"
+ prompt: "Create a git pre-commit hook to generate assets for Heroku?"
if_recipe: heroku
View
6 recipes/redis.rb
@@ -1,5 +1,11 @@
gem 'redis'
+say_wizard "Generating Redis initializer..."
+
+initializer "redis.rb", <<-RUBY
+REDIS = Redis.new
+RUBY
+
__END__
name: Redis
View
39 recipes/redistogo.rb
@@ -0,0 +1,39 @@
+prepend_file "config/initializers/redis.rb", <<-RUBY
+uri = URI.parse(ENV['REDISTOGO_URL'])
+
+RUBY
+
+inject_into_file "config/initializers/redis.rb", :after => "Redis.new" do
+ "(:host => uri.host, :port => uri.port, :password => uri.password)"
+end
+
+env("REDISTOGO_URL", "redis://localhost:6379")
+
+after_bundler do
+ if config['use_heroku']
+ say_wizard "Adding redistogo:nano Heroku addon, you can always upgrade later."
+ run "heroku addons:add redistogo:nano"
+ else
+ env("REDISTOGO_URL", config['url'], 'production') if config['url']
+ end
+end
+__END__
+
+name: RedisToGo
+description: "Use RedisToGo hosting for this app's Redis."
+author: mbleigh
+
+requires: [redis, env_yaml]
+run_after: [redis, env_yaml]
+category: services
+
+config:
+ - use_heroku:
+ type: boolean
+ prompt: "Use the RedisToGo Heroku addon?"
+ if_recipe: heroku
+ - url:
+ type: string
+ prompt: "Enter your RedisToGo URL:"
+ unless: use_heroku
+
Please sign in to comment.
Something went wrong with that request. Please try again.