Class: Rails::Generators::AppGenerator
- Inherits:
-
AppBase
- Object
- Thor::Group
- Base
- AppBase
- Rails::Generators::AppGenerator
show all
- Defined in:
- lib/rails/commands/application.rb,
lib/rails/generators/rails/app/app_generator.rb
Overview
Constant Summary
Constants inherited
from AppBase
Rails::Generators::AppBase::DATABASES, Rails::Generators::AppBase::JDBC_DATABASES
Instance Attribute Summary
Attributes inherited from AppBase
#rails_template
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from AppBase
add_shared_options_for, strict_args_position
Methods inherited from Base
base_root, class_option, default_source_root, desc, hide!, hook_for, inherited, namespace, remove_hook_for, source_root
Methods included from Actions
#add_source, #after_bundle, #capify!, #environment, #gem, #gem_group, #generate, #git, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor
Constructor Details
Returns a new instance of AppGenerator.
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 185
def initialize(*args)
super
unless app_path
raise Error, "Application name should be provided in arguments. For details run: rails --help"
end
if !options[:skip_active_record] && !DATABASES.include?(options[:database])
raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}."
end
self.options = options.merge(skip_sprockets: true, skip_javascript: true).freeze if options[:api]
end
|
Class Method Details
.exit_on_failure? ⇒ Boolean
We want to exit on failure to be kind to other libraries This is only when accessing via CLI
9
10
11
|
# File 'lib/rails/commands/application.rb', line 9
def self.exit_on_failure?
true
end
|
Instance Method Details
#create_active_record_files ⇒ Object
233
234
235
236
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 233
def create_active_record_files
return if options[:skip_active_record]
build(:database_yml)
end
|
#create_app_files ⇒ Object
212
213
214
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 212
def create_app_files
build(:app)
end
|
#create_bin_files ⇒ Object
216
217
218
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 216
def create_bin_files
build(:bin)
end
|
#create_boot_file ⇒ Object
229
230
231
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 229
def create_boot_file
template "config/boot.rb"
end
|
#create_config_files ⇒ Object
220
221
222
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 220
def create_config_files
build(:config)
end
|
#create_db_files ⇒ Object
238
239
240
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 238
def create_db_files
build(:db)
end
|
#create_lib_files ⇒ Object
242
243
244
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 242
def create_lib_files
build(:lib)
end
|
#create_log_files ⇒ Object
246
247
248
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 246
def create_log_files
build(:log)
end
|
#create_public_files ⇒ Object
250
251
252
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 250
def create_public_files
build(:public_directory)
end
|
#create_root_files ⇒ Object
204
205
206
207
208
209
210
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 204
def create_root_files
build(:readme)
build(:rakefile)
build(:configru)
build(:gitignore) unless options[:skip_git]
build(:gemfile) unless options[:skip_gemfile]
end
|
#create_test_files ⇒ Object
254
255
256
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 254
def create_test_files
build(:test) unless options[:skip_test]
end
|
#create_tmp_files ⇒ Object
258
259
260
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 258
def create_tmp_files
build(:tmp)
end
|
#create_vendor_files ⇒ Object
262
263
264
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 262
def create_vendor_files
build(:vendor)
end
|
#delete_action_cable_files_skipping_action_cable ⇒ Object
325
326
327
328
329
330
331
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 325
def delete_action_cable_files_skipping_action_cable
if options[:skip_action_cable]
remove_file 'config/cable.yml'
remove_file 'app/assets/javascripts/cable.js'
remove_dir 'app/channels'
end
end
|
#delete_action_mailer_files_skipping_action_mailer ⇒ Object
317
318
319
320
321
322
323
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 317
def delete_action_mailer_files_skipping_action_mailer
if options[:skip_action_mailer]
remove_file 'app/mailers/application_mailer.rb'
remove_file 'app/views/layouts/mailer.html.erb'
remove_file 'app/views/layouts/mailer.text.erb'
end
end
|
#delete_api_initializers ⇒ Object
340
341
342
343
344
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 340
def delete_api_initializers
unless options[:api]
remove_file 'config/initializers/cors.rb'
end
end
|
#delete_app_assets_if_api_option ⇒ Object
266
267
268
269
270
271
272
273
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 266
def delete_app_assets_if_api_option
if options[:api]
remove_dir 'app/assets'
remove_dir 'lib/assets'
remove_dir 'tmp/cache/assets'
remove_dir 'vendor/assets'
end
end
|
#delete_app_helpers_if_api_option ⇒ Object
275
276
277
278
279
280
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 275
def delete_app_helpers_if_api_option
if options[:api]
remove_dir 'app/helpers'
remove_dir 'test/helpers'
end
end
|
#delete_application_layout_file_if_api_option ⇒ Object
282
283
284
285
286
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 282
def delete_application_layout_file_if_api_option
if options[:api]
remove_file 'app/views/layouts/application.html.erb'
end
end
|
#delete_application_record_skipping_active_record ⇒ Object
311
312
313
314
315
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 311
def delete_application_record_skipping_active_record
if options[:skip_active_record]
remove_file 'app/models/application_record.rb'
end
end
|
#delete_assets_initializer_skipping_sprockets ⇒ Object
305
306
307
308
309
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 305
def delete_assets_initializer_skipping_sprockets
if options[:skip_sprockets]
remove_file 'config/initializers/assets.rb'
end
end
|
#delete_js_folder_skipping_javascript ⇒ Object
299
300
301
302
303
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 299
def delete_js_folder_skipping_javascript
if options[:skip_javascript]
remove_dir 'app/assets/javascripts'
end
end
|
#delete_non_api_initializers_if_api_option ⇒ Object
333
334
335
336
337
338
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 333
def delete_non_api_initializers_if_api_option
if options[:api]
remove_file 'config/initializers/session_store.rb'
remove_file 'config/initializers/cookies_serializer.rb'
end
end
|
#delete_public_files_if_api_option ⇒ Object
288
289
290
291
292
293
294
295
296
297
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 288
def delete_public_files_if_api_option
if options[:api]
remove_file 'public/404.html'
remove_file 'public/422.html'
remove_file 'public/500.html'
remove_file 'public/apple-touch-icon-precomposed.png'
remove_file 'public/apple-touch-icon.png'
remove_file 'public/favicon.ico'
end
end
|
#finish_template ⇒ Object
346
347
348
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 346
def finish_template
build(:leftovers)
end
|
#run_after_bundle_callbacks ⇒ Object
353
354
355
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 353
def run_after_bundle_callbacks
@after_bundle_callbacks.each(&:call)
end
|
#update_config_files ⇒ Object
224
225
226
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 224
def update_config_files
build(:config_when_updating)
end
|