rails_apps_composer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +313 -0
- data/bin/rails_apps_composer +7 -0
- data/lib/rails_wizard.rb +10 -0
- data/lib/rails_wizard/command.rb +79 -0
- data/lib/rails_wizard/config.rb +86 -0
- data/lib/rails_wizard/recipe.rb +106 -0
- data/lib/rails_wizard/recipes.rb +38 -0
- data/lib/rails_wizard/template.rb +58 -0
- data/recipes/action_mailer.rb +41 -0
- data/recipes/activerecord.rb +37 -0
- data/recipes/add_user.rb +87 -0
- data/recipes/add_user_name.rb +74 -0
- data/recipes/application_layout.rb +45 -0
- data/recipes/ban_spiders.rb +27 -0
- data/recipes/capybara.rb +34 -0
- data/recipes/cleanup.rb +36 -0
- data/recipes/css_setup.rb +42 -0
- data/recipes/cucumber.rb +62 -0
- data/recipes/devise.rb +76 -0
- data/recipes/devise_navigation.rb +93 -0
- data/recipes/env_yaml.rb +54 -0
- data/recipes/git.rb +38 -0
- data/recipes/haml.rb +23 -0
- data/recipes/heroku.rb +58 -0
- data/recipes/home_page.rb +45 -0
- data/recipes/home_page_users.rb +47 -0
- data/recipes/hoptoad.rb +34 -0
- data/recipes/jammit.rb +43 -0
- data/recipes/jquery.rb +70 -0
- data/recipes/less.rb +12 -0
- data/recipes/mongo_mapper.rb +18 -0
- data/recipes/mongohq.rb +59 -0
- data/recipes/mongoid.rb +39 -0
- data/recipes/mootools.rb +23 -0
- data/recipes/navigation.rb +68 -0
- data/recipes/omniauth.rb +152 -0
- data/recipes/omniauth_email.rb +82 -0
- data/recipes/pow.rb +12 -0
- data/recipes/prototype.rb +11 -0
- data/recipes/rails_admin.rb +21 -0
- data/recipes/redis.rb +17 -0
- data/recipes/redistogo.rb +40 -0
- data/recipes/rightjs.rb +17 -0
- data/recipes/rspec.rb +112 -0
- data/recipes/sass.rb +13 -0
- data/recipes/seed_database.rb +42 -0
- data/recipes/sequel.rb +13 -0
- data/recipes/settingslogic.rb +43 -0
- data/recipes/slim.rb +11 -0
- data/recipes/test_unit.rb +11 -0
- data/recipes/users_page.rb +103 -0
- data/spec/rails_wizard/config_spec.rb +99 -0
- data/spec/rails_wizard/recipe_spec.rb +103 -0
- data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
- data/spec/rails_wizard/recipes_spec.rb +24 -0
- data/spec/rails_wizard/template_spec.rb +48 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/rails_directory.rb +17 -0
- data/spec/support/template_runner.rb +28 -0
- data/templates/helpers.erb +45 -0
- data/templates/layout.erb +69 -0
- data/templates/recipe.erb +10 -0
- data/version.rb +3 -0
- metadata +206 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails_apps_composer/blob/master/recipes/application_layout.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "ApplicationLayout recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# Set up the default application layout
|
9
|
+
if recipes.include? 'haml'
|
10
|
+
remove_file 'app/views/layouts/application.html.erb'
|
11
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
12
|
+
create_file 'app/views/layouts/application.html.haml' do <<-HAML
|
13
|
+
!!!
|
14
|
+
%html
|
15
|
+
%head
|
16
|
+
%title #{app_name}
|
17
|
+
= stylesheet_link_tag :all
|
18
|
+
= javascript_include_tag :defaults
|
19
|
+
= csrf_meta_tag
|
20
|
+
%body
|
21
|
+
- flash.each do |name, msg|
|
22
|
+
= content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String)
|
23
|
+
= yield
|
24
|
+
HAML
|
25
|
+
end
|
26
|
+
else
|
27
|
+
inject_into_file 'app/views/layouts/application.html.erb', :after => "<body>\n" do
|
28
|
+
<<-ERB
|
29
|
+
<%- flash.each do |name, msg| -%>
|
30
|
+
<%= content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String) %>
|
31
|
+
<%- end -%>
|
32
|
+
ERB
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
__END__
|
39
|
+
|
40
|
+
name: ApplicationLayout
|
41
|
+
description: "Add a default application layout with flash messages."
|
42
|
+
author: fortuity
|
43
|
+
|
44
|
+
category: other
|
45
|
+
tags: [utilities, configuration]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails_apps_composer/blob/master/recipes/ban_spiders.rb
|
3
|
+
|
4
|
+
if config['ban_spiders']
|
5
|
+
say_wizard "BanSpiders recipe running 'after bundler'"
|
6
|
+
after_bundler do
|
7
|
+
# ban spiders from your site by changing robots.txt
|
8
|
+
gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent'
|
9
|
+
gsub_file 'public/robots.txt', /# Disallow/, 'Disallow'
|
10
|
+
end
|
11
|
+
else
|
12
|
+
recipes.delete('ban_spiders')
|
13
|
+
end
|
14
|
+
|
15
|
+
__END__
|
16
|
+
|
17
|
+
name: BanSpiders
|
18
|
+
description: "Ban spiders from the site by changing robots.txt."
|
19
|
+
author: fortuity
|
20
|
+
|
21
|
+
category: other
|
22
|
+
tags: [utilities, configuration]
|
23
|
+
|
24
|
+
config:
|
25
|
+
- ban_spiders:
|
26
|
+
type: boolean
|
27
|
+
prompt: Would you like to set a robots.txt file to ban spiders?
|
data/recipes/capybara.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
gem 'capybara', :group => [:development, :test]
|
2
|
+
|
3
|
+
after_bundler do
|
4
|
+
create_file "spec/support/capybara.rb", <<-RUBY
|
5
|
+
require 'capybara/rails'
|
6
|
+
require 'capybara/rspec'
|
7
|
+
RUBY
|
8
|
+
|
9
|
+
create_file "spec/requests/home_spec.rb", <<-RUBY
|
10
|
+
require 'spec_helper'
|
11
|
+
|
12
|
+
describe 'visiting the homepage' do
|
13
|
+
before do
|
14
|
+
visit '/'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have a body' do
|
18
|
+
page.should have_css('body')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
RUBY
|
22
|
+
end
|
23
|
+
|
24
|
+
__END__
|
25
|
+
|
26
|
+
name: Capybara
|
27
|
+
description: "Use the Capybara acceptance testing libraries with RSpec."
|
28
|
+
author: mbleigh
|
29
|
+
|
30
|
+
requires: [rspec]
|
31
|
+
run_after: [rspec]
|
32
|
+
exclusive: acceptance_testing
|
33
|
+
category: testing
|
34
|
+
tags: [acceptance]
|
data/recipes/cleanup.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails_apps_composer/blob/master/recipes/cleanup.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "Cleanup recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# remove unnecessary files
|
9
|
+
%w{
|
10
|
+
README
|
11
|
+
doc/README_FOR_APP
|
12
|
+
public/index.html
|
13
|
+
public/images/rails.png
|
14
|
+
}.each { |file| remove_file file }
|
15
|
+
|
16
|
+
# add placeholder READMEs
|
17
|
+
get "https://github.com/fortuity/rails-template-recipes/raw/master/sample_readme.txt", "README"
|
18
|
+
get "https://github.com/fortuity/rails-template-recipes/raw/master/sample_readme.textile", "README.textile"
|
19
|
+
gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}"
|
20
|
+
gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}"
|
21
|
+
|
22
|
+
# remove commented lines from Gemfile
|
23
|
+
# thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
|
24
|
+
gsub_file "Gemfile", /#.*\n/, "\n"
|
25
|
+
gsub_file "Gemfile", /\n+/, "\n"
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
__END__
|
30
|
+
|
31
|
+
name: Cleanup
|
32
|
+
description: "Remove unnecessary files left over from generating a new Rails app."
|
33
|
+
author: fortuity
|
34
|
+
|
35
|
+
category: other
|
36
|
+
tags: [utilities, configuration]
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails_apps_composer/blob/master/recipes/css_setup.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "CssSetup recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# Add a stylesheet with styles for a horizontal menu and flash messages
|
9
|
+
create_file 'public/stylesheets/application.css' do <<-CSS
|
10
|
+
ul.hmenu {
|
11
|
+
list-style: none;
|
12
|
+
margin: 0 0 2em;
|
13
|
+
padding: 0;
|
14
|
+
}
|
15
|
+
ul.hmenu li {
|
16
|
+
display: inline;
|
17
|
+
}
|
18
|
+
#flash_notice, #flash_alert {
|
19
|
+
padding: 5px 8px;
|
20
|
+
margin: 10px 0;
|
21
|
+
}
|
22
|
+
#flash_notice {
|
23
|
+
background-color: #CFC;
|
24
|
+
border: solid 1px #6C6;
|
25
|
+
}
|
26
|
+
#flash_alert {
|
27
|
+
background-color: #FCC;
|
28
|
+
border: solid 1px #C66;
|
29
|
+
}
|
30
|
+
CSS
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
__END__
|
36
|
+
|
37
|
+
name: CssSetup
|
38
|
+
description: "Add a stylesheet with styles for a horizontal menu and flash messages."
|
39
|
+
author: fortuity
|
40
|
+
|
41
|
+
category: other
|
42
|
+
tags: [utilities, configuration]
|
data/recipes/cucumber.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails_apps_composer/blob/master/recipes/cucumber.rb
|
3
|
+
|
4
|
+
if config['cucumber']
|
5
|
+
gem 'cucumber-rails', ">= 0.4.1", :group => :test
|
6
|
+
gem 'capybara', ">= 0.4.1.2", :group => :test
|
7
|
+
gem 'database_cleaner', '>= 0.6.7', :group => :test
|
8
|
+
gem 'launchy', ">= 0.4.0", :group => :test
|
9
|
+
else
|
10
|
+
recipes.delete('cucumber')
|
11
|
+
end
|
12
|
+
|
13
|
+
if config['cucumber']
|
14
|
+
after_bundler do
|
15
|
+
say_wizard "Cucumber recipe running 'after bundler'"
|
16
|
+
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' if recipes.include?('mongoid')}"
|
17
|
+
if recipes.include? 'mongoid'
|
18
|
+
gsub_file 'features/support/env.rb', /transaction/, "truncation"
|
19
|
+
inject_into_file 'features/support/env.rb', :after => 'begin' do
|
20
|
+
"\n DatabaseCleaner.orm = 'mongoid'"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if config['cucumber']
|
27
|
+
if recipes.include? 'devise'
|
28
|
+
after_bundler do
|
29
|
+
say_wizard "Copying Cucumber scenarios from the rails3-mongoid-devise examples"
|
30
|
+
# copy all the Cucumber scenario files from the rails3-mongoid-devise example app
|
31
|
+
inside 'features/users' do
|
32
|
+
get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_in.feature', 'sign_in.feature'
|
33
|
+
get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_out.feature', 'sign_out.feature'
|
34
|
+
get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_up.feature', 'sign_up.feature'
|
35
|
+
get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/user_edit.feature', 'user_edit.feature'
|
36
|
+
get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/user_show.feature', 'user_show.feature'
|
37
|
+
end
|
38
|
+
inside 'features/step_definitions' do
|
39
|
+
get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/step_definitions/user_steps.rb', 'user_steps.rb'
|
40
|
+
end
|
41
|
+
remove_file 'features/support/paths.rb'
|
42
|
+
inside 'features/support' do
|
43
|
+
get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/support/paths.rb', 'paths.rb'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
__END__
|
50
|
+
|
51
|
+
name: Cucumber
|
52
|
+
description: "Use Cucumber for BDD (with Capybara)."
|
53
|
+
author: fortuity
|
54
|
+
|
55
|
+
exclusive: acceptance_testing
|
56
|
+
category: testing
|
57
|
+
tags: [acceptance]
|
58
|
+
|
59
|
+
config:
|
60
|
+
- cucumber:
|
61
|
+
type: boolean
|
62
|
+
prompt: Would you like to use Cucumber for your BDD?
|
data/recipes/devise.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails_apps_composer/blob/master/recipes/devise.rb
|
3
|
+
|
4
|
+
if config['devise']
|
5
|
+
gem "devise", ">= 1.3.3"
|
6
|
+
else
|
7
|
+
recipes.delete('devise')
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
if config['devise']
|
12
|
+
after_bundler do
|
13
|
+
|
14
|
+
say_wizard "Devise recipe running 'after bundler'"
|
15
|
+
|
16
|
+
# Run the Devise generator
|
17
|
+
generate 'devise:install'
|
18
|
+
|
19
|
+
if recipes.include? 'mongo_mapper'
|
20
|
+
gem 'mm-devise'
|
21
|
+
gsub_file 'config/initializers/devise.rb', 'devise/orm/', 'devise/orm/mongo_mapper_active_model'
|
22
|
+
generate 'mongo_mapper:devise User'
|
23
|
+
elsif recipes.include? 'mongoid'
|
24
|
+
# Nothing to do (Devise changes its initializer automatically when Mongoid is detected)
|
25
|
+
# gsub_file 'config/initializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid'
|
26
|
+
end
|
27
|
+
|
28
|
+
# Prevent logging of password_confirmation
|
29
|
+
gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
after_everything do
|
34
|
+
|
35
|
+
say_wizard "Devise recipe running 'after everything'"
|
36
|
+
|
37
|
+
if recipes.include? 'rspec'
|
38
|
+
say_wizard "Copying RSpec files from the rails3-devise-rspec-cucumber examples"
|
39
|
+
# copy all the RSpec specs files from the rails3-devise-rspec-cucumber example app
|
40
|
+
inside 'spec' do
|
41
|
+
get 'https://github.com/fortuity/rails3-devise-rspec-cucumber/raw/master/spec/factories.rb', 'factories.rb'
|
42
|
+
end
|
43
|
+
remove_file 'spec/controllers/home_controller_spec.rb'
|
44
|
+
remove_file 'spec/controllers/users_controller_spec.rb'
|
45
|
+
inside 'spec/controllers' do
|
46
|
+
get 'https://github.com/fortuity/rails3-devise-rspec-cucumber/raw/master/spec/controllers/home_controller_spec.rb', 'home_controller_spec.rb'
|
47
|
+
get 'https://github.com/fortuity/rails3-devise-rspec-cucumber/raw/master/spec/controllers/users_controller_spec.rb', 'users_controller_spec.rb'
|
48
|
+
end
|
49
|
+
remove_file 'spec/models/user_spec.rb'
|
50
|
+
inside 'spec/models' do
|
51
|
+
get 'https://github.com/fortuity/rails3-devise-rspec-cucumber/raw/master/spec/models/user_spec.rb', 'user_spec.rb'
|
52
|
+
end
|
53
|
+
remove_file 'spec/views/home/index.html.erb_spec.rb'
|
54
|
+
remove_file 'spec/views/home/index.html.haml_spec.rb'
|
55
|
+
remove_file 'spec/views/users/show.html.erb_spec.rb'
|
56
|
+
remove_file 'spec/views/users/show.html.haml_spec.rb'
|
57
|
+
remove_file 'spec/helpers/home_helper_spec.rb'
|
58
|
+
remove_file 'spec/helpers/users_helper_spec.rb'
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
__END__
|
65
|
+
|
66
|
+
name: Devise
|
67
|
+
description: Utilize Devise for authentication, automatically configured for your selected ORM.
|
68
|
+
author: fortuity
|
69
|
+
|
70
|
+
category: authentication
|
71
|
+
exclusive: authentication
|
72
|
+
|
73
|
+
config:
|
74
|
+
- devise:
|
75
|
+
type: boolean
|
76
|
+
prompt: Would you like to use Devise for authentication?
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails_apps_composer/blob/master/recipes/devise_navigation.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "DeviseNavigation recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# Create navigation links for Devise
|
9
|
+
if recipes.include? 'haml'
|
10
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
11
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
12
|
+
create_file "app/views/devise/menu/_login_items.html.haml" do <<-'HAML'
|
13
|
+
- if user_signed_in?
|
14
|
+
%li
|
15
|
+
= link_to('Logout', destroy_user_session_path)
|
16
|
+
- else
|
17
|
+
%li
|
18
|
+
= link_to('Login', new_user_session_path)
|
19
|
+
HAML
|
20
|
+
end
|
21
|
+
else
|
22
|
+
create_file "app/views/devise/menu/_login_items.html.erb" do <<-ERB
|
23
|
+
<% if user_signed_in? %>
|
24
|
+
<li>
|
25
|
+
<%= link_to('Logout', destroy_user_session_path) %>
|
26
|
+
</li>
|
27
|
+
<% else %>
|
28
|
+
<li>
|
29
|
+
<%= link_to('Login', new_user_session_path) %>
|
30
|
+
</li>
|
31
|
+
<% end %>
|
32
|
+
ERB
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if recipes.include? 'haml'
|
37
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
38
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
39
|
+
create_file "app/views/devise/menu/_registration_items.html.haml" do <<-'HAML'
|
40
|
+
- if user_signed_in?
|
41
|
+
%li
|
42
|
+
= link_to('Edit account', edit_user_registration_path)
|
43
|
+
- else
|
44
|
+
%li
|
45
|
+
= link_to('Sign up', new_user_registration_path)
|
46
|
+
HAML
|
47
|
+
end
|
48
|
+
else
|
49
|
+
create_file "app/views/devise/menu/_registration_items.html.erb" do <<-ERB
|
50
|
+
<% if user_signed_in? %>
|
51
|
+
<li>
|
52
|
+
<%= link_to('Edit account', edit_user_registration_path) %>
|
53
|
+
</li>
|
54
|
+
<% else %>
|
55
|
+
<li>
|
56
|
+
<%= link_to('Sign up', new_user_registration_path) %>
|
57
|
+
</li>
|
58
|
+
<% end %>
|
59
|
+
ERB
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Add navigation links to the default application layout
|
64
|
+
if recipes.include? 'haml'
|
65
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
66
|
+
inject_into_file 'app/views/layouts/application.html.haml', :after => "%body\n" do <<-HAML
|
67
|
+
%ul.hmenu
|
68
|
+
= render 'devise/menu/registration_items'
|
69
|
+
= render 'devise/menu/login_items'
|
70
|
+
HAML
|
71
|
+
end
|
72
|
+
else
|
73
|
+
inject_into_file 'app/views/layouts/application.html.erb', :after => "<body>\n" do
|
74
|
+
<<-ERB
|
75
|
+
<ul class="hmenu">
|
76
|
+
<%= render 'devise/menu/registration_items' %>
|
77
|
+
<%= render 'devise/menu/login_items' %>
|
78
|
+
</ul>
|
79
|
+
ERB
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
__END__
|
86
|
+
|
87
|
+
name: DeviseNavigation
|
88
|
+
description: "Add navigation links for Devise."
|
89
|
+
author: fortuity
|
90
|
+
|
91
|
+
requires: [devise]
|
92
|
+
category: other
|
93
|
+
tags: [utilities, configuration]
|
data/recipes/env_yaml.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
say_wizard "Generating config/env.yaml..."
|
4
|
+
|
5
|
+
append_file "config/application.rb", <<-RUBY
|
6
|
+
|
7
|
+
require 'env_yaml'
|
8
|
+
RUBY
|
9
|
+
|
10
|
+
create_file "lib/env_yaml.rb", <<-RUBY
|
11
|
+
require 'yaml'
|
12
|
+
begin
|
13
|
+
env_yaml = YAML.load_file(File.dirname(__FILE__) + '/../config/env.yml')
|
14
|
+
if env_hash = env_yaml[ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development']
|
15
|
+
puts env_hash.inspect
|
16
|
+
env_hash.each_pair do |k,v|
|
17
|
+
ENV[k] = v.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
rescue StandardError => e
|
21
|
+
end
|
22
|
+
|
23
|
+
RUBY
|
24
|
+
|
25
|
+
create_file "config/env.yml", <<-YAML
|
26
|
+
defaults:
|
27
|
+
ENV_YAML: true
|
28
|
+
|
29
|
+
development:
|
30
|
+
<<: *defaults
|
31
|
+
|
32
|
+
test:
|
33
|
+
<<: *defaults
|
34
|
+
|
35
|
+
production:
|
36
|
+
<<: *defaults
|
37
|
+
YAML
|
38
|
+
|
39
|
+
def env(k,v,rack_env='development')
|
40
|
+
inject_into_file "config/env.yml", :after => "#{rack_env}:\n <<: *defaults" do
|
41
|
+
<<-YAML
|
42
|
+
#{k}: #{v.inspect}
|
43
|
+
YAML
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
__END__
|
48
|
+
|
49
|
+
name: EnvYAML
|
50
|
+
description: "Allows you to set environment variables in a YAML file at config/env.yaml"
|
51
|
+
author: mbleigh
|
52
|
+
|
53
|
+
category: other
|
54
|
+
tags: [utilities, configuration]
|