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 )
- JDBC_DATABASES =
%w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
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.
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 203
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
convert_database_option_for_jruby
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.
161
162
163
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 161
def rails_template
@rails_template
end
|
Instance Method Details
#apply_rails_template ⇒ Object
302
303
304
305
306
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 302
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
308
309
310
311
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 308
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
245
246
247
248
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 245
def create_active_record_files
return if options[:skip_active_record]
build(:database_yml)
end
|
#create_app_files ⇒ Object
233
234
235
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 233
def create_app_files
build(:app)
end
|
#create_boot_file ⇒ Object
241
242
243
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 241
def create_boot_file
template "config/boot.rb"
end
|
#create_config_files ⇒ Object
237
238
239
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 237
def create_config_files
build(:config)
end
|
#create_db_files ⇒ Object
250
251
252
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 250
def create_db_files
build(:db)
end
|
#create_doc_files ⇒ Object
254
255
256
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 254
def create_doc_files
build(:doc)
end
|
#create_lib_files ⇒ Object
258
259
260
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 258
def create_lib_files
build(:lib)
end
|
#create_log_files ⇒ Object
262
263
264
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 262
def create_log_files
build(:log)
end
|
#create_prototype_files ⇒ Object
278
279
280
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 278
def create_prototype_files
build(:javascripts)
end
|
#create_public_files ⇒ Object
266
267
268
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 266
def create_public_files
build(:public_directory)
end
|
#create_public_image_files ⇒ Object
270
271
272
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 270
def create_public_image_files
build(:images)
end
|
#create_public_stylesheets_files ⇒ Object
274
275
276
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 274
def create_public_stylesheets_files
build(:stylesheets)
end
|
#create_root ⇒ Object
216
217
218
219
220
221
222
223
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 216
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
225
226
227
228
229
230
231
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 225
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
282
283
284
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 282
def create_script_files
build(:script)
end
|
#create_test_files ⇒ Object
286
287
288
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 286
def create_test_files
build(:test) unless options[:skip_test_unit]
end
|
#create_tmp_files ⇒ Object
290
291
292
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 290
def create_tmp_files
build(:tmp)
end
|
#create_vendor_files ⇒ Object
294
295
296
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 294
def create_vendor_files
build(:vendor_plugins)
end
|
#finish_template ⇒ Object
298
299
300
|
# File 'lib/rails/generators/rails/app/app_generator.rb', line 298
def finish_template
build(:leftovers)
end
|