rails3_devise_wizard 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -50,15 +50,15 @@ You'll find more details about the available recipes by browsing the repository
50
50
 
51
51
  h4. Generate a Starter App
52
52
 
53
- You can build an application by providing a list of recipes with the @-r@ option. For example, to build the "rails3-mongoid-devise":http://github.com/fortuity/rails3-mongoid-devise/ example application, run the command:
53
+ There are two ways to use the rails3_devise_wizard gem to generate a starter app.
54
54
 
55
- <pre>
56
- $ rails3_devise_wizard new APP_NAME -r git jquery haml rspec cucumber mongoid action_mailer devise add_user_name home_page home_page_users seed_database users_page css_setup application_layout devise_navigation cleanup ban_spiders
57
- </pre>
55
+ If you want to build a starter app for one-time use, you can build an application by providing a list of recipes with the @-r@ option. This will automatically generate an application using the specified recipes.
56
+
57
+ If you want to create and save an application template that you can reuse as needed to "clone" identical starter apps, you can download the rails3_devise_wizard project, customize recipes as needed, and use a @rake@ task to save a reusable application template file.
58
58
 
59
- This will automatically generate an application using the specified recipes.
59
+ Each of these approaches is described below.
60
60
 
61
- h2. Make Your Own Starter App (the Easy Way)
61
+ h2. Make Your Own Starter App for One-Time Use
62
62
 
63
63
  h4. Select Recipes
64
64
 
@@ -68,7 +68,13 @@ You can mix and match recipes to create your own customized starter app. Browse
68
68
  $ rails3_devise_wizard new APP_NAME -r jquery haml
69
69
  </pre>
70
70
 
71
- h2. Make Your Own Starter App (the Advanced Way)
71
+ To build the "rails3-mongoid-devise":http://github.com/fortuity/rails3-mongoid-devise/ example application, run the command:
72
+
73
+ <pre>
74
+ $ rails3_devise_wizard new APP_NAME -r jquery haml rspec cucumber mongoid action_mailer devise add_user_name home_page home_page_users seed_database users_page css_setup application_layout devise_navigation cleanup ban_spiders git
75
+ </pre>
76
+
77
+ h2. Make Your Own Starter App with a Reusable Application Template
72
78
 
73
79
  You can modify the recipes and save an application template that creates your own customized starter app.
74
80
 
@@ -91,12 +97,18 @@ h4. Save the Application Template
91
97
  The rails3_devise_wizard gem creates an application template as an intermediate step before generating an application. You can generate and save the application template. Here's an example of generating an application template and saving the template to a file:
92
98
 
93
99
  <pre>
94
- $ rake print RECIPES=recipe1,recipe2 > ~/Desktop/template.txt
100
+ $ rake print --silent RECIPES=recipe1,recipe2 > ~/Desktop/template.txt
101
+ </pre>
102
+
103
+ To build a reusable application template for the "rails3-mongoid-devise":http://github.com/fortuity/rails3-mongoid-devise/ example application, run the command:
104
+
105
+ <pre>
106
+ $ rake print --silent RECIPES=jquery,haml,rspec,cucumber,mongoid,action_mailer,devise,add_user_name,home_page,home_page_users,seed_database,users_page,css_setup,application_layout,devise_navigation,cleanup,ban_spiders,git > ~/Desktop/template.txt
95
107
  </pre>
96
108
 
97
109
  h4. Edit the Application Template
98
110
 
99
- The application template is generated with an extraneous first line. Open the template file and remove the first line if it doesn't begin with a comment.
111
+ If you don't include the @--silent@ option, the rake task will generate the application template with an extraneous first line. Open the template file and remove the first line if you encounter this problem.
100
112
 
101
113
  h4. Generate an Application from an Application Template
102
114
 
@@ -2,7 +2,7 @@
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/action_mailer.rb
3
3
 
4
4
  after_bundler do
5
-
5
+ say_wizard "ActionMailer recipe running 'after bundler'"
6
6
  # modifying environment configuration files for ActionMailer
7
7
  gsub_file 'config/environments/development.rb', /# Don't care if the mailer can't send/, '# ActionMailer Config'
8
8
  gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do
@@ -2,7 +2,9 @@
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/add_user_name.rb
3
3
 
4
4
  after_bundler do
5
-
5
+
6
+ say_wizard "AddUserName recipe running 'after bundler'"
7
+
6
8
  # Add a 'name' attribute to the User model
7
9
  if recipes.include? 'mongoid'
8
10
  gsub_file 'app/models/user.rb', /end/ do
@@ -3,6 +3,8 @@
3
3
 
4
4
  after_bundler do
5
5
 
6
+ say_wizard "ApplicationLayout recipe running 'after bundler'"
7
+
6
8
  # Set up the default application layout
7
9
  if recipes.include? 'haml'
8
10
  remove_file 'app/views/layouts/application.html.erb'
@@ -1,12 +1,15 @@
1
1
  # Application template recipe for the rails3_devise_wizard. Check for a newer version here:
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/ban_spiders.rb
3
3
 
4
- after_bundler do
5
-
6
- # ban spiders from your site by changing robots.txt
7
- gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent'
8
- gsub_file 'public/robots.txt', /# Disallow/, 'Disallow'
9
-
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')
10
13
  end
11
14
 
12
15
  __END__
@@ -17,3 +20,8 @@ author: fortuity
17
20
 
18
21
  category: other
19
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/cleanup.rb CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
  after_bundler do
5
5
 
6
+ say_wizard "Cleanup recipe running 'after bundler'"
7
+
6
8
  # remove unnecessary files
7
9
  %w{
8
10
  README
data/recipes/css_setup.rb CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
  after_bundler do
5
5
 
6
+ say_wizard "CssSetup recipe running 'after bundler'"
7
+
6
8
  # Add a stylesheet with styles for a horizontal menu and flash messages
7
9
  create_file 'public/stylesheets/application.css' do <<-CSS
8
10
  ul.hmenu {
data/recipes/cucumber.rb CHANGED
@@ -1,61 +1,65 @@
1
1
  # Application template recipe for the rails3_devise_wizard. Check for a newer version here:
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/cucumber.rb
3
3
 
4
- gem 'cucumber-rails', ">= 0.4.1", :group => :test
5
- gem 'capybara', ">= 0.4.1.2", :group => :test
6
- gem 'launchy', ">= 0.4.0", :group => :test
7
-
8
- after_bundler do
9
- generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}"
10
-
11
- if recipes.include? 'mongoid'
12
- # reset your application database to a pristine state during testing
13
- create_file 'features/support/local_env.rb' do
14
- <<-RUBY
15
- require 'database_cleaner'
16
- DatabaseCleaner.strategy = :truncation
17
- DatabaseCleaner.orm = "mongoid"
18
- Before { DatabaseCleaner.clean }
19
- RUBY
20
- end
4
+ if config['cucumber']
5
+ gem 'cucumber-rails', ">= 0.4.1", :group => :test
6
+ gem 'capybara', ">= 0.4.1.2", :group => :test
7
+ unless recipes.include? 'rspec'
8
+ # we already added database_cleaner if we ran the rspec recipe
9
+ gem 'database_cleaner', '>= 0.6.6', :group => :test
21
10
  end
22
-
23
- # see https://github.com/aslakhellesoy/cucumber-rails/issues/closed/#issue/77
24
- gsub_file 'features/support/env.rb', /require 'cucumber\/rails\/capybara_javascript_emulation'/, "# require 'cucumber/rails/capybara_javascript_emulation'"
25
-
11
+ gem 'launchy', ">= 0.4.0", :group => :test
12
+ else
13
+ recipes.delete('cucumber')
26
14
  end
27
15
 
28
- if recipes.include? 'devise'
29
-
16
+ if config['cucumber']
30
17
  after_bundler do
31
-
32
- # copy all the Cucumber scenario files from the rails3-mongoid-devise example app
33
- inside 'features/users' do
34
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_in.feature', 'sign_in.feature'
35
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_out.feature', 'sign_out.feature'
36
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_up.feature', 'sign_up.feature'
37
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/user_edit.feature', 'user_edit.feature'
38
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/user_show.feature', 'user_show.feature'
39
- end
40
- inside 'features/step_definitions' do
41
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/step_definitions/user_steps.rb', 'user_steps.rb'
18
+ say_wizard "Cucumber recipe running 'after bundler'"
19
+ generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}"
20
+ if recipes.include? 'mongoid'
21
+ gsub_file 'features/support/env.rb', /transaction/, "truncation"
22
+ inject_into_file 'features/support/env.rb', :after => 'begin' do
23
+ "\n DatabaseCleaner.orm = 'mongoid'"
24
+ end
42
25
  end
43
- remove_file 'features/support/paths.rb'
44
- inside 'features/support' do
45
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/support/paths.rb', 'paths.rb'
46
- end
47
-
48
26
  end
49
-
50
27
  end
51
28
 
29
+ if config['cucumber']
30
+ if recipes.include? 'devise'
31
+ after_bundler do
32
+ say_wizard "Copying Cucumber scenarios from the rails3-mongoid-devise examples"
33
+ # copy all the Cucumber scenario files from the rails3-mongoid-devise example app
34
+ inside 'features/users' do
35
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_in.feature', 'sign_in.feature'
36
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_out.feature', 'sign_out.feature'
37
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_up.feature', 'sign_up.feature'
38
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/user_edit.feature', 'user_edit.feature'
39
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/user_show.feature', 'user_show.feature'
40
+ end
41
+ inside 'features/step_definitions' do
42
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/step_definitions/user_steps.rb', 'user_steps.rb'
43
+ end
44
+ remove_file 'features/support/paths.rb'
45
+ inside 'features/support' do
46
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/support/paths.rb', 'paths.rb'
47
+ end
48
+ end
49
+ end
50
+ end
52
51
 
53
52
  __END__
54
53
 
55
54
  name: Cucumber
56
- description: "Use Cucumber for integration testing with Capybara."
55
+ description: "Use Cucumber for BDD (with Capybara)."
57
56
  author: fortuity
58
57
 
59
58
  exclusive: acceptance_testing
60
59
  category: testing
61
60
  tags: [acceptance]
61
+
62
+ config:
63
+ - cucumber:
64
+ type: boolean
65
+ prompt: Would you like to use Cucumber for your BDD?
data/recipes/devise.rb CHANGED
@@ -1,51 +1,67 @@
1
1
  # Application template recipe for the rails3_devise_wizard. Check for a newer version here:
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/devise.rb
3
3
 
4
- gem "devise", ">= 1.3.0"
4
+ if config['devise']
5
+ gem "devise", ">= 1.3.0"
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'
5
18
 
6
- after_bundler do
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
7
27
 
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'
28
+ # Prevent logging of password_confirmation
29
+ gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
30
+
31
+ # Generate models and routes for a User
32
+ generate 'devise user'
33
+
18
34
  end
19
-
20
- # Prevent logging of password_confirmation
21
- gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
22
35
 
23
- # Generate models and routes for a User
24
- generate 'devise user'
36
+ after_everything do
25
37
 
26
- if recipes.include? 'rspec'
27
- # copy all the RSpec specs files from the rails3-mongoid-devise example app
28
- inside 'spec' do
29
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/spec/factories.rb', 'factories.rb'
30
- end
31
- remove_file 'spec/controllers/home_controller_spec.rb'
32
- remove_file 'spec/controllers/users_controller_spec.rb'
33
- inside 'spec/controllers' do
34
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/spec/controllers/home_controller_spec.rb', 'home_controller_spec.rb'
35
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/spec/controllers/users_controller_spec.rb', 'users_controller_spec.rb'
36
- end
37
- remove_file 'spec/models/user_spec.rb'
38
- inside 'spec/models' do
39
- get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/spec/models/user_spec.rb', 'user_spec.rb'
38
+ say_wizard "Devise recipe running 'after everything'"
39
+
40
+ if recipes.include? 'rspec'
41
+ say_wizard "Copying RSpec files from the rails3-mongoid-devise examples"
42
+ # copy all the RSpec specs files from the rails3-mongoid-devise example app
43
+ inside 'spec' do
44
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/spec/factories.rb', 'factories.rb'
45
+ end
46
+ remove_file 'spec/controllers/home_controller_spec.rb'
47
+ remove_file 'spec/controllers/users_controller_spec.rb'
48
+ inside 'spec/controllers' do
49
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/spec/controllers/home_controller_spec.rb', 'home_controller_spec.rb'
50
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/spec/controllers/users_controller_spec.rb', 'users_controller_spec.rb'
51
+ end
52
+ remove_file 'spec/models/user_spec.rb'
53
+ inside 'spec/models' do
54
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/spec/models/user_spec.rb', 'user_spec.rb'
55
+ end
56
+ remove_file 'spec/views/home/index.html.erb_spec.rb'
57
+ remove_file 'spec/views/home/index.html.haml_spec.rb'
58
+ remove_file 'spec/views/users/show.html.erb_spec.rb'
59
+ remove_file 'spec/views/users/show.html.haml_spec.rb'
60
+ remove_file 'spec/helpers/home_helper_spec.rb'
61
+ remove_file 'spec/helpers/users_helper_spec.rb'
40
62
  end
41
- remove_file 'spec/views/home/index.html.erb_spec.rb'
42
- remove_file 'spec/views/home/index.html.haml_spec.rb'
43
- remove_file 'spec/views/users/show.html.erb_spec.rb'
44
- remove_file 'spec/views/users/show.html.haml_spec.rb'
45
- remove_file 'spec/helpers/home_helper_spec.rb'
46
- remove_file 'spec/helpers/users_helper_spec.rb'
47
- end
48
63
 
64
+ end
49
65
  end
50
66
 
51
67
  __END__
@@ -56,3 +72,8 @@ author: fortuity
56
72
 
57
73
  category: authentication
58
74
  exclusive: authentication
75
+
76
+ config:
77
+ - devise:
78
+ type: boolean
79
+ prompt: Would you like to use Devise for authentication?
@@ -3,7 +3,7 @@
3
3
 
4
4
  after_bundler do
5
5
 
6
- if recipes.include? 'devise'
6
+ say_wizard "DeviseNavigation recipe running 'after bundler'"
7
7
 
8
8
  # Create navigation links for Devise
9
9
  if recipes.include? 'haml'
@@ -80,8 +80,6 @@ ERB
80
80
  end
81
81
  end
82
82
 
83
- end
84
-
85
83
  end
86
84
 
87
85
  __END__
data/recipes/git.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/git.rb
3
3
 
4
4
  after_everything do
5
+ say_wizard "Git recipe running 'after everything'"
5
6
  # Git should ignore some files
6
7
  remove_file '.gitignore'
7
8
  get "https://github.com/fortuity/rails3-gitignore/raw/master/gitignore.txt", ".gitignore"
@@ -18,7 +19,7 @@ end
18
19
  __END__
19
20
 
20
21
  name: Git
21
- description: "Provides basic Git setup for the Rails app and commits the initial repository."
22
+ description: "Set up Git and commit the initial repository."
22
23
  author: fortuity
23
24
 
24
25
  exclusive: scm
data/recipes/haml.rb CHANGED
@@ -1,14 +1,23 @@
1
1
  # Application template recipe for the rails3_devise_wizard. Check for a newer version here:
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/haml.rb
3
3
 
4
- gem 'haml', '>= 3.0.25'
5
- gem 'haml-rails', '>= 0.3.4', :group => :development
4
+ if config['haml']
5
+ gem 'haml', '>= 3.0.25'
6
+ gem 'haml-rails', '>= 0.3.4', :group => :development
7
+ else
8
+ recipes.delete('haml')
9
+ end
6
10
 
7
11
  __END__
8
12
 
9
13
  name: HAML
10
- description: "Utilize HAML for templating."
14
+ description: "Utilize Haml instead of ERB."
11
15
  author: fortuity
12
16
 
13
17
  category: templating
14
18
  exclusive: templating
19
+
20
+ config:
21
+ - haml:
22
+ type: boolean
23
+ prompt: Would you like to use Haml instead of ERB?
data/recipes/home_page.rb CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
  after_bundler do
5
5
 
6
+ say_wizard "HomePage recipe running 'after bundler'"
7
+
6
8
  # remove the default home page
7
9
  remove_file 'public/index.html'
8
10
 
@@ -36,7 +38,7 @@ end
36
38
  __END__
37
39
 
38
40
  name: HomePage
39
- description: "Create a simple home page (with a home controller and view)."
41
+ description: "Create a simple home page (creates a home controller and view)."
40
42
  author: fortuity
41
43
 
42
44
  category: other
@@ -3,38 +3,36 @@
3
3
 
4
4
  after_bundler do
5
5
 
6
- if recipes.include? 'devise'
6
+ say_wizard "HomePageUsers recipe running 'after bundler'"
7
7
 
8
- # Modify the home controller
9
- gsub_file 'app/controllers/home_controller.rb', /def index/ do
10
- <<-RUBY
8
+ # Modify the home controller
9
+ gsub_file 'app/controllers/home_controller.rb', /def index/ do
10
+ <<-RUBY
11
11
  def index
12
12
  @users = User.all
13
13
  RUBY
14
- end
14
+ end
15
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'
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
23
  %h3 Home
24
24
  - @users.each do |user|
25
25
  %p User: #{user.name}
26
26
  HAML
27
- end
28
- else
29
- append_file 'app/views/home/index.html.erb' do <<-ERB
27
+ end
28
+ else
29
+ append_file 'app/views/home/index.html.erb' do <<-ERB
30
30
  <h3>Home</h3>
31
31
  <% @users.each do |user| %>
32
32
  <p>User: <%= user.name %></p>
33
33
  <% end %>
34
34
  ERB
35
- end
36
35
  end
37
-
38
36
  end
39
37
 
40
38
  end
data/recipes/jquery.rb CHANGED
@@ -1,35 +1,42 @@
1
1
  # Application template recipe for the rails3_devise_wizard. Check for a newer version here:
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/jquery.rb
3
3
 
4
- after_bundler do
5
- # remove the Prototype adapter file
6
- remove_file 'public/javascripts/rails.js'
7
- # remove the Prototype files (if they exist)
8
- remove_file 'public/javascripts/controls.js'
9
- remove_file 'public/javascripts/dragdrop.js'
10
- remove_file 'public/javascripts/effects.js'
11
- remove_file 'public/javascripts/prototype.js'
12
- # add jQuery files
13
- inside "public/javascripts" do
14
- get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "rails.js"
15
- get "https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js", "jquery.js"
16
- if config['ui']
17
- get "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js", "jqueryui.js"
4
+ if config['jquery']
5
+ say_wizard "REMINDER: When creating a Rails app using jQuery..."
6
+ say_wizard "you should add the '-J' flag to 'rails new'"
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 "https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js", "jquery.js"
20
+ if config['ui']
21
+ get "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js", "jqueryui.js"
22
+ end
18
23
  end
24
+ # adjust the Javascript defaults
25
+ if config['ui']
26
+ inject_into_file 'config/application.rb', "config.action_view.javascript_expansions[:defaults] = %w(jquery jqueryui rails)\n", :after => "config.action_view.javascript_expansions[:defaults] = %w()\n", :verbose => false
27
+ else
28
+ inject_into_file 'config/application.rb', "config.action_view.javascript_expansions[:defaults] = %w(jquery rails)\n", :after => "config.action_view.javascript_expansions[:defaults] = %w()\n", :verbose => false
29
+ end
30
+ gsub_file "config/application.rb", /config.action_view.javascript_expansions\[:defaults\] = \%w\(\)\n/, ""
19
31
  end
20
- # adjust the Javascript defaults
21
- if config['ui']
22
- inject_into_file 'config/application.rb', "config.action_view.javascript_expansions[:defaults] = %w(jquery jqueryui rails)\n", :after => "config.action_view.javascript_expansions[:defaults] = %w()\n", :verbose => false
23
- else
24
- inject_into_file 'config/application.rb', "config.action_view.javascript_expansions[:defaults] = %w(jquery rails)\n", :after => "config.action_view.javascript_expansions[:defaults] = %w()\n", :verbose => false
25
- end
26
- gsub_file "config/application.rb", /config.action_view.javascript_expansions\[:defaults\] = \%w\(\)\n/, ""
32
+ else
33
+ recipes.delete('jquery')
27
34
  end
28
35
 
29
36
  __END__
30
37
 
31
38
  name: jQuery
32
- description: "Adds the latest jQuery and Rails UJS helpers for jQuery."
39
+ description: "Use jQuery instead of Prototype."
33
40
  author: fortuity
34
41
 
35
42
  exclusive: javascript_framework
@@ -39,6 +46,9 @@ tags: [javascript, framework]
39
46
  args: ["-J"]
40
47
 
41
48
  config:
49
+ - jquery:
50
+ type: boolean
51
+ prompt: Would you like to use jQuery instead of Prototype?
42
52
  - ui:
43
53
  type: boolean
44
- prompt: Install jQuery UI?
54
+ prompt: Would you like to use jQuery UI?
data/recipes/mongoid.rb CHANGED
@@ -1,25 +1,30 @@
1
1
  # Application template recipe for the rails3_devise_wizard. Check for a newer version here:
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/mongoid.rb
3
3
 
4
- gem 'bson_ext', '>= 1.3.0'
5
- gem 'mongoid', '>= 2.0.1'
4
+ if config['mongoid']
5
+ say_wizard "REMINDER: When creating a Rails app using Mongoid..."
6
+ say_wizard "you should add the '-O' flag to 'rails new'"
7
+ gem 'bson_ext', '>= 1.3.0'
8
+ gem 'mongoid', '>= 2.0.1'
9
+ else
10
+ recipes.delete('mongoid')
11
+ end
6
12
 
7
- after_bundler do
8
-
9
- generate 'mongoid:config'
10
-
11
- # note: the mongoid generator automatically modifies the config/application.rb file
12
- # to remove the ActiveRecord dependency by commenting out "require active_record/railtie'"
13
-
14
- # remove the unnecessary 'config/database.yml' file
15
- remove_file 'config/database.yml'
16
-
13
+ if config['mongoid']
14
+ after_bundler do
15
+ say_wizard "Mongoid recipe running 'after bundler'"
16
+ # note: the mongoid generator automatically modifies the config/application.rb file
17
+ # to remove the ActiveRecord dependency by commenting out "require active_record/railtie'"
18
+ generate 'mongoid:config'
19
+ # remove the unnecessary 'config/database.yml' file
20
+ remove_file 'config/database.yml'
21
+ end
17
22
  end
18
23
 
19
24
  __END__
20
25
 
21
26
  name: Mongoid
22
- description: "Utilize MongoDB with Mongoid as the ORM."
27
+ description: "Use Mongoid to connect to a MongoDB database."
23
28
  author: fortuity
24
29
 
25
30
  category: persistence
@@ -28,3 +33,7 @@ tags: [orm, mongodb]
28
33
 
29
34
  args: ["-O"]
30
35
 
36
+ config:
37
+ - mongoid:
38
+ type: boolean
39
+ prompt: Would you like to use Mongoid to connect to a MongoDB database?
data/recipes/rspec.rb CHANGED
@@ -1,31 +1,39 @@
1
1
  # Application template recipe for the rails3_devise_wizard. Check for a newer version here:
2
2
  # https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/rspec.rb
3
3
 
4
- gem 'rspec-rails', '>= 2.5.0', :group => [:development, :test]
5
- if recipes.include? 'mongoid'
6
- # use the database_cleaner gem to reset the test database
7
- gem 'database_cleaner', '>= 0.6.6', :group => :test
8
- # include RSpec matchers from the mongoid-rspec gem
9
- gem 'mongoid-rspec', ">= 1.4.1", :group => :test
10
- end
11
- if config['factory_girl']
12
- # use the factory_girl gem for test fixtures
13
- gem 'factory_girl_rails', ">= 1.1.beta1", :group => :test
4
+ if config['rspec']
5
+ say_wizard "REMINDER: When creating a Rails app using RSpec..."
6
+ say_wizard "you should add the '-T' flag to 'rails new'"
7
+ gem 'rspec-rails', '>= 2.5.0', :group => [:development, :test]
8
+ if recipes.include? 'mongoid'
9
+ # use the database_cleaner gem to reset the test database
10
+ gem 'database_cleaner', '>= 0.6.6', :group => :test
11
+ # include RSpec matchers from the mongoid-rspec gem
12
+ gem 'mongoid-rspec', ">= 1.4.1", :group => :test
13
+ end
14
+ if config['factory_girl']
15
+ # use the factory_girl gem for test fixtures
16
+ gem 'factory_girl_rails', ">= 1.1.beta1", :group => :test
17
+ end
18
+ else
19
+ recipes.delete('rspec')
14
20
  end
15
21
 
16
22
  # note: there is no need to specify the RSpec generator in the config/application.rb file
17
23
 
18
- after_bundler do
19
- generate 'rspec:install'
24
+ if config['rspec']
25
+ after_bundler do
26
+ say_wizard "RSpec recipe running 'after bundler'"
27
+ generate 'rspec:install'
20
28
 
21
- # remove ActiveRecord artifacts
22
- gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
23
- gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
29
+ # remove ActiveRecord artifacts
30
+ gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
31
+ gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
24
32
 
25
- if recipes.include? 'mongoid'
26
- # reset your application database to a pristine state during testing
27
- inject_into_file 'spec/spec_helper.rb', :before => "\nend" do
28
- <<-RUBY
33
+ if recipes.include? 'mongoid'
34
+ # reset your application database to a pristine state during testing
35
+ inject_into_file 'spec/spec_helper.rb', :before => "\nend" do
36
+ <<-RUBY
29
37
  \n
30
38
  # Clean up the database
31
39
  require 'database_cleaner'
@@ -38,44 +46,45 @@ after_bundler do
38
46
  DatabaseCleaner.clean
39
47
  end
40
48
  RUBY
49
+ end
41
50
  end
42
- end
43
51
 
44
- # remove either possible occurrence of "require rails/test_unit/railtie"
45
- gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
46
- gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
52
+ # remove either possible occurrence of "require rails/test_unit/railtie"
53
+ gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
54
+ gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
47
55
 
48
- say_wizard "Removing test folder (not needed for RSpec)"
49
- run 'rm -rf test/'
56
+ say_wizard "Removing test folder (not needed for RSpec)"
57
+ run 'rm -rf test/'
50
58
 
51
- if recipes.include? 'mongoid'
52
- # configure RSpec to use matchers from the mongoid-rspec gem
53
- create_file 'spec/support/mongoid.rb' do
54
- <<-RUBY
59
+ if recipes.include? 'mongoid'
60
+ # configure RSpec to use matchers from the mongoid-rspec gem
61
+ create_file 'spec/support/mongoid.rb' do
62
+ <<-RUBY
55
63
  RSpec.configure do |config|
56
64
  config.include Mongoid::Matchers
57
65
  end
58
66
  RUBY
67
+ end
59
68
  end
60
- end
61
69
 
62
- if recipes.include? 'devise'
63
- # add Devise test helpers
64
- create_file 'spec/support/devise.rb' do
65
- <<-RUBY
70
+ if recipes.include? 'devise'
71
+ # add Devise test helpers
72
+ create_file 'spec/support/devise.rb' do
73
+ <<-RUBY
66
74
  RSpec.configure do |config|
67
75
  config.include Devise::TestHelpers, :type => :controller
68
76
  end
69
77
  RUBY
78
+ end
70
79
  end
71
- end
72
80
 
81
+ end
73
82
  end
74
83
 
75
84
  __END__
76
85
 
77
86
  name: RSpec
78
- description: "Use RSpec for unit testing for this Rails app."
87
+ description: "Use RSpec instead of TestUnit."
79
88
  author: fortuity
80
89
 
81
90
  exclusive: unit_testing
@@ -84,6 +93,9 @@ category: testing
84
93
  args: ["-T"]
85
94
 
86
95
  config:
96
+ - rspec:
97
+ type: boolean
98
+ prompt: Would you like to use RSpec instead of TestUnit?
87
99
  - factory_girl:
88
100
  type: boolean
89
- prompt: Install the factory_girl gem for test fixtures?
101
+ prompt: Would you like to use factory_girl for test fixtures with RSpec?
@@ -4,24 +4,22 @@
4
4
 
5
5
  after_bundler do
6
6
 
7
- if recipes.include? 'devise'
7
+ say_wizard "SeedDatabase recipe running 'after bundler'"
8
8
 
9
- if recipes.include? 'mongoid'
10
- # create a default user
11
- append_file 'db/seeds.rb' do <<-FILE
9
+ if recipes.include? 'mongoid'
10
+ # create a default user
11
+ append_file 'db/seeds.rb' do <<-FILE
12
12
  puts 'EMPTY THE MONGODB DATABASE'
13
13
  Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
14
14
  puts 'SETTING UP DEFAULT USER LOGIN'
15
15
  user = User.create! :name => 'First User', :email => 'user@test.com', :password => 'please', :password_confirmation => 'please'
16
16
  puts 'New user created: ' << user.name
17
17
  FILE
18
- end
19
18
  end
20
-
21
- run 'rake db:seed'
22
-
23
19
  end
24
20
 
21
+ run 'rake db:seed'
22
+
25
23
  end
26
24
 
27
25
  __END__
@@ -3,7 +3,7 @@
3
3
 
4
4
  after_bundler do
5
5
 
6
- if recipes.include? 'devise'
6
+ say_wizard "UsersPage recipe running 'after bundler'"
7
7
 
8
8
  #----------------------------------------------------------------------------
9
9
  # Create a users controller
@@ -88,8 +88,6 @@ ERB
88
88
  end
89
89
  end
90
90
 
91
- end
92
-
93
91
  end
94
92
 
95
93
  __END__
data/templates/layout.erb CHANGED
@@ -24,6 +24,7 @@ RUBY
24
24
 
25
25
  <%= render "helpers" %>
26
26
 
27
+ say_wizard "Checking configuration. Please confirm your preferences."
27
28
  <% resolve_recipes.each do |recipe| %>
28
29
  <%= render 'recipe', recipe.get_binding %>
29
30
  <% end %>
@@ -36,11 +37,16 @@ RUBY
36
37
 
37
38
  # >-----------------------------[ Run Bundler ]-------------------------------<
38
39
 
39
- say_wizard "Running Bundler install. This will take a while."
40
+ say_wizard "Running 'bundle install'. This will take a while."
40
41
  run 'bundle install'
41
- say_wizard "Running after Bundler callbacks."
42
+ say_wizard "Running 'after bundler' callbacks."
42
43
  @after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
43
44
 
44
45
  @current_recipe = nil
45
- say_wizard "Running after everything callbacks."
46
+ say_wizard "Running 'after everything' callbacks."
46
47
  @after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
48
+
49
+ @current_recipe = nil
50
+ say_wizard "Finished running the rails3_devise_wizard app template."
51
+ say_wizard "Your new Rails app is ready. Any problems?"
52
+ say_wizard "See http://github.com/fortuity/rails3-mongoid-devise/issues"
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RailsWizard
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rails3_devise_wizard
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.4
5
+ version: 0.2.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Kehoe
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-16 00:00:00 Z
13
+ date: 2011-04-18 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  requirements:
173
173
  - - ">="
174
174
  - !ruby/object:Gem::Version
175
- hash: 291566255609786799
175
+ hash: -209227308102531619
176
176
  segments:
177
177
  - 0
178
178
  version: "0"
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  requirements:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
- hash: 291566255609786799
184
+ hash: -209227308102531619
185
185
  segments:
186
186
  - 0
187
187
  version: "0"