Class: Firestarter::AppBuilder
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- Firestarter::AppBuilder
show all
- Includes:
- Actions
- Defined in:
- lib/firestarter/app_builder.rb
Instance Method Summary
collapse
Methods included from Actions
#action_mailer_host, #configure_environment, #download_file, #replace_in_file
Instance Method Details
201
202
203
204
205
206
|
# File 'lib/firestarter/app_builder.rb', line 201
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
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/firestarter/app_builder.rb', line 42
def configure_generators
config = <<-RUBY
config.generators do |generate|
generate.helper false
generate.javascript_engine false
generate.request_specs false
generate.routing_specs false
generate.stylesheets false
generate.test_framework :rspec
generate.view_specs false
end
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
|
176
177
178
|
# File 'lib/firestarter/app_builder.rb', line 176
def configure_i18n_in_specs
copy_file 'i18n.rb', 'spec/support/i18n.rb'
end
|
220
221
222
|
# File 'lib/firestarter/app_builder.rb', line 220
def configure_puma
copy_file 'puma.rb', 'config/puma.rb'
end
|
193
194
195
|
# File 'lib/firestarter/app_builder.rb', line 193
def configure_rack_timeout
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
end
|
171
172
173
174
|
# File 'lib/firestarter/app_builder.rb', line 171
def configure_rspec
remove_file 'spec/spec_helper.rb'
copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
end
|
197
198
199
|
# File 'lib/firestarter/app_builder.rb', line 197
def configure_slim
copy_file 'slim.rb', 'config/initializers/slim.rb'
end
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/firestarter/app_builder.rb', line 68
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
|
166
167
168
169
|
# File 'lib/firestarter/app_builder.rb', line 166
def configure_spec_support_features
empty_directory_with_keep_file 'spec/features'
empty_directory_with_keep_file 'spec/support/features'
end
|
188
189
190
191
|
# File 'lib/firestarter/app_builder.rb', line 188
def configure_time_formats
remove_file 'config/locales/en.yml'
copy_file 'config_locales_en.yml', 'config/locales/en.yml'
end
|
180
181
182
183
184
185
186
|
# File 'lib/firestarter/app_builder.rb', line 180
def configure_time_zone
config = <<-RUBY
config.active_record.default_timezone = :utc
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
|
#copy_miscellaneous_files ⇒ Object
256
257
258
|
# File 'lib/firestarter/app_builder.rb', line 256
def copy_miscellaneous_files
copy_file 'errors.rb', 'config/initializers/errors.rb'
end
|
#create_application_layout ⇒ Object
127
128
129
130
131
132
|
# File 'lib/firestarter/app_builder.rb', line 127
def create_application_layout
remove_file 'app/views/layouts/application.html.erb'
template 'firestarter_layout.slim.erb',
'app/views/layouts/application.slim',
force: true
end
|
#create_database ⇒ Object
145
146
147
|
# File 'lib/firestarter/app_builder.rb', line 145
def create_database
bundle_command 'exec rake db:create db:migrate'
end
|
#create_partials_directory ⇒ Object
115
116
117
|
# File 'lib/firestarter/app_builder.rb', line 115
def create_partials_directory
empty_directory 'app/views/application'
end
|
#create_shared_flashes ⇒ Object
119
120
121
|
# File 'lib/firestarter/app_builder.rb', line 119
def create_shared_flashes
copy_file '_flashes.slim', 'app/views/application/_flashes.slim'
end
|
#create_shared_javascripts ⇒ Object
123
124
125
|
# File 'lib/firestarter/app_builder.rb', line 123
def create_shared_javascripts
copy_file '_javascript.slim', 'app/views/application/_javascript.slim'
end
|
#customize_error_pages ⇒ Object
260
261
262
263
264
265
266
267
268
269
270
|
# File 'lib/firestarter/app_builder.rb', line 260
def customize_error_pages
meta_tags =<<-EOS
<meta charset='utf-8' />
<meta name='ROBOTS' content='NOODP' />
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", /<!--.+-->\n/, ''
end
end
|
#disable_xml_params ⇒ Object
278
279
280
|
# File 'lib/firestarter/app_builder.rb', line 278
def disable_xml_params
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
end
|
#enable_database_cleaner ⇒ Object
162
163
164
|
# File 'lib/firestarter/app_builder.rb', line 162
def enable_database_cleaner
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
end
|
#enable_factory_girl_syntax ⇒ Object
59
60
61
|
# File 'lib/firestarter/app_builder.rb', line 59
def enable_factory_girl_syntax
copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
end
|
#enable_rack_deflater ⇒ Object
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/firestarter/app_builder.rb', line 84
def enable_rack_deflater
config = <<-RUBY
# Enable deflate / gzip compression of controller-generated responses
config.middleware.use Rack::Deflater
RUBY
inject_into_file 'config/environments/production.rb', config,
:after => "config.serve_static_assets = false\n"
end
|
#enable_unobtrusive_pry_in_specs ⇒ Object
158
159
160
|
# File 'lib/firestarter/app_builder.rb', line 158
def enable_unobtrusive_pry_in_specs
copy_file 'unobtrusive_pry.rb', 'spec/support/pry.rb'
end
|
#fix_i18n_deprecation_warning ⇒ Object
208
209
210
211
212
213
214
|
# File 'lib/firestarter/app_builder.rb', line 208
def fix_i18n_deprecation_warning
config = <<-RUBY
config.i18n.enforce_available_locales = true
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
|
#generate_rspec ⇒ Object
216
217
218
|
# File 'lib/firestarter/app_builder.rb', line 216
def generate_rspec
generate 'rspec:install'
end
|
#gitignore_files ⇒ Object
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/firestarter/app_builder.rb', line 235
def gitignore_files
remove_file '.gitignore'
copy_file 'firestarter_gitignore', '.gitignore'
[
'app/views/pages',
'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
252
253
254
|
# File 'lib/firestarter/app_builder.rb', line 252
def init_git
run 'git init'
end
|
#provide_dev_prime_task ⇒ Object
38
39
40
|
# File 'lib/firestarter/app_builder.rb', line 38
def provide_dev_prime_task
copy_file 'development_seeds.rb', 'lib/tasks/development_seeds.rake'
end
|
#provide_setup_script ⇒ Object
32
33
34
35
36
|
# File 'lib/firestarter/app_builder.rb', line 32
def provide_setup_script
remove_file 'bin/setup'
copy_file 'bin_setup', 'bin/setup'
run 'chmod a+x bin/setup'
end
|
#raise_on_delivery_errors ⇒ Object
13
14
15
16
|
# File 'lib/firestarter/app_builder.rb', line 13
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
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/firestarter/app_builder.rb', line 18
def raise_on_unpermitted_parameters
action_on_unpermitted_parameters = <<-RUBY
# Raise an ActionController::UnpermittedParameters exception when
# a parameter is not explcitly permitted but is passed anyway.
config.action_controller.action_on_unpermitted_parameters = :raise
RUBY
inject_into_file(
"config/environments/development.rb",
action_on_unpermitted_parameters,
before: "\nend"
)
end
|
#rakefile ⇒ Object
9
10
11
|
# File 'lib/firestarter/app_builder.rb', line 9
def rakefile
template 'Rakefile.erb', 'Rakefile'
end
|
#readme ⇒ Object
5
6
7
|
# File 'lib/firestarter/app_builder.rb', line 5
def readme
template 'README.md.erb', 'README.md'
end
|
272
273
274
275
276
|
# File 'lib/firestarter/app_builder.rb', line 272
def
replace_in_file 'config/routes.rb',
/Rails.application\.routes\.draw do.*end/m,
"Rails.application.routes.draw do\nend"
end
|
#remove_turbolinks ⇒ Object
134
135
136
137
138
|
# File 'lib/firestarter/app_builder.rb', line 134
def remove_turbolinks
replace_in_file 'app/assets/javascripts/application.js',
/\/\/= require turbolinks\n/,
''
end
|
#replace_gemfile ⇒ Object
149
150
151
152
|
# File 'lib/firestarter/app_builder.rb', line 149
def replace_gemfile
remove_file 'Gemfile'
template 'Gemfile.erb', 'Gemfile'
end
|
#scss_lint_config ⇒ Object
282
283
284
|
# File 'lib/firestarter/app_builder.rb', line 282
def scss_lint_config
copy_file 'scss-lint.yml', '.scss-lint.yml'
end
|
#set_ruby_to_version_being_used ⇒ Object
154
155
156
|
# File 'lib/firestarter/app_builder.rb', line 154
def set_ruby_to_version_being_used
template 'ruby-version.erb', '.ruby-version'
end
|
#setup_default_rake_task ⇒ Object
286
287
288
289
290
|
# File 'lib/firestarter/app_builder.rb', line 286
def setup_default_rake_task
append_file 'Rakefile' do
"task(:default).clear\ntask :default => [:spec]\n"
end
end
|
#setup_foreman ⇒ Object
224
225
226
227
|
# File 'lib/firestarter/app_builder.rb', line 224
def setup_foreman
copy_file 'sample.env', '.sample.env'
copy_file 'Procfile', 'Procfile'
end
|
#setup_secret_token ⇒ Object
109
110
111
112
113
|
# File 'lib/firestarter/app_builder.rb', line 109
def setup_secret_token
template 'secret_token.rb',
'config/initializers/secret_token.rb',
:force => true
end
|
#setup_staging_environment ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/firestarter/app_builder.rb', line 95
def setup_staging_environment
staging_file = 'config/environments/staging.rb'
copy_file 'staging.rb', staging_file
config = <<-RUBY
#{app_name.classify}::Application.configure do
# ...
end
RUBY
append_file staging_file, config
end
|
#setup_stylesheets ⇒ Object
229
230
231
232
233
|
# File 'lib/firestarter/app_builder.rb', line 229
def setup_stylesheets
remove_file 'app/assets/stylesheets/application.css'
copy_file 'application.sass',
'app/assets/stylesheets/application.sass'
end
|
#test_factories_first ⇒ Object
63
64
65
66
|
# File 'lib/firestarter/app_builder.rb', line 63
def test_factories_first
copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
append_file 'Rakefile', factories_spec_rake_task
end
|
#use_postgres_config_template ⇒ Object
140
141
142
143
|
# File 'lib/firestarter/app_builder.rb', line 140
def use_postgres_config_template
template 'postgresql_database.yml.erb', 'config/database.yml',
force: true
end
|