forked from sr3d/rails_wizard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some new recipes, some fixes for old ones.
- Loading branch information
Michael Bleigh
committed
Mar 22, 2011
1 parent
77345c5
commit 3d72eae
Showing
8 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|