rails_apps_composer 1.0.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.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/rightjs.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
gem 'right-rails'
|
2
|
+
|
3
|
+
after_bundler do
|
4
|
+
generate 'right_rails'
|
5
|
+
end
|
6
|
+
|
7
|
+
__END__
|
8
|
+
|
9
|
+
name: RightJS
|
10
|
+
description: "Use RightJS in place of Prototype for this application."
|
11
|
+
author: mbleigh
|
12
|
+
|
13
|
+
exclusive: javascript_framework
|
14
|
+
category: assets
|
15
|
+
tags: [javascript, framework]
|
16
|
+
|
17
|
+
args: ["-J"]
|
data/recipes/rspec.rb
ADDED
@@ -0,0 +1,112 @@
|
|
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/rspec.rb
|
3
|
+
|
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.7', :group => :test
|
11
|
+
# include RSpec matchers from the mongoid-rspec gem
|
12
|
+
gem 'mongoid-rspec', ">= 1.4.2", :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')
|
20
|
+
end
|
21
|
+
|
22
|
+
# note: there is no need to specify the RSpec generator in the config/application.rb file
|
23
|
+
|
24
|
+
if config['rspec']
|
25
|
+
after_bundler do
|
26
|
+
say_wizard "RSpec recipe running 'after bundler'"
|
27
|
+
generate 'rspec:install'
|
28
|
+
|
29
|
+
say_wizard "Removing test folder (not needed for RSpec)"
|
30
|
+
run 'rm -rf test/'
|
31
|
+
|
32
|
+
inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
|
33
|
+
|
34
|
+
# don't generate RSpec tests for views and helpers
|
35
|
+
config.generators do |g|
|
36
|
+
g.view_specs false
|
37
|
+
g.helper_specs false
|
38
|
+
end
|
39
|
+
|
40
|
+
RUBY
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
if recipes.include? 'mongoid'
|
45
|
+
|
46
|
+
# remove ActiveRecord artifacts
|
47
|
+
gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
|
48
|
+
gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
|
49
|
+
|
50
|
+
# reset your application database to a pristine state during testing
|
51
|
+
inject_into_file 'spec/spec_helper.rb', :before => "\nend" do
|
52
|
+
<<-RUBY
|
53
|
+
\n
|
54
|
+
# Clean up the database
|
55
|
+
require 'database_cleaner'
|
56
|
+
config.before(:suite) do
|
57
|
+
DatabaseCleaner.strategy = :truncation
|
58
|
+
DatabaseCleaner.orm = "mongoid"
|
59
|
+
end
|
60
|
+
|
61
|
+
config.before(:each) do
|
62
|
+
DatabaseCleaner.clean
|
63
|
+
end
|
64
|
+
RUBY
|
65
|
+
end
|
66
|
+
|
67
|
+
# remove either possible occurrence of "require rails/test_unit/railtie"
|
68
|
+
gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
|
69
|
+
gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
|
70
|
+
|
71
|
+
# configure RSpec to use matchers from the mongoid-rspec gem
|
72
|
+
create_file 'spec/support/mongoid.rb' do
|
73
|
+
<<-RUBY
|
74
|
+
RSpec.configure do |config|
|
75
|
+
config.include Mongoid::Matchers
|
76
|
+
end
|
77
|
+
RUBY
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if recipes.include? 'devise'
|
82
|
+
# add Devise test helpers
|
83
|
+
create_file 'spec/support/devise.rb' do
|
84
|
+
<<-RUBY
|
85
|
+
RSpec.configure do |config|
|
86
|
+
config.include Devise::TestHelpers, :type => :controller
|
87
|
+
end
|
88
|
+
RUBY
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
__END__
|
96
|
+
|
97
|
+
name: RSpec
|
98
|
+
description: "Use RSpec instead of TestUnit."
|
99
|
+
author: fortuity
|
100
|
+
|
101
|
+
exclusive: unit_testing
|
102
|
+
category: testing
|
103
|
+
|
104
|
+
args: ["-T"]
|
105
|
+
|
106
|
+
config:
|
107
|
+
- rspec:
|
108
|
+
type: boolean
|
109
|
+
prompt: Would you like to use RSpec instead of TestUnit?
|
110
|
+
- factory_girl:
|
111
|
+
type: boolean
|
112
|
+
prompt: Would you like to use factory_girl for test fixtures with RSpec?
|
data/recipes/sass.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
unless recipes.include? 'haml'
|
2
|
+
gem 'haml', '>= 3.0.0'
|
3
|
+
end
|
4
|
+
|
5
|
+
__END__
|
6
|
+
|
7
|
+
name: SASS
|
8
|
+
description: "Utilize SASS (through the HAML gem) for really awesome stylesheets!"
|
9
|
+
author: mbleigh
|
10
|
+
|
11
|
+
exclusive: css_replacement
|
12
|
+
category: assets
|
13
|
+
tags: [css]
|
@@ -0,0 +1,42 @@
|
|
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/seed_database.rb
|
3
|
+
|
4
|
+
|
5
|
+
after_bundler do
|
6
|
+
|
7
|
+
say_wizard "SeedDatabase recipe running 'after bundler'"
|
8
|
+
|
9
|
+
unless recipes.include? 'mongoid'
|
10
|
+
run 'rake db:migrate'
|
11
|
+
end
|
12
|
+
|
13
|
+
if recipes.include? 'mongoid'
|
14
|
+
append_file 'db/seeds.rb' do <<-FILE
|
15
|
+
puts 'EMPTY THE MONGODB DATABASE'
|
16
|
+
Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
|
17
|
+
FILE
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if recipes.include? 'devise'
|
22
|
+
# create a default user
|
23
|
+
append_file 'db/seeds.rb' do <<-FILE
|
24
|
+
puts 'SETTING UP DEFAULT USER LOGIN'
|
25
|
+
user = User.create! :name => 'First User', :email => 'user@test.com', :password => 'please', :password_confirmation => 'please'
|
26
|
+
puts 'New user created: ' << user.name
|
27
|
+
FILE
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
run 'rake db:seed'
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
__END__
|
36
|
+
|
37
|
+
name: SeedDatabase
|
38
|
+
description: "Create a database seed file with a default user."
|
39
|
+
author: fortuity
|
40
|
+
|
41
|
+
category: other
|
42
|
+
tags: [utilities, configuration]
|
data/recipes/sequel.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
gem 'settingslogic'
|
2
|
+
|
3
|
+
say_wizard "Generating config/application.yml..."
|
4
|
+
|
5
|
+
append_file "config/application.rb", <<-RUBY
|
6
|
+
|
7
|
+
require 'settings'
|
8
|
+
RUBY
|
9
|
+
|
10
|
+
create_file "lib/settings.rb", <<-RUBY
|
11
|
+
class Settings < Settingslogic
|
12
|
+
source "#\{Rails.root\}/config/application.yml"
|
13
|
+
namespace Rails.env
|
14
|
+
end
|
15
|
+
|
16
|
+
RUBY
|
17
|
+
|
18
|
+
create_file "config/application.yml", <<-YAML
|
19
|
+
defaults: &defaults
|
20
|
+
cool:
|
21
|
+
saweet: nested settings
|
22
|
+
neat_setting: 24
|
23
|
+
awesome_setting: <%= "Did you know 5 + 5 = #{5 + 5}?" %>
|
24
|
+
|
25
|
+
development:
|
26
|
+
<<: *defaults
|
27
|
+
neat_setting: 800
|
28
|
+
|
29
|
+
test:
|
30
|
+
<<: *defaults
|
31
|
+
|
32
|
+
production:
|
33
|
+
<<: *defaults
|
34
|
+
YAML
|
35
|
+
|
36
|
+
__END__
|
37
|
+
|
38
|
+
name: Settingslogic
|
39
|
+
description: "A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern."
|
40
|
+
author: elandesign
|
41
|
+
|
42
|
+
category: other
|
43
|
+
tags: [utilities, configuration]
|
data/recipes/slim.rb
ADDED
@@ -0,0 +1,103 @@
|
|
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/users_page.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "UsersPage recipe running 'after bundler'"
|
7
|
+
|
8
|
+
#----------------------------------------------------------------------------
|
9
|
+
# Create a users controller
|
10
|
+
#----------------------------------------------------------------------------
|
11
|
+
generate(:controller, "users show")
|
12
|
+
gsub_file 'app/controllers/users_controller.rb', /def show/ do
|
13
|
+
<<-RUBY
|
14
|
+
before_filter :authenticate_user!
|
15
|
+
|
16
|
+
def show
|
17
|
+
@user = User.find(params[:id])
|
18
|
+
RUBY
|
19
|
+
end
|
20
|
+
|
21
|
+
#----------------------------------------------------------------------------
|
22
|
+
# Modify the routes
|
23
|
+
#----------------------------------------------------------------------------
|
24
|
+
# @devise_for :users@ route must be placed above @resources :users, :only => :show@.
|
25
|
+
gsub_file 'config/routes.rb', /get \"users\/show\"/, '#get \"users\/show\"'
|
26
|
+
gsub_file 'config/routes.rb', /devise_for :users/ do
|
27
|
+
<<-RUBY
|
28
|
+
devise_for :users
|
29
|
+
resources :users, :only => :show
|
30
|
+
RUBY
|
31
|
+
end
|
32
|
+
|
33
|
+
#----------------------------------------------------------------------------
|
34
|
+
# Create a users show page
|
35
|
+
#----------------------------------------------------------------------------
|
36
|
+
if recipes.include? 'haml'
|
37
|
+
remove_file 'app/views/users/show.html.haml'
|
38
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
39
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
40
|
+
create_file 'app/views/users/show.html.haml' do <<-'HAML'
|
41
|
+
%p
|
42
|
+
User: #{@user.name}
|
43
|
+
%p
|
44
|
+
Email: #{@user.email if @user.email}
|
45
|
+
HAML
|
46
|
+
end
|
47
|
+
else
|
48
|
+
append_file 'app/views/users/show.html.erb' do <<-ERB
|
49
|
+
<p>User: <%= @user.name %></p>
|
50
|
+
<p>Email: <%= @user.email if @user.email %></p>
|
51
|
+
ERB
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#----------------------------------------------------------------------------
|
56
|
+
# Create a home page containing links to user show pages
|
57
|
+
# (clobbers code from the home_page_users recipe)
|
58
|
+
#----------------------------------------------------------------------------
|
59
|
+
# set up the controller
|
60
|
+
remove_file 'app/controllers/home_controller.rb'
|
61
|
+
create_file 'app/controllers/home_controller.rb' do
|
62
|
+
<<-RUBY
|
63
|
+
class HomeController < ApplicationController
|
64
|
+
def index
|
65
|
+
@users = User.all
|
66
|
+
end
|
67
|
+
end
|
68
|
+
RUBY
|
69
|
+
end
|
70
|
+
|
71
|
+
# modify the home page
|
72
|
+
if recipes.include? 'haml'
|
73
|
+
remove_file 'app/views/home/index.html.haml'
|
74
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
75
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
76
|
+
create_file 'app/views/home/index.html.haml' do
|
77
|
+
<<-'HAML'
|
78
|
+
%h3 Home
|
79
|
+
- @users.each do |user|
|
80
|
+
%p User: #{link_to user.name, user}
|
81
|
+
HAML
|
82
|
+
end
|
83
|
+
else
|
84
|
+
remove_file 'app/views/home/index.html.erb'
|
85
|
+
create_file 'app/views/home/index.html.erb' do <<-ERB
|
86
|
+
<h3>Home</h3>
|
87
|
+
<% @users.each do |user| %>
|
88
|
+
<p>User: <%=link_to user.name, user %></p>
|
89
|
+
<% end %>
|
90
|
+
ERB
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
__END__
|
97
|
+
|
98
|
+
name: UsersPage
|
99
|
+
description: "Add a users controller and user show page with links from the home page."
|
100
|
+
author: fortuity
|
101
|
+
|
102
|
+
category: other
|
103
|
+
tags: [utilities, configuration]
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsWizard::Config do
|
4
|
+
describe '#initialize' do
|
5
|
+
subject{ RailsWizard::Config.new(YAML.load(@schema)) }
|
6
|
+
it 'should add a question key for each key of the schema' do
|
7
|
+
@schema = <<-YAML
|
8
|
+
- test:
|
9
|
+
type: string
|
10
|
+
YAML
|
11
|
+
subject.questions.should be_key('test')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should instantiate the correct question type for each question' do
|
15
|
+
@schema = <<-YAML
|
16
|
+
- string:
|
17
|
+
type: string
|
18
|
+
- boolean:
|
19
|
+
type: boolean
|
20
|
+
- multiple_choice:
|
21
|
+
type: multiple_choice
|
22
|
+
YAML
|
23
|
+
subject.questions['string'].should be_kind_of(RailsWizard::Config::Prompt)
|
24
|
+
subject.questions['boolean'].should be_kind_of(RailsWizard::Config::TrueFalse)
|
25
|
+
subject.questions['multiple_choice'].should be_kind_of(RailsWizard::Config::MultipleChoice)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should error on invalid question type' do
|
29
|
+
@schema = <<-YAML
|
30
|
+
- invalid
|
31
|
+
type: invalid
|
32
|
+
YAML
|
33
|
+
lambda{ subject }.should raise_error(ArgumentError)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#compile' do
|
37
|
+
let(:lines) { subject.compile.split("\n") }
|
38
|
+
before do
|
39
|
+
@schema = <<-YAML
|
40
|
+
- string:
|
41
|
+
type: string
|
42
|
+
prompt: Give me a string?
|
43
|
+
if: is_true
|
44
|
+
- boolean:
|
45
|
+
type: boolean
|
46
|
+
prompt: Yes or no?
|
47
|
+
unless: is_false
|
48
|
+
if_recipe: awesome
|
49
|
+
- multiple_choice:
|
50
|
+
type: multiple_choice
|
51
|
+
choices: [[ABC, abc], [DEF, def]]
|
52
|
+
unless_recipe: awesome
|
53
|
+
YAML
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should include all questions' do
|
57
|
+
lines.size.should == 4
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should handle "if"' do
|
61
|
+
lines[1].should be_include("config['is_true']")
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should handle "unless"' do
|
65
|
+
lines[2].should be_include("!config['is_false']")
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should handle "if_recipe"' do
|
69
|
+
lines[2].should be_include("recipe?('awesome')")
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should handle "unelss_recipe"' do
|
73
|
+
lines[3].should be_include("!recipe?('awesome')")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe RailsWizard::Config::Prompt do
|
78
|
+
subject{ RailsWizard::Config::Prompt }
|
79
|
+
it 'should compile to a prompt' do
|
80
|
+
subject.new({'prompt' => "What's your favorite color?"}).question.should == 'ask_wizard("What\'s your favorite color?")'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe RailsWizard::Config::TrueFalse do
|
85
|
+
subject{ RailsWizard::Config::TrueFalse }
|
86
|
+
it 'should compile to a yes? question' do
|
87
|
+
subject.new({'prompt' => 'Yes yes?'}).question.should == 'yes_wizard?("Yes yes?")'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe RailsWizard::Config::MultipleChoice do
|
92
|
+
subject{ RailsWizard::Config::MultipleChoice }
|
93
|
+
it 'should compile into a multiple_choice' do
|
94
|
+
subject.new({'prompt' => 'What kind of fruit?', 'choices' => [['Apples', 'apples'], ['Bananas', 'bananas']]}).question.should ==
|
95
|
+
'multiple_choice("What kind of fruit?", [["Apples", "apples"], ["Bananas", "bananas"]])'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|