Class: AppGenerator
- Inherits:
-
Rails::Generator::Base
- Object
- Rails::Generator::Base
- AppGenerator
- Defined in:
- lib/rails_generator/generators/applications/app/app_generator.rb
Constant Summary collapse
- DEFAULT_SHEBANG =
File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
- DATABASES =
%w(mysql oracle postgresql sqlite2 sqlite3 frontbase)
Instance Attribute Summary
Attributes inherited from Rails::Generator::Base
#args, #destination_root, #source_root
Attributes included from Rails::Generator::Options
Instance Method Summary collapse
-
#initialize(runtime_args, runtime_options = {}) ⇒ AppGenerator
constructor
A new instance of AppGenerator.
- #manifest ⇒ Object
Methods inherited from Rails::Generator::Base
#destination_path, #source_path
Methods included from Rails::Generator::Options
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ AppGenerator
Returns a new instance of AppGenerator.
12 13 14 15 16 17 18 |
# File 'lib/rails_generator/generators/applications/app/app_generator.rb', line 12 def initialize(runtime_args, = {}) super usage if args.empty? usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if ([:db] && !DATABASES.include?([:db])) @destination_root = args.shift @app_name = File.basename(File.(@destination_root)) end |
Instance Method Details
#manifest ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rails_generator/generators/applications/app/app_generator.rb', line 20 def manifest # Use /usr/bin/env if no special shebang was specified = { :chmod => 0755, :shebang => [:shebang] == DEFAULT_SHEBANG ? nil : [:shebang] } = { :chmod => 0755, :shebang => [:shebang] } record do |m| # Root directory and all subdirectories. m.directory '' BASEDIRS.each { |path| m.directory path } # Root m.file "README", "README" # Application m.file "helpers/application.rb", "app/adaptors/application.rb" m.file "helpers/test_helper.rb", "test/test_helper.rb" m.file "helpers/publish.rb", "test/mocks/test/publish.rb" # database.yml m.template "configs/databases/#{[:db]}.yml", "config/database.yml", :assigns => { :app_name => @app_name, :socket => [:db] == "mysql" ? mysql_socket_location : nil } # mom.yml m.template "configs/mom.yml", "config/mom.yml" # settings.yml m.template "configs/settings.yml", "config/settings.yml" # boot.rb m.file "configs/boot.rb", "config/boot.rb" # Environments #m.file "environments/boot.rb", "config/boot.rb" #m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] } m.file "environments/environment.rb", "config/environment.rb" #m.file "environments/production.rb", "config/environments/production.rb" m.file "environments/development.rb", "config/environments/development.rb" m.file "environments/test.rb", "config/environments/test.rb" # Scripts %w( generate destroy about publish subscribe console ).each do |file| m.file "bin/#{file}", "script/#{file}", end # Dispatches m.file "dispatches/dispatch.rb", "public/dispatch.rb", # Docs m.file "doc/README_FOR_APP", "doc/README_FOR_APP" # Logs %w(subscriber development test).each { |file| m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666 } # Tests script m.file "helpers/test.rb", "test.rb" end end |