Class: InstanceGenerator
- Inherits:
-
Rails::Generator::Base
- Object
- Rails::Generator::Base
- InstanceGenerator
- Defined in:
- lib/generators-rails2/instance/instance_generator.rb
Constant Summary collapse
- DEFAULT_SHEBANG =
File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
- DATABASES =
%w( mysql postgresql sqlite3 sqlserver db2 )
- MYSQL_SOCKET_LOCATIONS =
[ "/tmp/mysql.sock", # default "/var/run/mysqld/mysqld.sock", # debian/gentoo "/var/tmp/mysql.sock", # freebsd "/var/lib/mysql/mysql.sock", # fedora "/opt/local/lib/mysql/mysql.sock", # fedora "/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4 "/opt/local/var/run/mysql5/mysqld.sock" # mac + darwinports + mysql5 ]
Instance Method Summary collapse
-
#initialize(runtime_args, runtime_options = {}) ⇒ InstanceGenerator
constructor
A new instance of InstanceGenerator.
- #manifest ⇒ Object
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ InstanceGenerator
Returns a new instance of InstanceGenerator.
22 23 24 25 26 27 |
# File 'lib/generators-rails2/instance/instance_generator.rb', line 22 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 end |
Instance Method Details
#manifest ⇒ Object
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 82 83 84 85 86 87 88 89 |
# File 'lib/generators-rails2/instance/instance_generator.rb', line 29 def manifest # The absolute location of the Radiant files root = File.(RADIANT_ROOT) # 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 m.directory "" # Standard files and directories base_dirs = %w(config config/environments config/initializers db log script public vendor/plugins vendor/extensions) text_files = %w(CHANGELOG CONTRIBUTORS LICENSE INSTALL README) environments = Dir["#{root}/config/environments/*.rb"] initializers = Dir["#{root}/config/initializers/*.rb"] scripts = Dir["#{root}/script/**/*"].reject { |f| f =~ /(destroy|generate|plugin)$/ } public_files = ["public/.htaccess"] + Dir["#{root}/public/**/*"] files = base_dirs + text_files + environments + initializers + scripts + public_files files.map! { |f| f = $1 if f =~ %r{^#{root}/(.+)$}; f } files.sort! files.each do |file| case when File.directory?("#{root}/#{file}") m.directory file when file =~ %r{^script/} m.file radiant_root(file), file, when file =~ %r{^public/dispatch} m.file radiant_root(file), file, else m.file radiant_root(file), file end end # script/generate m.file "instance_generate", "script/generate", # database.yml and .htaccess m.template "databases/#{[:db]}.yml", "config/database.yml", :assigns => { :app_name => File.basename(File.(@destination_root)), :socket => [:db] == "mysql" ? mysql_socket_location : nil } # Instance Rakefile m.file "instance_rakefile", "Rakefile" # Instance Configurations m.file "instance_routes.rb", "config/routes.rb" m.template "instance_environment.rb", "config/environment.rb", :assigns => { :radiant_environment => File.join(File.dirname(__FILE__), 'templates', radiant_root("config/environment.rb")), :app_name => File.basename(File.(@destination_root)) } m.template "instance_boot.rb", "config/boot.rb" # Install Readme m.readme radiant_root("INSTALL") end end |