Class: RailsloveSuspenders::AppBuilder
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- RailsloveSuspenders::AppBuilder
show all
- Includes:
- Actions
- Defined in:
- lib/railslove-suspenders/app_builder.rb
Instance Method Summary
collapse
Methods included from Actions
#action_mailer_host, #concat_file, #configure_environment, #download_file, #replace_in_file
Instance Method Details
#add_default_stylesheets ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/railslove-suspenders/app_builder.rb', line 71
def add_default_stylesheets
copy_file 'stylesheets/application.css.sass', 'app/assets/stylesheets/application.css.sass'
copy_file 'stylesheets/_shame.css.sass', 'app/assets/stylesheets/_shame.css.sass'
copy_file 'stylesheets/base/_colors.css.sass', 'app/assets/stylesheets/base/_colors.css.sass'
copy_file 'stylesheets/base/_dimension.css.sass', 'app/assets/stylesheets/base/_dimensions.css.sass'
copy_file 'stylesheets/base/_element_defaults.css.sass', 'app/assets/stylesheets/base/_element_defaults.css.sass'
copy_file 'stylesheets/base/_icon_font.css.sass', 'app/assets/stylesheets/base/_icon_font.css.sass'
copy_file 'stylesheets/base/_sprites.css.sass', 'app/assets/stylesheets/base/_sprites.css.sass'
copy_file 'stylesheets/base/_typography.css.sass', 'app/assets/stylesheets/base/_typography.css.sass'
copy_file 'stylesheets/base/_global_mixins.css.sass', 'app/assets/stylesheets/base/_global_mixins.css.sass'
end
|
183
184
185
186
187
188
|
# File 'lib/railslove-suspenders/app_builder.rb', line 183
def configure_action_mailer
action_mailer_host 'development', "#{app_name}.local"
action_mailer_host 'test', 'www.example.com'
action_mailer_host 'staging', "staging.#{app_name}.com"
action_mailer_host 'production', "#{app_name}.com"
end
|
161
162
163
164
|
# File 'lib/railslove-suspenders/app_builder.rb', line 161
def configure_background_jobs_for_rspec
copy_file 'background_jobs_rspec.rb', 'spec/support/background_jobs.rb'
run 'rails g delayed_job:active_record'
end
|
194
195
196
197
198
|
# File 'lib/railslove-suspenders/app_builder.rb', line 194
def configure_capybara_webkit
append_file 'spec/spec_helper.rb' do
"\nCapybara.javascript_driver = :webkit\n"
end
end
|
179
180
181
|
# File 'lib/railslove-suspenders/app_builder.rb', line 179
def configure_rack_timeout
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
end
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/railslove-suspenders/app_builder.rb', line 134
def configure_rspec
remove_file '.rspec'
copy_file 'rspec', '.rspec'
rspec_expect_syntax = <<-RUBY
config.expect_with :rspec do |c|
c.syntax = :expect
end
RUBY
config = <<-RUBY
config.generators do |generate|
generate.test_framework :rspec
generate.helper false
generate.stylesheets false
generate.javascript_engine false
generate.view_specs false
end
RUBY
inject_into_file 'spec/spec_helper.rb', rspec_expect_syntax,
:after => 'RSpec.configure do |config|'
inject_into_class 'config/application.rb', 'Application', config
end
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/railslove-suspenders/app_builder.rb', line 41
def configure_smtp
copy_file 'smtp.rb', 'config/initializers/smtp.rb'
prepend_file 'config/environments/production.rb',
"require Rails.root.join('config/initializers/smtp')\n"
config = <<-RUBY
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = SMTP_SETTINGS
RUBY
inject_into_file 'config/environments/production.rb', config,
:after => 'config.action_mailer.raise_delivery_errors = false'
end
|
174
175
176
177
|
# File 'lib/railslove-suspenders/app_builder.rb', line 174
def configure_time_formats
remove_file 'config/locales/en.yml'
copy_file 'config_locales_en.yml', 'config/locales/en.yml'
end
|
166
167
168
169
170
171
172
|
# File 'lib/railslove-suspenders/app_builder.rb', line 166
def configure_time_zone
config = <<-RUBY
config.active_record.default_timezone = :utc
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
|
204
205
206
|
# File 'lib/railslove-suspenders/app_builder.rb', line 204
def configure_unicorn
copy_file 'unicorn.rb', 'config/unicorn.rb'
end
|
#copy_miscellaneous_files ⇒ Object
250
251
252
|
# File 'lib/railslove-suspenders/app_builder.rb', line 250
def copy_miscellaneous_files
copy_file 'errors.rb', 'config/initializers/errors.rb'
end
|
#create_application_layout ⇒ Object
92
93
94
95
96
97
|
# File 'lib/railslove-suspenders/app_builder.rb', line 92
def create_application_layout
remove_file 'app/views/layouts/application.html.erb'
template 'suspenders_layout.html.haml',
'app/views/layouts/application.html.haml',
:force => true
end
|
#create_common_javascripts ⇒ Object
99
100
101
|
# File 'lib/railslove-suspenders/app_builder.rb', line 99
def create_common_javascripts
directory 'javascripts', 'app/assets/javascripts'
end
|
#create_database ⇒ Object
108
109
110
|
# File 'lib/railslove-suspenders/app_builder.rb', line 108
def create_database
bundle_command 'exec rake db:create'
end
|
#create_github_repo(repo_name) ⇒ Object
245
246
247
248
|
# File 'lib/railslove-suspenders/app_builder.rb', line 245
def create_github_repo(repo_name)
path_addition = override_path_for_tests
run "#{path_addition} hub create #{repo_name}"
end
|
#create_heroku_apps ⇒ Object
238
239
240
241
242
243
|
# File 'lib/railslove-suspenders/app_builder.rb', line 238
def create_heroku_apps
path_addition = override_path_for_tests
run "#{path_addition} heroku create #{app_name}-production --remote=production"
run "#{path_addition} heroku create #{app_name}-staging --remote=staging"
run "#{path_addition} heroku config:add RACK_ENV=staging RAILS_ENV=staging --remote=staging"
end
|
#create_partials_directory ⇒ Object
64
65
66
67
68
69
|
# File 'lib/railslove-suspenders/app_builder.rb', line 64
def create_partials_directory
empty_directory 'app/assets/stylesheets/base'
empty_directory 'app/assets/stylesheets/modules'
empty_directory 'app/assets/stylesheets/layout'
empty_directory 'app/assets/stylesheets/controllers'
end
|
#create_shared_flashes ⇒ Object
84
85
86
|
# File 'lib/railslove-suspenders/app_builder.rb', line 84
def create_shared_flashes
copy_file '_flashes.html.haml', 'app/views/layouts/_flashes.html.haml'
end
|
#create_shared_javascripts ⇒ Object
88
89
90
|
# File 'lib/railslove-suspenders/app_builder.rb', line 88
def create_shared_javascripts
copy_file '_javascript.html.haml', 'app/views/layouts/_javascript.html.haml'
end
|
#customize_error_pages ⇒ Object
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/railslove-suspenders/app_builder.rb', line 254
def customize_error_pages
meta_tags =<<-EOS
<meta charset='utf-8' />
<meta name='ROBOTS' content='NOODP' />
EOS
style_tags =<<-EOS
<link href='/assets/application.css' media='all' rel='stylesheet' type='text/css' />
EOS
%w(500 404 422).each do |page|
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
replace_in_file "public/#{page}.html", /<style.+>.+<\/style>/mi, style_tags.strip
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
end
end
|
#disable_xml_params ⇒ Object
276
277
278
|
# File 'lib/railslove-suspenders/app_builder.rb', line 276
def disable_xml_params
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
end
|
#enable_database_cleaner ⇒ Object
122
123
124
125
126
127
128
|
# File 'lib/railslove-suspenders/app_builder.rb', line 122
def enable_database_cleaner
replace_in_file 'spec/spec_helper.rb',
'config.use_transactional_fixtures = true',
'config.use_transactional_fixtures = false'
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
end
|
#enable_factory_girl_syntax ⇒ Object
32
33
34
|
# File 'lib/railslove-suspenders/app_builder.rb', line 32
def enable_factory_girl_syntax
copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
end
|
#enable_strong_parameter_matcher ⇒ Object
130
131
132
|
# File 'lib/railslove-suspenders/app_builder.rb', line 130
def enable_strong_parameter_matcher
copy_file 'strong_parameter_matcher.rb', 'spec/support/matchers/strong_parameter_matcher.rb'
end
|
#generate_clearance ⇒ Object
200
201
202
|
# File 'lib/railslove-suspenders/app_builder.rb', line 200
def generate_clearance
generate 'clearance:install'
end
|
#generate_rspec ⇒ Object
190
191
192
|
# File 'lib/railslove-suspenders/app_builder.rb', line 190
def generate_rspec
generate 'rspec:install'
end
|
#gitignore_files ⇒ Object
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# File 'lib/railslove-suspenders/app_builder.rb', line 219
def gitignore_files
concat_file 'suspenders_gitignore', '.gitignore'
[
'spec/lib',
'spec/controllers',
'spec/helpers',
'spec/support/matchers',
'spec/support/mixins',
'spec/support/shared_examples'
].each do |dir|
run "mkdir #{dir}"
run "touch #{dir}/.keep"
end
end
|
#init_git ⇒ Object
234
235
236
|
# File 'lib/railslove-suspenders/app_builder.rb', line 234
def init_git
run 'git init'
end
|
#provide_setup_script ⇒ Object
27
28
29
30
|
# File 'lib/railslove-suspenders/app_builder.rb', line 27
def provide_setup_script
copy_file 'bin_setup', 'bin/setup'
run 'chmod a+x bin/setup'
end
|
#raise_on_delivery_errors ⇒ Object
17
18
19
20
|
# File 'lib/railslove-suspenders/app_builder.rb', line 17
def raise_on_delivery_errors
replace_in_file 'config/environments/development.rb',
'raise_delivery_errors = false', 'raise_delivery_errors = true'
end
|
#raise_on_unpermitted_parameters ⇒ Object
22
23
24
25
|
# File 'lib/railslove-suspenders/app_builder.rb', line 22
def raise_on_unpermitted_parameters
configure_environment 'development',
'config.action_controller.action_on_unpermitted_parameters = :raise'
end
|
#readme ⇒ Object
5
6
7
|
# File 'lib/railslove-suspenders/app_builder.rb', line 5
def readme
template 'README.md.erb', 'README.md'
end
|
#remove_public_index ⇒ Object
9
10
11
|
# File 'lib/railslove-suspenders/app_builder.rb', line 9
def remove_public_index
remove_file 'public/index.html'
end
|
#remove_rails_logo_image ⇒ Object
13
14
15
|
# File 'lib/railslove-suspenders/app_builder.rb', line 13
def remove_rails_logo_image
remove_file 'app/assets/images/rails.png'
end
|
270
271
272
273
274
|
# File 'lib/railslove-suspenders/app_builder.rb', line 270
def
replace_in_file 'config/routes.rb',
/Application\.routes\.draw do.*end/m,
"Application.routes.draw do\nend"
end
|
#replace_gemfile ⇒ Object
112
113
114
115
|
# File 'lib/railslove-suspenders/app_builder.rb', line 112
def replace_gemfile
remove_file 'Gemfile'
copy_file 'Gemfile_clean', 'Gemfile'
end
|
#set_ruby_to_version_being_used ⇒ Object
117
118
119
120
|
# File 'lib/railslove-suspenders/app_builder.rb', line 117
def set_ruby_to_version_being_used
inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
after: /source 'https:\/\/rubygems.org'/
end
|
#setup_default_rake_task ⇒ Object
280
281
282
283
284
|
# File 'lib/railslove-suspenders/app_builder.rb', line 280
def setup_default_rake_task
append_file 'Rakefile' do
"task(:default).clear\ntask :default => [:spec]\n"
end
end
|
#setup_foreman ⇒ Object
208
209
210
211
|
# File 'lib/railslove-suspenders/app_builder.rb', line 208
def setup_foreman
copy_file 'sample.env', '.sample.env'
copy_file 'Procfile', 'Procfile'
end
|
#setup_staging_environment ⇒ Object
57
58
59
60
61
62
|
# File 'lib/railslove-suspenders/app_builder.rb', line 57
def setup_staging_environment
run 'cp config/environments/production.rb config/environments/staging.rb'
end
|
#setup_stylesheets ⇒ Object
213
214
215
216
217
|
# File 'lib/railslove-suspenders/app_builder.rb', line 213
def setup_stylesheets
remove_file 'app/assets/stylesheets/application.css'
end
|
#test_factories_first ⇒ Object
36
37
38
39
|
# File 'lib/railslove-suspenders/app_builder.rb', line 36
def test_factories_first
copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
end
|
#use_postgres_config_template ⇒ Object
103
104
105
106
|
# File 'lib/railslove-suspenders/app_builder.rb', line 103
def use_postgres_config_template
template 'postgresql_database.yml.erb', 'config/database.yml',
:force => true
end
|