Skip to content
Newer
Older
100644 137 lines (115 sloc) 4.6 KB
b1999be @dhh A hopefully more successful attempt at the Routing branch merge
dhh authored
1 require 'rbconfig'
2
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
3 class AppGenerator < Rails::Generator::Base
4 DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
5 Config::CONFIG['ruby_install_name'])
9601f96 @NZKoz attempt to fix #2500
NZKoz authored
6
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
7 default_options :gem => true, :shebang => DEFAULT_SHEBANG
b1999be @dhh A hopefully more successful attempt at the Routing branch merge
dhh authored
8 mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
9
10 def initialize(runtime_args, runtime_options = {})
11 super
12 usage if args.empty?
13 @destination_root = args.shift
9601f96 @NZKoz attempt to fix #2500
NZKoz authored
14 @socket = MYSQL_SOCKET_LOCATIONS.find {|f| File.exists?(f) }
6273753 @jeremy Try to figure out which mysql socket to use. Default to /path/to/your…
jeremy authored
15 @socket = '/path/to/your/mysql.sock' if @socket.blank?
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
16 end
17
18 def manifest
19 script_options = { :chmod => 0755, :shebang => options[:shebang] }
20
21 record do |m|
22 # Root directory and all subdirectories.
23 m.directory ''
24 BASEDIRS.each { |path| m.directory path }
25
26 # Root
27 m.file "fresh_rakefile", "Rakefile"
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored
28 m.file "README", "README"
29 m.file "CHANGELOG", "CHANGELOG"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
30
31 # Application
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored
32 m.template "helpers/application.rb", "app/controllers/application.rb"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
33 m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored
34 m.template "helpers/test_helper.rb", "test/test_helper.rb"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
35
36 # database.yml and .htaccess
6273753 @jeremy Try to figure out which mysql socket to use. Default to /path/to/your…
jeremy authored
37 m.template "configs/database.yml", "config/database.yml", :assigns => {
38 :app_name => File.basename(File.expand_path(@destination_root)),
39 :socket => @socket
40 }
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored
41 m.template "configs/routes.rb", "config/routes.rb"
42 m.template "configs/apache.conf", "public/.htaccess"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
43
44 # Environments
bc011df @dhh Moved all the shared tasks from Rakefile into Rails, so that the Rake…
dhh authored
45 m.file "environments/boot.rb", "config/boot.rb"
20e3cfe @dhh Combined the script/environment.rb used for gems and regular files ve…
dhh authored
46 m.file "environments/environment.rb", "config/environment.rb"
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored
47 m.file "environments/production.rb", "config/environments/production.rb"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
48 m.file "environments/development.rb", "config/environments/development.rb"
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored
49 m.file "environments/test.rb", "config/environments/test.rb"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
50
d75481c @dhh Added convenience controls for FCGI processes (especially when manage…
dhh authored
51 # Scripts
8ad552a @dhh Moving perform to performance
dhh authored
52 %w( breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server ).each do |file|
a9f34ea @dhh Backed out of script/run portal idea. Muscle memory too deep
dhh authored
53 m.file "bin/#{file}", "script/#{file}", script_options
54 end
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
55
56 # Dispatches
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored
57 m.file "dispatches/dispatch.rb", "public/dispatch.rb", script_options
58 m.file "dispatches/dispatch.rb", "public/dispatch.cgi", script_options
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
59 m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", script_options
60
61 # HTML files
62 %w(404 500 index).each do |file|
63 m.template "html/#{file}.html", "public/#{file}.html"
64 end
10be1c5 @dhh Added an empty favicon.ico file to the public directory of new applic…
dhh authored
65
66 m.template "html/favicon.ico", "public/favicon.ico"
7d6f783 @dhh Added an empty robots.txt to public/, so that web servers asking for …
dhh authored
67 m.template "html/robots.txt", "public/robots.txt"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
68
ecc0e28 @dhh Add prototype.js to new apps in javascripts/ #885
dhh authored
69 # Javascripts
7d101d5 @madrobby Update Prototype to V1.4.0_pre11, script.aculo.us to [2502] and fix t…
madrobby authored
70 m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
71 m.file "html/javascripts/scriptaculous.js", "public/javascripts/scriptaculous.js"
72 m.file "html/javascripts/effects.js", "public/javascripts/effects.js"
73 m.file "html/javascripts/dragdrop.js", "public/javascripts/dragdrop.js"
74 m.file "html/javascripts/controls.js", "public/javascripts/controls.js"
75 m.file "html/javascripts/slider.js", "public/javascripts/slider.js"
ecc0e28 @dhh Add prototype.js to new apps in javascripts/ #885
dhh authored
76
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
77 # Docs
78 m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
79
80 # Logs
8245588 @dhh Added lighttpd config example and changed apache.log to less discrimi…
dhh authored
81 %w(server production development test).each { |file|
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
82 m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666
83 }
84 end
85 end
86
87 protected
88 def banner
89 "Usage: #{$0} /path/to/your/app [options]"
90 end
91
92 def add_options!(opt)
93 opt.separator ''
94 opt.separator 'Options:'
95 opt.on("--ruby [#{DEFAULT_SHEBANG}]",
96 "Path to the Ruby binary of your choice.") { |options[:shebang]| }
97 opt.on("--without-gems",
98 "Don't use the Rails gems for your app.",
99 "WARNING: see note below.") { |options[:gem]| }
100 end
101
102
103 # Installation skeleton. Intermediate directories are automatically
104 # created so don't sweat their absence here.
105 BASEDIRS = %w(
bc8e412 @dhh Integrated Action Service with the existing elements
dhh authored
106 app/apis
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
107 app/controllers
108 app/helpers
109 app/models
110 app/views/layouts
111 config/environments
69d0f50 @dhh Added support for independent components residing in /components
dhh authored
112 components
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
113 db
114 doc
115 lib
e2ba206 @dhh Moved config/tasks to lib/tasks and added more documentation to envir…
dhh authored
116 lib/tasks
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
117 log
118 public/images
119 public/javascripts
120 public/stylesheets
08917a6 @dhh Fixed script/performance
dhh authored
121 script/performance
0065697 @jeremy r3619@sedna: jeremy | 2005-10-14 14:41:24 -0700
jeremy authored
122 script/process
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
123 test/fixtures
124 test/functional
125 test/mocks/development
38ea84a @dhh Fixed test/mocks/testing to the correct test/mocks/test #740
dhh authored
126 test/mocks/test
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
127 test/unit
128 vendor
a9f34ea @dhh Backed out of script/run portal idea. Muscle memory too deep
dhh authored
129 vendor/plugins
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
130 )
9601f96 @NZKoz attempt to fix #2500
NZKoz authored
131
132 MYSQL_SOCKET_LOCATIONS = [ "/tmp/mysql.sock", #default
133 "/var/run/mysqld/mysqld.sock", #debian
134 "/var/tmp/mysql.sock", # freebsd
135 "/var/lib/mysql/mysql.sock" ] #fedora
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored
136 end
Something went wrong with that request. Please try again.