rails_wizard 0.1.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.markdown +95 -0
- data/bin/rails_wizard +7 -0
- data/lib/rails_wizard.rb +10 -0
- data/lib/rails_wizard/command.rb +78 -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 +57 -0
- data/recipes/activerecord.rb +37 -0
- data/recipes/capybara.rb +34 -0
- data/recipes/cucumber.rb +16 -0
- data/recipes/devise.rb +23 -0
- data/recipes/git.rb +15 -0
- data/recipes/haml.rb +11 -0
- data/recipes/heroku.rb +58 -0
- data/recipes/hoptoad.rb +31 -0
- data/recipes/jammit.rb +43 -0
- data/recipes/jquery.rb +23 -0
- data/recipes/less.rb +12 -0
- data/recipes/mongo_mapper.rb +18 -0
- data/recipes/mongohq.rb +59 -0
- data/recipes/mongoid.rb +18 -0
- data/recipes/mootools.rb +23 -0
- data/recipes/omniauth.rb +15 -0
- data/recipes/prototype.rb +11 -0
- data/recipes/redis.rb +11 -0
- data/recipes/rightjs.rb +17 -0
- data/recipes/rspec.rb +21 -0
- data/recipes/sass.rb +13 -0
- data/recipes/sequel.rb +13 -0
- data/recipes/slim.rb +11 -0
- data/recipes/test_unit.rb +11 -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 +44 -0
- data/templates/layout.erb +42 -0
- data/templates/recipe.erb +9 -0
- data/version.rb +3 -0
- metadata +139 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
if config['database']
|
2
|
+
say_wizard "Configuring '#{config['database']}' database settings..."
|
3
|
+
old_gem = gem_for_database
|
4
|
+
@options = @options.dup.merge(:database => config['database'])
|
5
|
+
gsub_file 'Gemfile', "gem '#{old_gem}'", "gem '#{gem_for_database}'"
|
6
|
+
template "config/databases/#{@options[:database]}.yml", "config/database.yml.new"
|
7
|
+
run 'mv config/database.yml.new config/database.yml'
|
8
|
+
end
|
9
|
+
|
10
|
+
after_bundler do
|
11
|
+
rake "db:create:all" if config['auto_create']
|
12
|
+
end
|
13
|
+
|
14
|
+
__END__
|
15
|
+
|
16
|
+
name: ActiveRecord
|
17
|
+
description: "Use the default ActiveRecord database store."
|
18
|
+
author: mbleigh
|
19
|
+
|
20
|
+
exclusive: orm
|
21
|
+
category: persistence
|
22
|
+
tags: [sql, defaults, orm]
|
23
|
+
|
24
|
+
config:
|
25
|
+
- database:
|
26
|
+
type: multiple_choice
|
27
|
+
prompt: "Which database are you using?"
|
28
|
+
choices:
|
29
|
+
- ["MySQL", mysql]
|
30
|
+
- ["Oracle", oracle]
|
31
|
+
- ["PostgreSQL", postgresql]
|
32
|
+
- ["SQLite", sqlite3]
|
33
|
+
- ["Frontbase", frontbase]
|
34
|
+
- ["IBM DB", ibm_db]
|
35
|
+
- auto_create:
|
36
|
+
type: boolean
|
37
|
+
prompt: "Automatically create database with default configuration?"
|
data/recipes/capybara.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
gem 'capybara'
|
2
|
+
|
3
|
+
after_bundler do
|
4
|
+
create_file "spec/support/capybara.rb", <<-RUBY
|
5
|
+
require 'capybara/rails'
|
6
|
+
require 'capbybara/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/cucumber.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
gem 'cucumber-rails', :group => :test
|
2
|
+
gem 'capybara', :group => :test
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}"
|
6
|
+
end
|
7
|
+
|
8
|
+
__END__
|
9
|
+
|
10
|
+
name: Cucumber
|
11
|
+
description: "Use Cucumber for integration testing with Capybara."
|
12
|
+
author: mbleigh
|
13
|
+
|
14
|
+
exclusive: acceptance_testing
|
15
|
+
category: testing
|
16
|
+
tags: [acceptance]
|
data/recipes/devise.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
gem 'devise'
|
2
|
+
|
3
|
+
after_bundler do
|
4
|
+
generate 'devise:install'
|
5
|
+
|
6
|
+
if recipes.include? 'mongo_mapper'
|
7
|
+
gem 'mm-devise'
|
8
|
+
gsub_file 'config/intializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongo_mapper_active_model'
|
9
|
+
elsif recipes.include? 'mongoid'
|
10
|
+
gsub_file 'config/intializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid'
|
11
|
+
end
|
12
|
+
|
13
|
+
generate 'devise user'
|
14
|
+
end
|
15
|
+
|
16
|
+
__END__
|
17
|
+
|
18
|
+
name: Devise
|
19
|
+
description: Utilize Devise for authentication, automatically configured for your selected ORM.
|
20
|
+
author: mbleigh
|
21
|
+
|
22
|
+
category: authentication
|
23
|
+
exclusive: authentication
|
data/recipes/git.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
after_everything do
|
2
|
+
git :init
|
3
|
+
git :add => '.'
|
4
|
+
git :commit => '-m "Initial import."'
|
5
|
+
end
|
6
|
+
|
7
|
+
__END__
|
8
|
+
|
9
|
+
name: Git
|
10
|
+
description: "Provides basic Git setup for the Rails app and commits the initial repository."
|
11
|
+
author: mbleigh
|
12
|
+
|
13
|
+
exclusive: scm
|
14
|
+
category: other
|
15
|
+
tags: [scm]
|
data/recipes/haml.rb
ADDED
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
|
data/recipes/hoptoad.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
gem 'hoptoad_notifier'
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
if config['use_heroku']
|
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
|
+
else
|
10
|
+
generate "hoptoad --api-key #{config['api_key']}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
__END__
|
15
|
+
|
16
|
+
name: Hoptoad
|
17
|
+
description: Add Hoptoad exception reporting to your application.
|
18
|
+
|
19
|
+
category: services
|
20
|
+
exclusive: exception_notification
|
21
|
+
tags: [exception_notification]
|
22
|
+
|
23
|
+
config:
|
24
|
+
- use_heroku:
|
25
|
+
type: boolean
|
26
|
+
prompt: "Use the Hoptoad Heroku addon?"
|
27
|
+
if_recipe: heroku
|
28
|
+
- api_key:
|
29
|
+
prompt: "Enter Hoptoad API Key:"
|
30
|
+
type: string
|
31
|
+
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: "Do you a git pre-commit hook to generate assets for Heroku?"
|
43
|
+
if_recipe: heroku
|
data/recipes/jquery.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
inside "public/javascripts" do
|
2
|
+
get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "rails.js"
|
3
|
+
get "http://code.jquery.com/jquery-1.5.1.min.js", "jquery.js"
|
4
|
+
end
|
5
|
+
|
6
|
+
application do
|
7
|
+
"\nconfig.action_view.javascript_expansions[:defaults] = %w(jquery rails)\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
gsub_file "config/application.rb", /# JavaScript.*\n/, ""
|
11
|
+
gsub_file "config/application.rb", /# config\.action_view\.javascript.*\n/, ""
|
12
|
+
|
13
|
+
__END__
|
14
|
+
|
15
|
+
name: jQuery
|
16
|
+
description: "Adds the latest jQuery and Rails UJS helpers for jQuery."
|
17
|
+
author: mbleigh
|
18
|
+
|
19
|
+
exclusive: javascript_framework
|
20
|
+
category: assets
|
21
|
+
tags: [javascript, framework]
|
22
|
+
|
23
|
+
args: ["-J"]
|
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_bundler 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]
|
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
|
data/recipes/mongoid.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
gem 'mongoid', '>= 2.0.0.beta.19'
|
2
|
+
|
3
|
+
after_bundler do
|
4
|
+
generate 'mongoid:config'
|
5
|
+
end
|
6
|
+
|
7
|
+
__END__
|
8
|
+
|
9
|
+
name: Mongoid
|
10
|
+
description: "Utilize MongoDB with Mongoid as the ORM."
|
11
|
+
author: mbleigh
|
12
|
+
|
13
|
+
category: persistence
|
14
|
+
exclusive: orm
|
15
|
+
tags: [orm, mongodb]
|
16
|
+
|
17
|
+
args: ["-O"]
|
18
|
+
|
data/recipes/mootools.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
inside "public/javascripts" do
|
2
|
+
get "https://github.com/kevinvaldek/mootools-ujs/raw/master/Source/rails.js", "rails.js"
|
3
|
+
get "http://ajax.googleapis.com/ajax/libs/mootools/1.2.5/mootools-yui-compressed.js", "mootools.min.js"
|
4
|
+
end
|
5
|
+
|
6
|
+
gsub_file "config/application.rb", /# JavaScript.*\n/, ""
|
7
|
+
gsub_file "config/application.rb", /# config\.action_view\.javascript.*\n/, ""
|
8
|
+
|
9
|
+
application do
|
10
|
+
"\n config.action_view.javascript_expansions[:defaults] = %w(mootools.min rails)\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
__END__
|
14
|
+
|
15
|
+
name: MooTools
|
16
|
+
description: "Adds MooTools and MooTools-compatible UJS helpers."
|
17
|
+
author: mbleigh
|
18
|
+
|
19
|
+
exclusive: javascript_framework
|
20
|
+
category: assets
|
21
|
+
tags: [javascript, framework]
|
22
|
+
|
23
|
+
args: ["-J"]
|