Class: Rails::Generators::AppGenerator
- Inherits:
-
Base
- Object
- Thor::Group
- Base
- Rails::Generators::AppGenerator
show all
- Defined in:
- lib/rails/generators/rails/app/app_generator.rb
Constant Summary
collapse
- DATABASES =
%w( mysql oracle postgresql sqlite3 frontbase ibm_db )
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
base_root, class_option, default_source_root, desc, hook_for, inherited, namespace, remove_hook_for, source_root
Methods included from Actions
#add_source, #capify!, #environment, #freeze!, #gem, #generate, #git, #initializer, #lib, #plugin, #rake, #rakefile, #readme, #route, #vendor
Constructor Details
Returns a new instance of AppGenerator.
201
202
203
204
205
206
207
208
209
210
211
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 201
def initialize(*args)
raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank?
@original_wd = Dir.pwd
super
if !options[:skip_active_record] && !DATABASES.include?(options[:database])
raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}."
end
end
|
Instance Attribute Details
#rails_template ⇒ Object
Returns the value of attribute rails_template.
159
160
161
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 159
def rails_template
@rails_template
end
|
Instance Method Details
#apply_rails_template ⇒ Object
299
300
301
302
303
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 299
def apply_rails_template
apply rails_template if rails_template
rescue Thor::Error, LoadError, Errno::ENOENT => e
raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}"
end
|
#bundle_if_dev_or_edge ⇒ Object
305
306
307
308
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 305
def bundle_if_dev_or_edge
bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
run "#{bundle_command} install" if dev_or_edge?
end
|
#create_active_record_files ⇒ Object
242
243
244
245
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 242
def create_active_record_files
return if options[:skip_active_record]
build(:database_yml)
end
|
#create_app_files ⇒ Object
230
231
232
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 230
def create_app_files
build(:app)
end
|
#create_boot_file ⇒ Object
238
239
240
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 238
def create_boot_file
template "config/boot.rb"
end
|
#create_config_files ⇒ Object
234
235
236
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 234
def create_config_files
build(:config)
end
|
#create_db_files ⇒ Object
247
248
249
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 247
def create_db_files
build(:db)
end
|
#create_doc_files ⇒ Object
251
252
253
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 251
def create_doc_files
build(:doc)
end
|
#create_lib_files ⇒ Object
255
256
257
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 255
def create_lib_files
build(:lib)
end
|
#create_log_files ⇒ Object
259
260
261
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 259
def create_log_files
build(:log)
end
|
#create_prototype_files ⇒ Object
275
276
277
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 275
def create_prototype_files
build(:javascripts)
end
|
#create_public_files ⇒ Object
263
264
265
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 263
def create_public_files
build(:public_directory)
end
|
#create_public_image_files ⇒ Object
267
268
269
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 267
def create_public_image_files
build(:images)
end
|
#create_public_stylesheets_files ⇒ Object
271
272
273
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 271
def create_public_stylesheets_files
build(:stylesheets)
end
|
#create_root ⇒ Object
213
214
215
216
217
218
219
220
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 213
def create_root
self.destination_root = File.expand_path(app_path, destination_root)
valid_app_const?
empty_directory '.'
set_default_accessors!
FileUtils.cd(destination_root) unless options[:pretend]
end
|
#create_root_files ⇒ Object
222
223
224
225
226
227
228
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 222
def create_root_files
build(:readme)
build(:rakefile)
build(:configru)
build(:gitignore) unless options[:skip_git]
build(:gemfile) unless options[:skip_gemfile]
end
|
#create_script_files ⇒ Object
279
280
281
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 279
def create_script_files
build(:script)
end
|
#create_test_files ⇒ Object
283
284
285
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 283
def create_test_files
build(:test) unless options[:skip_test_unit]
end
|
#create_tmp_files ⇒ Object
287
288
289
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 287
def create_tmp_files
build(:tmp)
end
|
#create_vendor_files ⇒ Object
291
292
293
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 291
def create_vendor_files
build(:vendor_plugins)
end
|
#finish_template ⇒ Object
295
296
297
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 295
def finish_template
build(:leftovers)
end
|