rails_apps_composer 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/recipes/git.rb
ADDED
@@ -0,0 +1,38 @@
|
|
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/git.rb
|
3
|
+
|
4
|
+
after_everything do
|
5
|
+
|
6
|
+
say_wizard "Git recipe running 'after everything'"
|
7
|
+
|
8
|
+
# Git should ignore some files
|
9
|
+
remove_file '.gitignore'
|
10
|
+
get "https://github.com/fortuity/rails3-gitignore/raw/master/gitignore.txt", ".gitignore"
|
11
|
+
|
12
|
+
if recipes.include? 'omniauth'
|
13
|
+
append_file '.gitignore' do <<-TXT
|
14
|
+
# keep OmniAuth service provider secrets out of the Git repo
|
15
|
+
config/initializers/omniauth.rb
|
16
|
+
TXT
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Initialize new Git repo
|
21
|
+
git :init
|
22
|
+
git :add => '.'
|
23
|
+
git :commit => "-aqm 'new Rails app generated by rails_apps_composer'"
|
24
|
+
# Create a git branch
|
25
|
+
git :checkout => ' -b working_branch'
|
26
|
+
git :add => '.'
|
27
|
+
git :commit => "-m 'Initial commit of working_branch'"
|
28
|
+
end
|
29
|
+
|
30
|
+
__END__
|
31
|
+
|
32
|
+
name: Git
|
33
|
+
description: "Set up Git and commit the initial repository."
|
34
|
+
author: fortuity
|
35
|
+
|
36
|
+
exclusive: scm
|
37
|
+
category: other
|
38
|
+
tags: [scm]
|
data/recipes/haml.rb
ADDED
@@ -0,0 +1,23 @@
|
|
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/haml.rb
|
3
|
+
|
4
|
+
if config['haml']
|
5
|
+
gem 'haml', '>= 3.1.1'
|
6
|
+
gem 'haml-rails', '>= 0.3.4', :group => :development
|
7
|
+
else
|
8
|
+
recipes.delete('haml')
|
9
|
+
end
|
10
|
+
|
11
|
+
__END__
|
12
|
+
|
13
|
+
name: HAML
|
14
|
+
description: "Utilize Haml instead of ERB."
|
15
|
+
author: fortuity
|
16
|
+
|
17
|
+
category: templating
|
18
|
+
exclusive: templating
|
19
|
+
|
20
|
+
config:
|
21
|
+
- haml:
|
22
|
+
type: boolean
|
23
|
+
prompt: Would you like to use Haml instead of ERB?
|
data/recipes/heroku.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
heroku_name = app_name.gsub('_','')
|
2
|
+
|
3
|
+
after_everything do
|
4
|
+
if config['create']
|
5
|
+
say_wizard "Creating Heroku app '#{heroku_name}.heroku.com'"
|
6
|
+
while !system("heroku create #{heroku_name}")
|
7
|
+
heroku_name = ask_wizard("What do you want to call your app? ")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
if config['staging']
|
12
|
+
staging_name = "#{heroku_name}-staging"
|
13
|
+
say_wizard "Creating staging Heroku app '#{staging_name}.heroku.com'"
|
14
|
+
while !system("heroku create #{staging_name}")
|
15
|
+
staging_name = ask_wizard("What do you want to call your staging app?")
|
16
|
+
end
|
17
|
+
git :remote => "rm heroku"
|
18
|
+
git :remote => "add production git@heroku.com:#{heroku_name}.git"
|
19
|
+
git :remote => "add staging git@heroku.com:#{staging_name}.git"
|
20
|
+
say_wizard "Created branches 'production' and 'staging' for Heroku deploy."
|
21
|
+
end
|
22
|
+
|
23
|
+
unless config['domain'].blank?
|
24
|
+
run "heroku addons:add custom_domains"
|
25
|
+
run "heroku domains:add #{config['domain']}"
|
26
|
+
end
|
27
|
+
|
28
|
+
git :push => "#{config['staging'] ? 'staging' : 'heroku'} master" if config['deploy']
|
29
|
+
end
|
30
|
+
|
31
|
+
__END__
|
32
|
+
|
33
|
+
name: Heroku
|
34
|
+
description: Create Heroku application and instantly deploy.
|
35
|
+
author: mbleigh
|
36
|
+
|
37
|
+
requires: [git]
|
38
|
+
run_after: [git]
|
39
|
+
exclusive: deployment
|
40
|
+
category: deployment
|
41
|
+
tags: [provider]
|
42
|
+
|
43
|
+
config:
|
44
|
+
- create:
|
45
|
+
prompt: "Automatically create appname.heroku.com?"
|
46
|
+
type: boolean
|
47
|
+
- staging:
|
48
|
+
prompt: "Create staging app? (appname-staging.heroku.com)"
|
49
|
+
type: boolean
|
50
|
+
if: create
|
51
|
+
- domain:
|
52
|
+
prompt: "Specify custom domain (or leave blank):"
|
53
|
+
type: string
|
54
|
+
if: create
|
55
|
+
- deploy:
|
56
|
+
prompt: "Deploy immediately?"
|
57
|
+
type: boolean
|
58
|
+
if: create
|
@@ -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/home_page.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "HomePage recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# remove the default home page
|
9
|
+
remove_file 'public/index.html'
|
10
|
+
|
11
|
+
# create a home controller and view
|
12
|
+
generate(:controller, "home index")
|
13
|
+
|
14
|
+
# set up a simple home page (with placeholder content)
|
15
|
+
if recipes.include? 'haml'
|
16
|
+
remove_file 'app/views/home/index.html.haml'
|
17
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
18
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
19
|
+
create_file 'app/views/home/index.html.haml' do
|
20
|
+
<<-'HAML'
|
21
|
+
%h3 Home
|
22
|
+
HAML
|
23
|
+
end
|
24
|
+
else
|
25
|
+
remove_file 'app/views/home/index.html.erb'
|
26
|
+
create_file 'app/views/home/index.html.erb' do
|
27
|
+
<<-ERB
|
28
|
+
<h3>Home</h3>
|
29
|
+
ERB
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# set routes
|
34
|
+
gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"'
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
__END__
|
39
|
+
|
40
|
+
name: HomePage
|
41
|
+
description: "Create a simple home page (creates a home controller and view)."
|
42
|
+
author: fortuity
|
43
|
+
|
44
|
+
category: other
|
45
|
+
tags: [utilities, configuration]
|
@@ -0,0 +1,47 @@
|
|
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/home_page_users.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "HomePageUsers recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# Modify the home controller
|
9
|
+
gsub_file 'app/controllers/home_controller.rb', /def index/ do
|
10
|
+
<<-RUBY
|
11
|
+
def index
|
12
|
+
@users = User.all
|
13
|
+
RUBY
|
14
|
+
end
|
15
|
+
|
16
|
+
# Replace the home page
|
17
|
+
if recipes.include? 'haml'
|
18
|
+
remove_file 'app/views/home/index.html.haml'
|
19
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
20
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
21
|
+
create_file 'app/views/home/index.html.haml' do
|
22
|
+
<<-'HAML'
|
23
|
+
%h3 Home
|
24
|
+
- @users.each do |user|
|
25
|
+
%p User: #{user.name}
|
26
|
+
HAML
|
27
|
+
end
|
28
|
+
else
|
29
|
+
append_file 'app/views/home/index.html.erb' do <<-ERB
|
30
|
+
<h3>Home</h3>
|
31
|
+
<% @users.each do |user| %>
|
32
|
+
<p>User: <%= user.name %></p>
|
33
|
+
<% end %>
|
34
|
+
ERB
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
__END__
|
41
|
+
|
42
|
+
name: HomePageUsers
|
43
|
+
description: "Display a list of users on the home page."
|
44
|
+
author: fortuity
|
45
|
+
|
46
|
+
category: other
|
47
|
+
tags: [utilities, configuration]
|
data/recipes/hoptoad.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
gem 'hoptoad_notifier'
|
3
|
+
|
4
|
+
if config['use_heroku']
|
5
|
+
after_everything do
|
6
|
+
say_wizard "Adding hoptoad:basic Heroku addon (you can always upgrade later)"
|
7
|
+
run "heroku addons:add hoptoad:basic"
|
8
|
+
generate "hoptoad --heroku"
|
9
|
+
end
|
10
|
+
else
|
11
|
+
after_bundler do
|
12
|
+
generate "hoptoad --api-key #{config['api_key']}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
__END__
|
17
|
+
|
18
|
+
name: Hoptoad
|
19
|
+
description: Add Hoptoad exception reporting to your application.
|
20
|
+
|
21
|
+
category: services
|
22
|
+
exclusive: exception_notification
|
23
|
+
tags: [exception_notification]
|
24
|
+
run_after: [heroku]
|
25
|
+
|
26
|
+
config:
|
27
|
+
- use_heroku:
|
28
|
+
type: boolean
|
29
|
+
prompt: "Use the Hoptoad Heroku addon?"
|
30
|
+
if_recipe: heroku
|
31
|
+
- api_key:
|
32
|
+
prompt: "Enter Hoptoad API Key:"
|
33
|
+
type: string
|
34
|
+
unless: use_heroku
|
data/recipes/jammit.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
gem 'jammit'
|
2
|
+
|
3
|
+
after_bundler do
|
4
|
+
if config['pre_commit']
|
5
|
+
say_wizard "Adding git pre-commit hook..."
|
6
|
+
create_file ".git/hooks/pre-commit", <<-BASH
|
7
|
+
#!/bin/sh
|
8
|
+
|
9
|
+
echo "Packaging assets with Jammit..."
|
10
|
+
jammit
|
11
|
+
git add public/assets
|
12
|
+
BASH
|
13
|
+
run "chmod +x .git/hooks/pre-commit"
|
14
|
+
end
|
15
|
+
|
16
|
+
create_file "config/assets.yml", <<-YAML
|
17
|
+
javascripts:
|
18
|
+
app:
|
19
|
+
- public/javascripts/*.js
|
20
|
+
stylesheets:
|
21
|
+
app:
|
22
|
+
- public/stylesheets/*.css
|
23
|
+
YAML
|
24
|
+
|
25
|
+
gsub_file "app/views/layouts/application.html.erb", "<%= javascript_include_tag :defaults %>", "<%= include_javascripts :app %>"
|
26
|
+
gsub_file "app/views/layouts/application.html.erb", "<%= stylesheet_link_tag :all %>", "<%= include_stylesheets :app %>"
|
27
|
+
end
|
28
|
+
|
29
|
+
__END__
|
30
|
+
|
31
|
+
name: Jammit
|
32
|
+
description: "Use Jammit to package your application's assets."
|
33
|
+
author: mbleigh
|
34
|
+
|
35
|
+
exclusive: asset_packaging
|
36
|
+
category: assets
|
37
|
+
tags: [packaging]
|
38
|
+
|
39
|
+
config:
|
40
|
+
- pre_commit:
|
41
|
+
type: boolean
|
42
|
+
prompt: "Create a git pre-commit hook to generate assets for Heroku?"
|
43
|
+
if_recipe: heroku
|
data/recipes/jquery.rb
ADDED
@@ -0,0 +1,70 @@
|
|
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/jquery.rb
|
3
|
+
|
4
|
+
if config['jquery']
|
5
|
+
if recipes.include? 'rails 3.0'
|
6
|
+
say_wizard "Replacing Prototype framework with jQuery for Rails 3.0."
|
7
|
+
after_bundler do
|
8
|
+
say_wizard "jQuery recipe running 'after bundler'"
|
9
|
+
# remove the Prototype adapter file
|
10
|
+
remove_file 'public/javascripts/rails.js'
|
11
|
+
# remove the Prototype files (if they exist)
|
12
|
+
remove_file 'public/javascripts/controls.js'
|
13
|
+
remove_file 'public/javascripts/dragdrop.js'
|
14
|
+
remove_file 'public/javascripts/effects.js'
|
15
|
+
remove_file 'public/javascripts/prototype.js'
|
16
|
+
# add jQuery files
|
17
|
+
inside "public/javascripts" do
|
18
|
+
get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "rails.js"
|
19
|
+
get "http://code.jquery.com/jquery-1.6.min.js", "jquery.js"
|
20
|
+
if config['ui']
|
21
|
+
get "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js", "jqueryui.js"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
# adjust the Javascript defaults
|
25
|
+
# first uncomment "config.action_view.javascript_expansions"
|
26
|
+
gsub_file "config/application.rb", /# config.action_view.javascript_expansions/, "config.action_view.javascript_expansions"
|
27
|
+
# then add "jquery rails" if necessary
|
28
|
+
gsub_file "config/application.rb", /= \%w\(\)/, "%w(jquery rails)"
|
29
|
+
# finally change to "jquery jqueryui rails" if necessary
|
30
|
+
if config['ui']
|
31
|
+
gsub_file "config/application.rb", /jquery rails/, "jquery jqueryui rails"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
elsif recipes.include? 'rails 3.1'
|
35
|
+
if config['ui']
|
36
|
+
inside "app/assets/javascripts" do
|
37
|
+
get "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js", "jqueryui.js"
|
38
|
+
end
|
39
|
+
else
|
40
|
+
say_wizard "jQuery installed by default in Rails 3.1."
|
41
|
+
end
|
42
|
+
else
|
43
|
+
say_wizard "Don't know what to do for Rails version #{Rails::VERSION::STRING}. jQuery recipe skipped."
|
44
|
+
end
|
45
|
+
else
|
46
|
+
if config['ui']
|
47
|
+
say_wizard "You said you didn't want jQuery. Can't install jQuery UI without jQuery."
|
48
|
+
end
|
49
|
+
recipes.delete('jquery')
|
50
|
+
end
|
51
|
+
|
52
|
+
__END__
|
53
|
+
|
54
|
+
name: jQuery
|
55
|
+
description: "Install jQuery (with jQuery UI option) for Rails 3.0 or 3.1."
|
56
|
+
author: fortuity
|
57
|
+
|
58
|
+
exclusive: javascript_framework
|
59
|
+
category: assets
|
60
|
+
tags: [javascript, framework]
|
61
|
+
|
62
|
+
args: ["-J"]
|
63
|
+
|
64
|
+
config:
|
65
|
+
- jquery:
|
66
|
+
type: boolean
|
67
|
+
prompt: Would you like to use jQuery?
|
68
|
+
- ui:
|
69
|
+
type: boolean
|
70
|
+
prompt: Would you like to use jQuery UI?
|
data/recipes/less.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
gem 'less'
|
2
|
+
plugin 'more', :git => 'git://github.com/cloudhead/more.git'
|
3
|
+
|
4
|
+
__END__
|
5
|
+
|
6
|
+
name: Less CSS
|
7
|
+
description: "Utilize Less CSS for CSS generation utilizing the \"more\" plugin for Rails."
|
8
|
+
author: mbleigh
|
9
|
+
|
10
|
+
exclusive: css_replacement
|
11
|
+
category: assets
|
12
|
+
tags: [css]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
gem 'bson_ext'
|
2
|
+
gem 'mongo_mapper', :git => 'git://github.com/jnunemaker/mongomapper.git', :branch => 'rails3'
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
generate 'mongo_mapper:config'
|
6
|
+
end
|
7
|
+
|
8
|
+
__END__
|
9
|
+
|
10
|
+
name: MongoMapper
|
11
|
+
description: "Use MongoDB with MongoMapper as your primary datastore."
|
12
|
+
author: mbleigh
|
13
|
+
|
14
|
+
exclusive: orm
|
15
|
+
category: persistence
|
16
|
+
tags: [mongodb, orm]
|
17
|
+
|
18
|
+
args: ["-O"]
|
data/recipes/mongohq.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
if config['use_heroku']
|
2
|
+
|
3
|
+
header = <<-YAML
|
4
|
+
<% if ENV['MONGOHQ_URL'] %>
|
5
|
+
<% mongohq = URI.parse(ENV['MONGOHQ_URL']) %>
|
6
|
+
mongohq:
|
7
|
+
host: <%= mongohq.host %>
|
8
|
+
port: <%= mongohq.port %>
|
9
|
+
database: <%= mongohq.path.sub '/', '' %>
|
10
|
+
username: <%= mongohq.user %>
|
11
|
+
password: <%= mongohq.password %>
|
12
|
+
<% end %>
|
13
|
+
YAML
|
14
|
+
|
15
|
+
after_everything do
|
16
|
+
say_wizard 'Adding mongohq:free addon (you can always upgrade later)'
|
17
|
+
system 'heroku addons:add mongohq:free'
|
18
|
+
end
|
19
|
+
else
|
20
|
+
mongohq = URI.parse(config['uri'])
|
21
|
+
|
22
|
+
header = <<-YAML
|
23
|
+
mongohq:
|
24
|
+
host: #{mongohq.host}
|
25
|
+
port: #{mongohq.port}
|
26
|
+
database: #{mongohq.path.sub '/',''}
|
27
|
+
username: #{mongohq.user}
|
28
|
+
password: #{mongohq.password}
|
29
|
+
YAML
|
30
|
+
end
|
31
|
+
|
32
|
+
after_bundler do
|
33
|
+
mongo_yml = "config/mongo#{'id' if recipe?('mongoid')}.yml"
|
34
|
+
|
35
|
+
prepend_file mongo_yml, header
|
36
|
+
inject_into_file mongo_yml, " <<: *mongohq\n", :after => "production:\n <<: *defaults\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
__END__
|
40
|
+
|
41
|
+
name: MongoHQ
|
42
|
+
description: "Utilize MongoHQ as the production data host for your application."
|
43
|
+
author: mbleigh
|
44
|
+
|
45
|
+
requires_any: [mongo_mapper, mongoid]
|
46
|
+
run_after: [mongo_mapper, mongoid, heroku]
|
47
|
+
exclusive: mongodb_host
|
48
|
+
category: services
|
49
|
+
tags: [mongodb]
|
50
|
+
|
51
|
+
config:
|
52
|
+
- use_heroku:
|
53
|
+
type: boolean
|
54
|
+
prompt: "Use the MongoHQ Heroku addon?"
|
55
|
+
if_recipe: heroku
|
56
|
+
- uri:
|
57
|
+
type: string
|
58
|
+
prompt: "Enter your MongoHQ URI:"
|
59
|
+
unless: use_heroku
|