rails3_devise_wizard 0.2
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 +135 -0
- data/bin/rails3_devise_wizard +7 -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/lib/rails_wizard.rb +10 -0
- data/recipes/action_mailer.rb +41 -0
- data/recipes/activerecord.rb +37 -0
- data/recipes/add_user_name.rb +75 -0
- data/recipes/application_layout.rb +43 -0
- data/recipes/ban_spiders.rb +19 -0
- data/recipes/capybara.rb +34 -0
- data/recipes/cleanup.rb +34 -0
- data/recipes/css_setup.rb +40 -0
- data/recipes/cucumber.rb +69 -0
- data/recipes/devise.rb +35 -0
- data/recipes/devise_navigation.rb +95 -0
- data/recipes/env_yaml.rb +54 -0
- data/recipes/git.rb +26 -0
- data/recipes/haml.rb +14 -0
- data/recipes/heroku.rb +58 -0
- data/recipes/home_page.rb +43 -0
- data/recipes/home_page_users.rb +50 -0
- data/recipes/hoptoad.rb +34 -0
- data/recipes/jammit.rb +43 -0
- data/recipes/jquery.rb +44 -0
- data/recipes/less.rb +12 -0
- data/recipes/mongo_mapper.rb +18 -0
- data/recipes/mongohq.rb +59 -0
- data/recipes/mongoid.rb +30 -0
- data/recipes/mootools.rb +23 -0
- data/recipes/omniauth.rb +15 -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 +89 -0
- data/recipes/sass.rb +13 -0
- data/recipes/seed_database.rb +35 -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 +46 -0
- data/templates/recipe.erb +10 -0
- data/version.rb +3 -0
- metadata +205 -0
data/recipes/devise.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/devise.rb
|
3
|
+
|
4
|
+
gem "devise", ">= 1.2.1"
|
5
|
+
|
6
|
+
after_bundler do
|
7
|
+
|
8
|
+
# Run the Devise generator
|
9
|
+
generate 'devise:install'
|
10
|
+
|
11
|
+
if recipes.include? 'mongo_mapper'
|
12
|
+
gem 'mm-devise'
|
13
|
+
gsub_file 'config/initializers/devise.rb', 'devise/orm/', 'devise/orm/mongo_mapper_active_model'
|
14
|
+
generate 'mongo_mapper:devise User'
|
15
|
+
elsif recipes.include? 'mongoid'
|
16
|
+
# Nothing to do (Devise changes its initializer automatically when Mongoid is detected)
|
17
|
+
# gsub_file 'config/initializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid'
|
18
|
+
end
|
19
|
+
|
20
|
+
# Prevent logging of password_confirmation
|
21
|
+
gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
|
22
|
+
|
23
|
+
# Generate models and routes for a User
|
24
|
+
generate 'devise user'
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
__END__
|
29
|
+
|
30
|
+
name: Devise
|
31
|
+
description: Utilize Devise for authentication, automatically configured for your selected ORM.
|
32
|
+
author: fortuity
|
33
|
+
|
34
|
+
category: authentication
|
35
|
+
exclusive: authentication
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/devise_navigation.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
if recipes.include? 'devise'
|
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
|
+
__END__
|
88
|
+
|
89
|
+
name: DeviseNavigation
|
90
|
+
description: "Add navigation links for Devise."
|
91
|
+
author: fortuity
|
92
|
+
|
93
|
+
requires: [devise]
|
94
|
+
category: other
|
95
|
+
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]
|
data/recipes/git.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/git.rb
|
3
|
+
|
4
|
+
after_everything do
|
5
|
+
# Git should ignore some files
|
6
|
+
remove_file '.gitignore'
|
7
|
+
get "https://github.com/fortuity/rails3-gitignore/raw/master/gitignore.txt", ".gitignore"
|
8
|
+
# Initialize new Git repo
|
9
|
+
git :init
|
10
|
+
git :add => '.'
|
11
|
+
git :commit => "-aqm 'Initial commit of a new Rails app'"
|
12
|
+
# Create a git branch
|
13
|
+
git :checkout => ' -b working_branch'
|
14
|
+
git :add => '.'
|
15
|
+
git :commit => "-m 'Initial commit of working_branch'"
|
16
|
+
end
|
17
|
+
|
18
|
+
__END__
|
19
|
+
|
20
|
+
name: Git
|
21
|
+
description: "Provides basic Git setup for the Rails app and commits the initial repository."
|
22
|
+
author: fortuity
|
23
|
+
|
24
|
+
exclusive: scm
|
25
|
+
category: other
|
26
|
+
tags: [scm]
|
data/recipes/haml.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/haml.rb
|
3
|
+
|
4
|
+
gem 'haml', '>= 3.0.25'
|
5
|
+
gem 'haml-rails', '>= 0.3.4', :group => :development
|
6
|
+
|
7
|
+
__END__
|
8
|
+
|
9
|
+
name: HAML
|
10
|
+
description: "Utilize HAML for templating."
|
11
|
+
author: fortuity
|
12
|
+
|
13
|
+
category: templating
|
14
|
+
exclusive: templating
|
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,43 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/home_page.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
# remove the default home page
|
7
|
+
remove_file 'public/index.html'
|
8
|
+
|
9
|
+
# create a home controller and view
|
10
|
+
generate(:controller, "home index")
|
11
|
+
|
12
|
+
# set up a simple home page (with placeholder content)
|
13
|
+
if recipes.include? 'haml'
|
14
|
+
remove_file 'app/views/home/index.html.haml'
|
15
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
16
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
17
|
+
create_file 'app/views/home/index.html.haml' do
|
18
|
+
<<-'HAML'
|
19
|
+
%h3 Home
|
20
|
+
HAML
|
21
|
+
end
|
22
|
+
else
|
23
|
+
remove_file 'app/views/home/index.html.erb'
|
24
|
+
create_file 'app/views/home/index.html.erb' do
|
25
|
+
<<-ERB
|
26
|
+
<h3>Home</h3>
|
27
|
+
ERB
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# set routes
|
32
|
+
gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"'
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
__END__
|
37
|
+
|
38
|
+
name: HomePage
|
39
|
+
description: "Create a simple home page (with a home controller and view)."
|
40
|
+
author: fortuity
|
41
|
+
|
42
|
+
category: other
|
43
|
+
tags: [utilities, configuration]
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/home_page_users.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
if recipes.include? 'devise'
|
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
|
+
__END__
|
43
|
+
|
44
|
+
name: HomePageUsers
|
45
|
+
description: "Display a list of users on the home page."
|
46
|
+
author: fortuity
|
47
|
+
|
48
|
+
requires: [devise]
|
49
|
+
category: other
|
50
|
+
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
|