Class: Rails::Generators::AppGenerator

Inherits:
AppBase show all
Defined in:
railties/lib/rails/commands/application.rb,
railties/lib/rails/generators/rails/app/app_generator.rb

Overview

:nodoc:

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, #rake, #rakefile, #readme, #route, #vendor

Constructor Details

#initialize(*args) ⇒ AppGenerator

Returns a new instance of AppGenerator.


171
172
173
174
175
176
177
178
179
180
181
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 171

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
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

Returns:

  • (Boolean)

9
10
11
# File 'railties/lib/rails/commands/application.rb', line 9

def self.exit_on_failure?
  true
end

Instance Method Details

#create_active_record_filesObject


215
216
217
218
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 215

def create_active_record_files
  return if options[:skip_active_record]
  build(:database_yml)
end

#create_app_filesObject


194
195
196
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 194

def create_app_files
  build(:app)
end

#create_bin_filesObject


198
199
200
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 198

def create_bin_files
  build(:bin)
end

#create_boot_fileObject


211
212
213
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 211

def create_boot_file
  template "config/boot.rb"
end

#create_config_filesObject


202
203
204
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 202

def create_config_files
  build(:config)
end

#create_db_filesObject


220
221
222
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 220

def create_db_files
  build(:db)
end

#create_lib_filesObject


224
225
226
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 224

def create_lib_files
  build(:lib)
end

#create_log_filesObject


228
229
230
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 228

def create_log_files
  build(:log)
end

#create_public_filesObject


232
233
234
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 232

def create_public_files
  build(:public_directory)
end

#create_root_filesObject


186
187
188
189
190
191
192
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 186

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_filesObject


236
237
238
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 236

def create_test_files
  build(:test) unless options[:skip_test_unit]
end

#create_tmp_filesObject


240
241
242
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 240

def create_tmp_files
  build(:tmp)
end

#create_vendor_filesObject


244
245
246
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 244

def create_vendor_files
  build(:vendor)
end

#delete_assets_initializer_skipping_sprocketsObject


254
255
256
257
258
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 254

def delete_assets_initializer_skipping_sprockets
  if options[:skip_sprockets]
    remove_file 'config/initializers/assets.rb'
  end
end

#delete_js_folder_skipping_javascriptObject


248
249
250
251
252
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 248

def delete_js_folder_skipping_javascript
  if options[:skip_javascript]
    remove_dir 'app/assets/javascripts'
  end
end

#finish_templateObject


260
261
262
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 260

def finish_template
  build(:leftovers)
end

#run_after_bundle_callbacksObject


267
268
269
270
271
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 267

def run_after_bundle_callbacks
  @after_bundle_callbacks.each do |callback|
    callback.call
  end
end

#update_config_filesObject


206
207
208
# File 'railties/lib/rails/generators/rails/app/app_generator.rb', line 206

def update_config_files
  build(:config_when_updating)
end