-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.rb
140 lines (101 loc) · 4.91 KB
/
template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# >---------------------------[ Install Command ]-----------------------------<
# rails new APP_NAME -m http://railswizard.org/c06d889533aacd7e527f.rb -T -J
# >---------------------------------------------------------------------------<
#
# _____ _ _ __ ___ _
# | __ \ (_) | \ \ / (_) | |
# | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
# | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
# | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
# |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
#
# This template was generated by RailsWizard, the amazing and awesome Rails
# application template builder. Get started at http://railswizard.org
#
# ___________________________________________________________________________
# |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
# | | |
# | Name: | ar_jquery_cucumber_rspec_devise_haml |
# | URL: | http://railswizard.org/c06d889533aacd7e527f.rb |
# | Updated: | March 05, 2011 at 20:06PM |
# | | |
# |\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
# ---------------------------------------------------------------------------
# >----------------------------[ Initial Setup ]------------------------------<
initializer 'generators.rb', <<-RUBY
Rails.application.config.generators do |g|
end
RUBY
template = {"orm"=>"activerecord", "unit_testing"=>"rspec", "integration_testing"=>"cucumber", "javascript"=>"jquery", "authentication"=>"devise", "templating"=>"haml", "css"=>"sass"}
recipes = template.values.flatten
def say_recipe(name); say "\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
def say_wizard(text); say "\033[36m" + "wizard".rjust(10) + "\033[0m" + " #{text}" end
@after_blocks = []
def after_bundler(&block); @after_blocks << block; end
# >-----------------------------[ ActiveRecord ]------------------------------<
# Use the default ActiveRecord database store.
say_recipe 'ActiveRecord'
# No additional code required.
# >---------------------------------[ RSpec ]---------------------------------<
# Use RSpec for unit testing for this Rails app.
say_recipe 'RSpec'
gem 'rspec-rails', '>= 2.0.1', :group => [:development, :test]
inject_into_file "config/initializers/generators.rb", :after => "Rails.application.config.generators do |g|\n" do
" g.test_framework = :rspec\n"
end
after_bundler do
generate 'rspec:install'
end
# >-------------------------------[ Cucumber ]--------------------------------<
# Use Cucumber for integration testing with Capybara.
say_recipe 'Cucumber'
gem 'cucumber-rails', :group => :test
gem 'capybara', :group => :test
after_bundler do
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}"
end
# >--------------------------------[ jQuery ]---------------------------------<
# Adds the latest jQuery and Rails UJS helpers for jQuery.
say_recipe 'jQuery'
inside "public/javascripts" do
get "http://github.com/rtacconi/rails-template-cucumber/rails.js", "rails.js"
get "http://code.jquery.com/jquery-1.5.min.js", "jquery.js"
end
application do
"\nconfig.action_view.javascript_expansions[:defaults] = %w(jquery rails)\n"
end
gsub_file "config/application.rb", /# JavaScript.*\n/, ""
gsub_file "config/application.rb", /# config\.action_view\.javascript.*\n/, ""
# >--------------------------------[ Devise ]---------------------------------<
# Utilize Devise for authentication, automatically configured for your selected ORM.
say_recipe 'Devise'
gem 'devise'
after_bundler do
generate 'devise:install'
case template['orm']
when 'mongo_mapper'
gem 'mm-devise'
gsub_file 'config/intializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongo_mapper_active_model'
when 'mongoid'
gsub_file 'config/intializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid'
when 'active_record'
# Nothing to do
generate 'devise user'
end
end
# >---------------------------------[ HAML ]----------------------------------<
# Utilize HAML for templating.
say_recipe 'HAML'
gem 'haml', '>= 3.0.0'
gem 'haml-rails'
# >---------------------------------[ SASS ]----------------------------------<
# Utilize SASS (through the HAML gem) for really awesome stylesheets!
say_recipe 'SASS'
unless recipes.include? 'haml'
gem 'haml', '>= 3.0.0'
end
# >-----------------------------[ Run Bundler ]-------------------------------<
say_wizard "Running Bundler install. This will take a while."
run 'bundle install'
say_wizard "Running after Bundler callbacks."
@after_blocks.each{|b| b.call}