Skip to content
Newer
Older
100644 185 lines (155 sloc) 6.83 KB
b1999be @dhh A hopefully more successful attempt at the Routing branch merge
dhh authored Feb 15, 2005
1 require 'rbconfig'
ad9bacb @technoweenie fix app generator
technoweenie authored Feb 24, 2007
2 require 'digest/md5'
b1999be @dhh A hopefully more successful attempt at the Routing branch merge
dhh authored Feb 15, 2005
3
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
4 class AppGenerator < Rails::Generator::Base
5 DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
6 Config::CONFIG['ruby_install_name'])
0d33934 @jeremy rails -d frontbase to create a new project with a frontbase database.…
jeremy authored Jul 8, 2006
7
f0e9074 @acangiano Add IMB DB support to Rails application generator. [#1136 state:resol…
acangiano authored Oct 3, 2008
8 DATABASES = %w(mysql oracle postgresql sqlite2 sqlite3 frontbase ibm_db)
2556e67 @jeremy App generate says sqlite3 is the default and mentions frontbase. Closes
jeremy authored Dec 21, 2007
9 DEFAULT_DATABASE = 'sqlite3'
0d33934 @jeremy rails -d frontbase to create a new project with a frontbase database.…
jeremy authored Jul 8, 2006
10
2556e67 @jeremy App generate says sqlite3 is the default and mentions frontbase. Closes
jeremy authored Dec 21, 2007
11 default_options :db => (ENV["RAILS_DEFAULT_DATABASE"] || DEFAULT_DATABASE),
8a9496c @seckar Add environment variable RAILS_DEFAULT_DATABASE, which allows the bui…
seckar authored Mar 14, 2007
12 :shebang => DEFAULT_SHEBANG, :freeze => false
290983b @dhh Added -d/--database option to the rails command, so you can do "rails…
dhh authored Feb 25, 2006
13 mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
14
15 def initialize(runtime_args, runtime_options = {})
16 super
17 usage if args.empty?
8995483 @dhh Guard against app generation if the database specified isnt supported…
dhh authored Feb 28, 2006
18 usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if (options[:db] && !DATABASES.include?(options[:db]))
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
19 @destination_root = args.shift
0adcd81 @jeremy The app generator sets a session key in application.rb so apps runnin…
jeremy authored May 7, 2006
20 @app_name = File.basename(File.expand_path(@destination_root))
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
21 end
22
23 def manifest
0f0d926 @dhh Fixed that the -r/--ruby path option of the rails command was not bei…
dhh authored Apr 6, 2006
24 # Use /usr/bin/env if no special shebang was specified
25 script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
5879a2e @dhh Changed all script/* to use /usr/bin/env ruby instead of hard-coded R…
dhh authored Nov 9, 2005
26 dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
27
ad9bacb @technoweenie fix app generator
technoweenie authored Feb 24, 2007
28 # duplicate CGI::Session#generate_unique_id
29 md5 = Digest::MD5.new
30 now = Time.now
31 md5 << now.to_s
32 md5 << String(now.usec)
33 md5 << String(rand(0))
34 md5 << String($$)
35 md5 << @app_name
36
f1d6a0e @jeremy Introduce SecretKeyGenerator for more secure session secrets than CGI…
jeremy authored Nov 28, 2007
37 # Do our best to generate a secure secret key for CookieStore
b3411ff @FooBarWidget Deprecate Rails::SecretKeyGenerator in favor of ActiveSupport::Secure…
FooBarWidget authored Aug 27, 2008
38 secret = ActiveSupport::SecureRandom.hex(64)
f1d6a0e @jeremy Introduce SecretKeyGenerator for more secure session secrets than CGI…
jeremy authored Nov 28, 2007
39
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
40 record do |m|
41 # Root directory and all subdirectories.
42 m.directory ''
43 BASEDIRS.each { |path| m.directory path }
44
45 # Root
46 m.file "fresh_rakefile", "Rakefile"
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored Jun 26, 2005
47 m.file "README", "README"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
48
49 # Application
fcce1f1 @dhh BACKWARDS INCOMPATIBLE: Renamed application.rb to application_control…
dhh authored Nov 17, 2008
50 m.template "helpers/application_controller.rb", "app/controllers/application_controller.rb", :assigns => {
51 :app_name => @app_name, :app_secret => md5.hexdigest }
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
52 m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored Jun 26, 2005
53 m.template "helpers/test_helper.rb", "test/test_helper.rb"
eab7120 @jeremy Performance: integration test benchmarking and profiling. [Jeremy Kem…
jeremy authored Jun 13, 2008
54 m.template "helpers/performance_test.rb", "test/performance/browsing_test.rb"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
55
3e73278 @dhh Removed the default .htaccess configuration as there are so many good…
dhh authored Mar 29, 2008
56 # database.yml and routes.rb
290983b @dhh Added -d/--database option to the rails command, so you can do "rails…
dhh authored Feb 25, 2006
57 m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
0adcd81 @jeremy The app generator sets a session key in application.rb so apps runnin…
jeremy authored May 7, 2006
58 :app_name => @app_name,
290983b @dhh Added -d/--database option to the rails command, so you can do "rails…
dhh authored Feb 25, 2006
59 :socket => options[:db] == "mysql" ? mysql_socket_location : nil
6273753 @jeremy Try to figure out which mysql socket to use. Default to /path/to/your…
jeremy authored Oct 16, 2005
60 }
3e73278 @dhh Removed the default .htaccess configuration as there are so many good…
dhh authored Mar 29, 2008
61 m.template "configs/routes.rb", "config/routes.rb"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
62
7bf757d @dhh Include two default initializers as examples
dhh authored Feb 23, 2007
63 # Initializers
64 m.template "configs/initializers/inflections.rb", "config/initializers/inflections.rb"
6b9448c @jeremy Partial updates include only unsaved attributes. Off by default; set …
jeremy authored Mar 31, 2008
65 m.template "configs/initializers/mime_types.rb", "config/initializers/mime_types.rb"
f6484e6 @jeremy rename config/initializers/new_in_rails_3.rb to new_rails_defaults.rb
jeremy authored Mar 31, 2008
66 m.template "configs/initializers/new_rails_defaults.rb", "config/initializers/new_rails_defaults.rb"
7bf757d @dhh Include two default initializers as examples
dhh authored Feb 23, 2007
67
d9b92ee @dhh Added config.i18n settings gatherer to config/environment, auto-loadi…
dhh authored Nov 18, 2008
68 # Locale
69 m.template "configs/locales/en.yml", "config/locales/en.yml"
70
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
71 # Environments
53e1e50 @dhh Specify gem version in environment.rb
dhh authored Apr 1, 2006
72 m.file "environments/boot.rb", "config/boot.rb"
f1d6a0e @jeremy Introduce SecretKeyGenerator for more secure session secrets than CGI…
jeremy authored Nov 28, 2007
73 m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze], :app_name => @app_name, :app_secret => secret }
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored Jun 26, 2005
74 m.file "environments/production.rb", "config/environments/production.rb"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
75 m.file "environments/development.rb", "config/environments/development.rb"
f0608c9 @dhh Include the new Javascripts in new apps
dhh authored Jun 26, 2005
76 m.file "environments/test.rb", "config/environments/test.rb"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
77
d75481c @dhh Added convenience controls for FCGI processes (especially when manage…
dhh authored Jul 24, 2005
78 # Scripts
b510d8b @jeremy Add script/dbconsole to app generator
jeremy authored May 7, 2008
79 %w( about console dbconsole destroy generate performance/benchmarker performance/profiler performance/request process/reaper process/spawner process/inspector runner server plugin ).each do |file|
a9f34ea @dhh Backed out of script/run portal idea. Muscle memory too deep
dhh authored Oct 6, 2005
80 m.file "bin/#{file}", "script/#{file}", script_options
81 end
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
82
83 # Dispatches
5879a2e @dhh Changed all script/* to use /usr/bin/env ruby instead of hard-coded R…
dhh authored Nov 9, 2005
84 m.file "dispatches/dispatch.rb", "public/dispatch.rb", dispatcher_options
85 m.file "dispatches/dispatch.rb", "public/dispatch.cgi", dispatcher_options
86 m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", dispatcher_options
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
87
88 # HTML files
89235ba @dhh Include the new 422 in the app generation
dhh authored Sep 24, 2007
89 %w(404 422 500 index).each do |file|
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
90 m.template "html/#{file}.html", "public/#{file}.html"
91 end
0d33934 @jeremy rails -d frontbase to create a new project with a frontbase database.…
jeremy authored Jul 8, 2006
92
290983b @dhh Added -d/--database option to the rails command, so you can do "rails…
dhh authored Feb 25, 2006
93 m.template "html/favicon.ico", "public/favicon.ico"
94 m.template "html/robots.txt", "public/robots.txt"
b661c96 @sstephenson Added an omnipresent RailsInfoController with a properties action tha…
sstephenson authored Nov 8, 2005
95 m.file "html/images/rails.png", "public/images/rails.png"
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
96
ecc0e28 @dhh Add prototype.js to new apps in javascripts/ #885
dhh authored Mar 21, 2005
97 # Javascripts
045f5fd @dhh Added public/javascripts/application.js as a sample since it'll autom…
dhh authored Mar 4, 2006
98 m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
99 m.file "html/javascripts/effects.js", "public/javascripts/effects.js"
100 m.file "html/javascripts/dragdrop.js", "public/javascripts/dragdrop.js"
101 m.file "html/javascripts/controls.js", "public/javascripts/controls.js"
102 m.file "html/javascripts/application.js", "public/javascripts/application.js"
ecc0e28 @dhh Add prototype.js to new apps in javascripts/ #885
dhh authored Mar 21, 2005
103
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
104 # Docs
105 m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
106
107 # Logs
8245588 @dhh Added lighttpd config example and changed apache.log to less discrimi…
dhh authored Feb 20, 2005
108 %w(server production development test).each { |file|
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
109 m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666
110 }
111 end
112 end
113
114 protected
115 def banner
116 "Usage: #{$0} /path/to/your/app [options]"
117 end
118
119 def add_options!(opt)
120 opt.separator ''
121 opt.separator 'Options:'
0f0d926 @dhh Fixed that the -r/--ruby path option of the rails command was not bei…
dhh authored Apr 6, 2006
122 opt.on("-r", "--ruby=path", String,
123 "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
81a6a60 @seckar Remove opts.on { |options[:option_name] } style hash assignment. Closes
seckar authored Jun 28, 2006
124 "Default: #{DEFAULT_SHEBANG}") { |v| options[:shebang] = v }
290983b @dhh Added -d/--database option to the rails command, so you can do "rails…
dhh authored Feb 25, 2006
125
126 opt.on("-d", "--database=name", String,
2556e67 @jeremy App generate says sqlite3 is the default and mentions frontbase. Closes
jeremy authored Dec 21, 2007
127 "Preconfigure for selected database (options: #{DATABASES.join('/')}).",
128 "Default: #{DEFAULT_DATABASE}") { |v| options[:db] = v }
d08f838 @dhh Added -f/--freeze option to rails command for freezing the applicatio…
dhh authored Apr 1, 2006
129
0d33934 @jeremy rails -d frontbase to create a new project with a frontbase database.…
jeremy authored Jul 8, 2006
130 opt.on("-f", "--freeze",
d08f838 @dhh Added -f/--freeze option to rails command for freezing the applicatio…
dhh authored Apr 1, 2006
131 "Freeze Rails in vendor/rails from the gems generating the skeleton",
81a6a60 @seckar Remove opts.on { |options[:option_name] } style hash assignment. Closes
seckar authored Jun 28, 2006
132 "Default: false") { |v| options[:freeze] = v }
290983b @dhh Added -d/--database option to the rails command, so you can do "rails…
dhh authored Feb 25, 2006
133 end
0d33934 @jeremy rails -d frontbase to create a new project with a frontbase database.…
jeremy authored Jul 8, 2006
134
290983b @dhh Added -d/--database option to the rails command, so you can do "rails…
dhh authored Feb 25, 2006
135 def mysql_socket_location
b1ce7e4 @jeremy Ruby 1.9 compat: File.exists\? -> File.exist\? en masse. References #…
jeremy authored Dec 10, 2007
136 MYSQL_SOCKET_LOCATIONS.find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
137 end
138
139
140 # Installation skeleton. Intermediate directories are automatically
141 # created so don't sweat their absence here.
142 BASEDIRS = %w(
143 app/controllers
144 app/helpers
145 app/models
146 app/views/layouts
147 config/environments
c6d6082 @dhh Added config/initializers where all ruby files within it are automati…
dhh authored Feb 23, 2007
148 config/initializers
d9b92ee @dhh Added config.i18n settings gatherer to config/environment, auto-loadi…
dhh authored Nov 18, 2008
149 config/locales
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
150 db
151 doc
152 lib
e2ba206 @dhh Moved config/tasks to lib/tasks and added more documentation to envir…
dhh authored Sep 11, 2005
153 lib/tasks
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
154 log
155 public/images
156 public/javascripts
157 public/stylesheets
08917a6 @dhh Fixed script/performance
dhh authored Oct 15, 2005
158 script/performance
0065697 @jeremy r3619@sedna: jeremy | 2005-10-14 14:41:24 -0700
jeremy authored Oct 14, 2005
159 script/process
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
160 test/fixtures
161 test/functional
1a91abe @jamis Add integration test support to app generation and testing
jamis authored Feb 28, 2006
162 test/integration
eab7120 @jeremy Performance: integration test benchmarking and profiling. [Jeremy Kem…
jeremy authored Jun 13, 2008
163 test/performance
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
164 test/unit
165 vendor
a9f34ea @dhh Backed out of script/run portal idea. Muscle memory too deep
dhh authored Oct 6, 2005
166 vendor/plugins
1aea470 @dhh Added tmp/sessions, tmp/cache, and tmp/sockets as default directories…
dhh authored Feb 25, 2006
167 tmp/sessions
168 tmp/sockets
169 tmp/cache
7a8ed3b @dhh Added pid file usage to script/process/spawner and script/process/rea…
dhh authored Apr 28, 2006
170 tmp/pids
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
171 )
9601f96 @NZKoz attempt to fix #2500
NZKoz authored Oct 17, 2005
172
24e3dbb @jeremy Add default Mac + DarwinPorts MySQL socket locations to the app gener…
jeremy authored Oct 29, 2005
173 MYSQL_SOCKET_LOCATIONS = [
174 "/tmp/mysql.sock", # default
175 "/var/run/mysqld/mysqld.sock", # debian/gentoo
176 "/var/tmp/mysql.sock", # freebsd
177 "/var/lib/mysql/mysql.sock", # fedora
178 "/opt/local/lib/mysql/mysql.sock", # fedora
179 "/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
180 "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
a61c182 @jeremy The app generator detects the XAMPP package's MySQL socket location. …
jeremy authored May 12, 2006
181 "/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
182 "/opt/lampp/var/mysql/mysql.sock" # xampp for linux
24e3dbb @jeremy Add default Mac + DarwinPorts MySQL socket locations to the app gener…
jeremy authored Oct 29, 2005
183 ]
daee6fd @dhh Added new generator framework that informs about its doings on genera…
dhh authored Feb 7, 2005
184 end
Something went wrong with that request. Please try again.