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.
Files changed (61) hide show
  1. data/README.textile +135 -0
  2. data/bin/rails3_devise_wizard +7 -0
  3. data/lib/rails_wizard/command.rb +79 -0
  4. data/lib/rails_wizard/config.rb +86 -0
  5. data/lib/rails_wizard/recipe.rb +106 -0
  6. data/lib/rails_wizard/recipes.rb +38 -0
  7. data/lib/rails_wizard/template.rb +58 -0
  8. data/lib/rails_wizard.rb +10 -0
  9. data/recipes/action_mailer.rb +41 -0
  10. data/recipes/activerecord.rb +37 -0
  11. data/recipes/add_user_name.rb +75 -0
  12. data/recipes/application_layout.rb +43 -0
  13. data/recipes/ban_spiders.rb +19 -0
  14. data/recipes/capybara.rb +34 -0
  15. data/recipes/cleanup.rb +34 -0
  16. data/recipes/css_setup.rb +40 -0
  17. data/recipes/cucumber.rb +69 -0
  18. data/recipes/devise.rb +35 -0
  19. data/recipes/devise_navigation.rb +95 -0
  20. data/recipes/env_yaml.rb +54 -0
  21. data/recipes/git.rb +26 -0
  22. data/recipes/haml.rb +14 -0
  23. data/recipes/heroku.rb +58 -0
  24. data/recipes/home_page.rb +43 -0
  25. data/recipes/home_page_users.rb +50 -0
  26. data/recipes/hoptoad.rb +34 -0
  27. data/recipes/jammit.rb +43 -0
  28. data/recipes/jquery.rb +44 -0
  29. data/recipes/less.rb +12 -0
  30. data/recipes/mongo_mapper.rb +18 -0
  31. data/recipes/mongohq.rb +59 -0
  32. data/recipes/mongoid.rb +30 -0
  33. data/recipes/mootools.rb +23 -0
  34. data/recipes/omniauth.rb +15 -0
  35. data/recipes/pow.rb +12 -0
  36. data/recipes/prototype.rb +11 -0
  37. data/recipes/rails_admin.rb +21 -0
  38. data/recipes/redis.rb +17 -0
  39. data/recipes/redistogo.rb +40 -0
  40. data/recipes/rightjs.rb +17 -0
  41. data/recipes/rspec.rb +89 -0
  42. data/recipes/sass.rb +13 -0
  43. data/recipes/seed_database.rb +35 -0
  44. data/recipes/sequel.rb +13 -0
  45. data/recipes/settingslogic.rb +43 -0
  46. data/recipes/slim.rb +11 -0
  47. data/recipes/test_unit.rb +11 -0
  48. data/recipes/users_page.rb +103 -0
  49. data/spec/rails_wizard/config_spec.rb +99 -0
  50. data/spec/rails_wizard/recipe_spec.rb +103 -0
  51. data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
  52. data/spec/rails_wizard/recipes_spec.rb +24 -0
  53. data/spec/rails_wizard/template_spec.rb +48 -0
  54. data/spec/spec_helper.rb +11 -0
  55. data/spec/support/rails_directory.rb +17 -0
  56. data/spec/support/template_runner.rb +28 -0
  57. data/templates/helpers.erb +45 -0
  58. data/templates/layout.erb +46 -0
  59. data/templates/recipe.erb +10 -0
  60. data/version.rb +3 -0
  61. metadata +205 -0
@@ -0,0 +1,58 @@
1
+ module RailsWizard
2
+ class Template
3
+ attr_reader :recipes
4
+
5
+ def initialize(recipes)
6
+ @recipes = recipes.map{|r| RailsWizard::Recipe.from_mongo(r)}
7
+ end
8
+
9
+ def self.template_root
10
+ File.dirname(__FILE__) + '/../../templates'
11
+ end
12
+
13
+ def self.render(template_name, binding = nil)
14
+ erb = ERB.new(File.open(template_root + '/' + template_name + '.erb').read)
15
+ erb.result(binding)
16
+ end
17
+ def render(template_name, binding = nil); self.class.render(template_name, binding) end
18
+
19
+
20
+ def resolve_recipes
21
+ # @resolve_recipes ||= recipes_with_dependencies.sort
22
+ @resolve_recipes ||= recipes_with_dependencies
23
+ end
24
+
25
+ def recipe_classes
26
+ @recipe_classes ||= recipes.map{|r| RailsWizard::Recipe.from_mongo(r)}
27
+ end
28
+
29
+ def recipes_with_dependencies
30
+ @recipes_with_dependencies ||= recipe_classes
31
+
32
+ added_more = false
33
+ for recipe in recipe_classes
34
+ recipe.requires.each do |requirement|
35
+ requirement = RailsWizard::Recipe.from_mongo(requirement)
36
+ count = @recipes_with_dependencies.size
37
+ (@recipes_with_dependencies << requirement).uniq!
38
+ unless @recipes_with_dependencies.size == count
39
+ added_more = true
40
+ end
41
+ end
42
+ end
43
+
44
+ added_more ? recipes_with_dependencies : @recipes_with_dependencies
45
+ end
46
+
47
+ def compile
48
+ render 'layout', binding
49
+ end
50
+
51
+ def args
52
+ recipes.map(&:args).uniq
53
+ end
54
+
55
+ def custom_code?; false end
56
+ def custom_code; nil end
57
+ end
58
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails_wizard/recipes'
2
+ require 'rails_wizard/recipe'
3
+ require 'rails_wizard/config'
4
+ require 'rails_wizard/template'
5
+
6
+ Dir[File.dirname(__FILE__) + '/../recipes/*.rb'].each do |path|
7
+ key = File.basename(path, '.rb')
8
+ recipe = RailsWizard::Recipe.generate(key, File.open(path))
9
+ RailsWizard::Recipes.add(recipe)
10
+ end
@@ -0,0 +1,41 @@
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/action_mailer.rb
3
+
4
+ after_bundler do
5
+
6
+ # modifying environment configuration files for ActionMailer
7
+ gsub_file 'config/environments/development.rb', /# Don't care if the mailer can't send/, '# ActionMailer Config'
8
+ gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do
9
+ <<-RUBY
10
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
11
+ # A dummy setup for development - no deliveries, but logged
12
+ config.action_mailer.delivery_method = :smtp
13
+ config.action_mailer.perform_deliveries = false
14
+ config.action_mailer.raise_delivery_errors = true
15
+ config.action_mailer.default :charset => "utf-8"
16
+ RUBY
17
+ end
18
+ gsub_file 'config/environments/production.rb', /config.active_support.deprecation = :notify/ do
19
+ <<-RUBY
20
+ config.active_support.deprecation = :notify
21
+
22
+ config.action_mailer.default_url_options = { :host => 'yourhost.com' }
23
+ # ActionMailer Config
24
+ # Setup for production - deliveries, no errors raised
25
+ config.action_mailer.delivery_method = :smtp
26
+ config.action_mailer.perform_deliveries = true
27
+ config.action_mailer.raise_delivery_errors = false
28
+ config.action_mailer.default :charset => "utf-8"
29
+ RUBY
30
+ end
31
+
32
+ end
33
+
34
+ __END__
35
+
36
+ name: ActionMailer
37
+ description: "Configure ActionMailer to show errors during development and suppress failures when the app is deployed to production."
38
+ author: fortuity
39
+
40
+ category: other
41
+ tags: [utilities, configuration]
@@ -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?"
@@ -0,0 +1,75 @@
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/add_user_name.rb
3
+
4
+ after_bundler do
5
+
6
+ # Add a 'name' attribute to the User model
7
+ if recipes.include? 'mongoid'
8
+ gsub_file 'app/models/user.rb', /end/ do
9
+ <<-RUBY
10
+ field :name
11
+ validates_presence_of :name
12
+ validates_uniqueness_of :name, :email, :case_sensitive => false
13
+ attr_accessible :name, :email, :password, :password_confirmation, :remember_me
14
+ end
15
+ RUBY
16
+ end
17
+ elsif recipes.include? 'mongo_mapper'
18
+ # Using MongoMapper? Create an issue, suggest some code, and I'll add it
19
+ elsif recipes.include? 'active_record'
20
+ gsub_file 'app/models/user.rb', /end/ do
21
+ <<-RUBY
22
+ validates_presence_of :name
23
+ validates_uniqueness_of :name, :email, :case_sensitive => false
24
+ attr_accessible :name, :email, :password, :password_confirmation, :remember_me
25
+ end
26
+ RUBY
27
+ end
28
+ else
29
+ # Placeholder for some other ORM
30
+ end
31
+
32
+ if recipes.include? 'devise'
33
+ unless recipes.include? 'haml'
34
+
35
+ # Generate Devise views (unless you are using Haml)
36
+ run 'rails generate devise:views'
37
+
38
+ # Modify Devise views to add 'name'
39
+ inject_into_file "app/views/devise/registrations/edit.html.erb", :after => "<%= devise_error_messages! %>\n" do
40
+ <<-ERB
41
+ <p><%= f.label :name %><br />
42
+ <%= f.text_field :name %></p>
43
+ ERB
44
+ end
45
+
46
+ inject_into_file "app/views/devise/registrations/new.html.erb", :after => "<%= devise_error_messages! %>\n" do
47
+ <<-ERB
48
+ <p><%= f.label :name %><br />
49
+ <%= f.text_field :name %></p>
50
+ ERB
51
+ end
52
+
53
+ else
54
+
55
+ # copy Haml versions of modified Devise views
56
+ inside 'app/views/devise/registrations' do
57
+ get 'https://github.com/fortuity/rails3-application-templates/raw/master/files/rails3-mongoid-devise/app/views/devise/registrations/edit.html.haml', 'edit.html.haml'
58
+ get 'https://github.com/fortuity/rails3-application-templates/raw/master/files/rails3-mongoid-devise/app/views/devise/registrations/new.html.haml', 'new.html.haml'
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+
67
+ __END__
68
+
69
+ name: AddUserName
70
+ description: "Modify the default Devise configuration to add a 'name' attribute for all users."
71
+ author: fortuity
72
+
73
+ requires: [devise]
74
+ category: other
75
+ tags: [utilities, configuration]
@@ -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/application_layout.rb
3
+
4
+ after_bundler do
5
+
6
+ # Set up the default application layout
7
+ if recipes.include? 'haml'
8
+ remove_file 'app/views/layouts/application.html.erb'
9
+ # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
10
+ create_file 'app/views/layouts/application.html.haml' do <<-HAML
11
+ !!!
12
+ %html
13
+ %head
14
+ %title #{app_name}
15
+ = stylesheet_link_tag :all
16
+ = javascript_include_tag :defaults
17
+ = csrf_meta_tag
18
+ %body
19
+ - flash.each do |name, msg|
20
+ = content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String)
21
+ = yield
22
+ HAML
23
+ end
24
+ else
25
+ inject_into_file 'app/views/layouts/application.html.erb', :after => "<body>\n" do
26
+ <<-ERB
27
+ <%- flash.each do |name, msg| -%>
28
+ <%= content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String) %>
29
+ <%- end -%>
30
+ ERB
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ __END__
37
+
38
+ name: ApplicationLayout
39
+ description: "Add a default application layout with flash messages."
40
+ author: fortuity
41
+
42
+ category: other
43
+ tags: [utilities, configuration]
@@ -0,0 +1,19 @@
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/ban_spiders.rb
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
+
10
+ end
11
+
12
+ __END__
13
+
14
+ name: BanSpiders
15
+ description: "Ban spiders from the site by changing robots.txt."
16
+ author: fortuity
17
+
18
+ category: other
19
+ tags: [utilities, configuration]
@@ -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]
@@ -0,0 +1,34 @@
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/cleanup.rb
3
+
4
+ after_bundler do
5
+
6
+ # remove unnecessary files
7
+ %w{
8
+ README
9
+ doc/README_FOR_APP
10
+ public/index.html
11
+ public/images/rails.png
12
+ }.each { |file| remove_file file }
13
+
14
+ # add placeholder READMEs
15
+ get "https://github.com/fortuity/rails-template-recipes/raw/master/sample_readme.txt", "README"
16
+ get "https://github.com/fortuity/rails-template-recipes/raw/master/sample_readme.textile", "README.textile"
17
+ gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}"
18
+ gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}"
19
+
20
+ # remove commented lines from Gemfile
21
+ # thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
22
+ gsub_file "Gemfile", /#.*\n/, "\n"
23
+ gsub_file "Gemfile", /\n+/, "\n"
24
+
25
+ end
26
+
27
+ __END__
28
+
29
+ name: Cleanup
30
+ description: "Remove unnecessary files left over from generating a new Rails app."
31
+ author: fortuity
32
+
33
+ category: other
34
+ tags: [utilities, configuration]
@@ -0,0 +1,40 @@
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/css_setup.rb
3
+
4
+ after_bundler do
5
+
6
+ # Add a stylesheet with styles for a horizontal menu and flash messages
7
+ create_file 'public/stylesheets/application.css' do <<-CSS
8
+ ul.hmenu {
9
+ list-style: none;
10
+ margin: 0 0 2em;
11
+ padding: 0;
12
+ }
13
+ ul.hmenu li {
14
+ display: inline;
15
+ }
16
+ #flash_notice, #flash_alert {
17
+ padding: 5px 8px;
18
+ margin: 10px 0;
19
+ }
20
+ #flash_notice {
21
+ background-color: #CFC;
22
+ border: solid 1px #6C6;
23
+ }
24
+ #flash_alert {
25
+ background-color: #FCC;
26
+ border: solid 1px #C66;
27
+ }
28
+ CSS
29
+ end
30
+
31
+ end
32
+
33
+ __END__
34
+
35
+ name: CssSetup
36
+ description: "Add a stylesheet with styles for a horizontal menu and flash messages."
37
+ author: fortuity
38
+
39
+ category: other
40
+ tags: [utilities, configuration]
@@ -0,0 +1,69 @@
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/cucumber.rb
3
+
4
+ gem 'cucumber-rails', ">= 0.4.0", :group => :test
5
+ gem 'capybara', ">= 0.4.1.2", :group => :test
6
+ gem 'launchy', ">= 0.4.0", :group => :test
7
+ if config['relish']
8
+ gem 'relish', ">= 0.2.2", :group => :development
9
+ end
10
+
11
+ after_bundler do
12
+ generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}"
13
+
14
+ if recipes.include? 'mongoid'
15
+ # reset your application database to a pristine state during testing
16
+ create_file 'features/support/local_env.rb' do
17
+ <<-RUBY
18
+ require 'database_cleaner'
19
+ DatabaseCleaner.strategy = :truncation
20
+ DatabaseCleaner.orm = "mongoid"
21
+ Before { DatabaseCleaner.clean }
22
+ RUBY
23
+ end
24
+ end
25
+
26
+ # see https://github.com/aslakhellesoy/cucumber-rails/issues/closed/#issue/77
27
+ gsub_file 'features/support/env.rb', /require 'cucumber\/rails\/capybara_javascript_emulation'/, "# require 'cucumber/rails/capybara_javascript_emulation'"
28
+
29
+ end
30
+
31
+ if recipes.include? 'devise'
32
+
33
+ after_bundler do
34
+
35
+ # copy all the Cucumber scenario files from the rails3-mongoid-devise example app
36
+ inside 'features/users' do
37
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_in.feature', 'sign_in.feature'
38
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_out.feature', 'sign_out.feature'
39
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/sign_up.feature', 'sign_up.feature'
40
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/user_edit.feature', 'user_edit.feature'
41
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/users/user_show.feature', 'user_show.feature'
42
+ end
43
+ inside 'features/step_definitions' do
44
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/step_definitions/user_steps.rb', 'user_steps.rb'
45
+ end
46
+ remove_file 'features/support/paths.rb'
47
+ inside 'features/support' do
48
+ get 'https://github.com/fortuity/rails3-mongoid-devise/raw/master/features/support/paths.rb', 'paths.rb'
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+
55
+
56
+ __END__
57
+
58
+ name: Cucumber
59
+ description: "Use Cucumber for integration testing with Capybara."
60
+ author: fortuity
61
+
62
+ exclusive: acceptance_testing
63
+ category: testing
64
+ tags: [acceptance]
65
+
66
+ config:
67
+ - relish:
68
+ type: boolean
69
+ prompt: Install the relish gem for viewing Cucumber features?