rails 1.1.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails might be problematic. Click here for more details.

Files changed (104) hide show
  1. data/CHANGELOG +267 -2
  2. data/MIT-LICENSE +1 -1
  3. data/README +62 -63
  4. data/Rakefile +26 -15
  5. data/bin/process/inspector +3 -0
  6. data/configs/databases/frontbase.yml +28 -0
  7. data/configs/databases/mysql.yml +3 -2
  8. data/configs/databases/oracle.yml +10 -1
  9. data/configs/databases/sqlite3.yml +3 -0
  10. data/configs/lighttpd.conf +1 -0
  11. data/configs/routes.rb +1 -0
  12. data/environments/boot.rb +4 -3
  13. data/environments/environment.rb +9 -2
  14. data/environments/production.rb +1 -1
  15. data/helpers/application.rb +5 -2
  16. data/html/404.html +27 -5
  17. data/html/500.html +27 -5
  18. data/html/javascripts/controls.js +41 -23
  19. data/html/javascripts/dragdrop.js +105 -76
  20. data/html/javascripts/effects.js +293 -163
  21. data/html/javascripts/prototype.js +897 -389
  22. data/lib/breakpoint.rb +31 -1
  23. data/lib/breakpoint_client.rb +5 -5
  24. data/lib/code_statistics.rb +1 -1
  25. data/lib/commands/performance/profiler.rb +25 -9
  26. data/lib/commands/plugin.rb +69 -23
  27. data/lib/commands/process/inspector.rb +68 -0
  28. data/lib/commands/process/reaper.rb +88 -69
  29. data/lib/commands/process/spawner.rb +148 -33
  30. data/lib/commands/runner.rb +27 -6
  31. data/lib/commands/server.rb +18 -9
  32. data/lib/commands/servers/base.rb +19 -0
  33. data/lib/commands/servers/lighttpd.rb +20 -18
  34. data/lib/commands/servers/mongrel.rb +65 -0
  35. data/lib/console_sandbox.rb +2 -2
  36. data/lib/dispatcher.rb +67 -11
  37. data/lib/fcgi_handler.rb +52 -34
  38. data/lib/initializer.rb +190 -111
  39. data/lib/rails/version.rb +2 -2
  40. data/lib/rails_generator/base.rb +82 -24
  41. data/lib/rails_generator/commands.rb +87 -25
  42. data/lib/rails_generator/generated_attribute.rb +42 -0
  43. data/lib/rails_generator/generators/applications/app/app_generator.rb +13 -10
  44. data/lib/rails_generator/generators/components/controller/controller_generator.rb +1 -2
  45. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +10 -8
  46. data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +1 -1
  47. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +4 -4
  48. data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +1 -1
  49. data/lib/rails_generator/generators/components/migration/templates/migration.rb +1 -1
  50. data/lib/rails_generator/generators/components/model/USAGE +19 -12
  51. data/lib/rails_generator/generators/components/model/model_generator.rb +4 -0
  52. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +8 -2
  53. data/lib/rails_generator/generators/components/model/templates/migration.rb +3 -1
  54. data/lib/rails_generator/generators/components/observer/USAGE +15 -0
  55. data/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
  56. data/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
  57. data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +10 -0
  58. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +4 -0
  59. data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +1 -0
  60. data/lib/rails_generator/generators/components/resource/resource_generator.rb +76 -0
  61. data/lib/rails_generator/generators/components/resource/templates/USAGE +18 -0
  62. data/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
  63. data/lib/rails_generator/generators/components/resource/templates/fixtures.yml +11 -0
  64. data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +20 -0
  65. data/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
  66. data/lib/rails_generator/generators/components/resource/templates/migration.rb +13 -0
  67. data/lib/rails_generator/generators/components/resource/templates/model.rb +2 -0
  68. data/lib/rails_generator/generators/components/resource/templates/unit_test.rb +10 -0
  69. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +10 -1
  70. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +11 -7
  71. data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +5 -1
  72. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +2 -2
  73. data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +1 -1
  74. data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +2 -2
  75. data/lib/rails_generator/generators/components/scaffold_resource/USAGE +29 -0
  76. data/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +92 -0
  77. data/lib/rails_generator/generators/components/scaffold_resource/templates/controller.rb +79 -0
  78. data/lib/rails_generator/generators/components/scaffold_resource/templates/fixtures.yml +11 -0
  79. data/lib/rails_generator/generators/components/scaffold_resource/templates/functional_test.rb +57 -0
  80. data/lib/rails_generator/generators/components/scaffold_resource/templates/helper.rb +2 -0
  81. data/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml +17 -0
  82. data/lib/rails_generator/generators/components/scaffold_resource/templates/migration.rb +13 -0
  83. data/lib/rails_generator/generators/components/scaffold_resource/templates/model.rb +2 -0
  84. data/lib/rails_generator/generators/components/scaffold_resource/templates/style.css +74 -0
  85. data/lib/rails_generator/generators/components/scaffold_resource/templates/unit_test.rb +10 -0
  86. data/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml +19 -0
  87. data/lib/rails_generator/generators/components/scaffold_resource/templates/view_index.rhtml +24 -0
  88. data/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml +18 -0
  89. data/lib/rails_generator/generators/components/scaffold_resource/templates/view_show.rhtml +10 -0
  90. data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +7 -1
  91. data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +5 -4
  92. data/lib/rails_generator/lookup.rb +1 -2
  93. data/lib/rails_generator/options.rb +6 -3
  94. data/lib/tasks/databases.rake +46 -20
  95. data/lib/tasks/documentation.rake +1 -0
  96. data/lib/tasks/framework.rake +1 -3
  97. data/lib/tasks/pre_namespace_aliases.rake +34 -27
  98. data/lib/tasks/rails.rb +2 -2
  99. data/lib/tasks/statistics.rake +6 -5
  100. data/lib/tasks/testing.rake +28 -13
  101. data/lib/tasks/tmp.rake +8 -1
  102. data/lib/test_help.rb +3 -2
  103. data/lib/webrick_server.rb +6 -8
  104. metadata +50 -9
@@ -1,8 +1,8 @@
1
1
  module Rails
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 1
5
- TINY = 6
4
+ MINOR = 2
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,20 +1,49 @@
1
1
  require File.dirname(__FILE__) + '/options'
2
2
  require File.dirname(__FILE__) + '/manifest'
3
3
  require File.dirname(__FILE__) + '/spec'
4
+ require File.dirname(__FILE__) + '/generated_attribute'
4
5
 
5
- # Rails::Generator is a code generation platform tailored for the Rails
6
- # web application framework. Generators are easily invoked within Rails
7
- # applications to add and remove components such as models and controllers.
8
- # New generators are easy to create and may be distributed as RubyGems or
9
- # tarballs for inclusion system-wide, per-user, or per-application.
10
- #
11
- # Generators may subclass other generators to provide variations that
12
- # require little or no new logic but replace the template files.
13
- # The postback generator is an example: it subclasses the scaffold
14
- # generator and just replaces the code templates with its own.
15
- #
16
- # Now go forth and multiply^Wgenerate.
17
6
  module Rails
7
+ # Rails::Generator is a code generation platform tailored for the Rails
8
+ # web application framework. Generators are easily invoked within Rails
9
+ # applications to add and remove components such as models and controllers.
10
+ # New generators are easy to create and may be distributed as RubyGems,
11
+ # tarballs, or Rails plugins for inclusion system-wide, per-user,
12
+ # or per-application.
13
+ #
14
+ # For actual examples see the rails_generator/generators directory in the
15
+ # Rails source (or the +railties+ directory if you have frozen the Rails
16
+ # source in your application).
17
+ #
18
+ # Generators may subclass other generators to provide variations that
19
+ # require little or no new logic but replace the template files.
20
+ #
21
+ # For a RubyGem, put your generator class and templates in the +lib+
22
+ # directory. For a Rails plugin, make a +generators+ directory at the
23
+ # root of your plugin.
24
+ #
25
+ # The layout of generator files can be seen in the built-in
26
+ # +controller+ generator:
27
+ #
28
+ # generators/
29
+ # controller/
30
+ # controller_generator.rb
31
+ # templates/
32
+ # controller.rb
33
+ # functional_test.rb
34
+ # helper.rb
35
+ # view.rhtml
36
+ #
37
+ # The directory name (+controller+) matches the name of the generator file
38
+ # (controller_generator.rb) and class (+ControllerGenerator+). The files
39
+ # that will be copied or used as templates are stored in the +templates+
40
+ # directory.
41
+ #
42
+ # The filenames of the templates don't matter, but choose something that
43
+ # will be self-explatatory since you will be referencing these in the
44
+ # +manifest+ method inside your generator subclass.
45
+ #
46
+ #
18
47
  module Generator
19
48
  class GeneratorError < StandardError; end
20
49
  class UsageError < GeneratorError; end
@@ -22,27 +51,36 @@ module Rails
22
51
 
23
52
  # The base code generator is bare-bones. It sets up the source and
24
53
  # destination paths and tells the logger whether to keep its trap shut.
25
- # You're probably looking for NamedBase, a subclass meant for generating
26
- # "named" components such as models, controllers, and mailers.
54
+ #
55
+ # It's useful for copying files such as stylesheets, images, or
56
+ # javascripts.
57
+ #
58
+ # For more comprehensive template-based passive code generation with
59
+ # arguments, you'll want Rails::Generator::NamedBase.
27
60
  #
28
61
  # Generators create a manifest of the actions they perform then hand
29
- # the manifest to a command which replay the actions to do the heavy
30
- # lifting. Create, destroy, and list commands are included. Since a
62
+ # the manifest to a command which replays the actions to do the heavy
63
+ # lifting (such as checking for existing files or creating directories
64
+ # if needed). Create, destroy, and list commands are included. Since a
31
65
  # single manifest may be used by any command, creating new generators is
32
66
  # as simple as writing some code templates and declaring what you'd like
33
67
  # to do with them.
34
68
  #
35
69
  # The manifest method must be implemented by subclasses, returning a
36
- # Rails::Generator::Manifest. The record method is provided as a
70
+ # Rails::Generator::Manifest. The +record+ method is provided as a
37
71
  # convenience for manifest creation. Example:
38
- # class EliteGenerator < Rails::Generator::Base
72
+ #
73
+ # class StylesheetGenerator < Rails::Generator::Base
39
74
  # def manifest
40
75
  # record do |m|
41
- # m.do(some)
42
- # m.things(in) { here }
76
+ # m.directory('public/stylesheets')
77
+ # m.file('application.css', 'public/stylesheets/application.css')
43
78
  # end
44
79
  # end
45
80
  # end
81
+ #
82
+ # See Rails::Generator::Commands::Create for a list of methods available
83
+ # to the manifest.
46
84
  class Base
47
85
  include Options
48
86
 
@@ -78,7 +116,7 @@ module Rails
78
116
  usage if options[:help]
79
117
  end
80
118
 
81
- # Generators must provide a manifest. Use the record method to create
119
+ # Generators must provide a manifest. Use the +record+ method to create
82
120
  # a new manifest and record your generator's actions.
83
121
  def manifest
84
122
  raise NotImplementedError, "No manifest for '#{spec.name}' generator."
@@ -136,13 +174,25 @@ module Rails
136
174
  # The base generator for named components: models, controllers, mailers,
137
175
  # etc. The target name is taken as the first argument and inflected to
138
176
  # singular, plural, class, file, and table forms for your convenience.
139
- # The remaining arguments are aliased to actions for controller and
140
- # mailer convenience.
177
+ # The remaining arguments are aliased to +actions+ as an array for
178
+ # controller and mailer convenience.
179
+ #
180
+ # Several useful local variables and methods are populated in the
181
+ # +initialize+ method. See below for a list of Attributes and
182
+ # External Aliases available to both the manifest and to all templates.
141
183
  #
142
184
  # If no name is provided, the generator raises a usage error with content
143
185
  # optionally read from the USAGE file in the generator's base path.
144
186
  #
145
- # See Rails::Generator::Base for a discussion of Manifests and Commands.
187
+ # For example, the +controller+ generator takes the first argument as
188
+ # the name of the class and subsequent arguments as the names of
189
+ # actions to be generated:
190
+ #
191
+ # ./script/generate controller Article index new create
192
+ #
193
+ # See Rails::Generator::Base for a discussion of manifests,
194
+ # Rails::Generator::Commands::Create for methods available to the manifest,
195
+ # and Rails::Generator for a general discussion of generators.
146
196
  class NamedBase < Base
147
197
  attr_reader :name, :class_name, :singular_name, :plural_name, :table_name
148
198
  attr_reader :class_path, :file_path, :class_nesting, :class_nesting_depth
@@ -165,6 +215,13 @@ module Rails
165
215
  def banner
166
216
  "Usage: #{$0} #{spec.name} #{spec.name.camelize}Name [options]"
167
217
  end
218
+
219
+ def attributes
220
+ @attributes ||= @args.collect do |attribute|
221
+ Rails::Generator::GeneratedAttribute.new(*attribute.split(":"))
222
+ end
223
+ end
224
+
168
225
 
169
226
  private
170
227
  def assign_names!(name)
@@ -175,6 +232,7 @@ module Rails
175
232
  if @class_nesting.empty?
176
233
  @class_name = @class_name_without_nesting
177
234
  else
235
+ @table_name = @class_nesting.underscore << "_" << @table_name
178
236
  @class_name = "#{@class_nesting}::#{@class_name_without_nesting}"
179
237
  end
180
238
  end
@@ -1,6 +1,7 @@
1
1
  require 'delegate'
2
2
  require 'optparse'
3
3
  require 'fileutils'
4
+ require 'tempfile'
4
5
  require 'erb'
5
6
 
6
7
  module Rails
@@ -16,7 +17,7 @@ module Rails
16
17
  # Even more convenient access to commands. Include Commands in
17
18
  # the generator Base class to get a nice #command instance method
18
19
  # which returns a delegate for the requested command.
19
- def self.append_features(base)
20
+ def self.included(base)
20
21
  base.send(:define_method, :command) do |command|
21
22
  Commands.instance(command, self)
22
23
  end
@@ -83,11 +84,25 @@ module Rails
83
84
  "%.#{padding}d" % next_migration_number
84
85
  end
85
86
 
87
+ def gsub_file(relative_destination, regexp, *args, &block)
88
+ path = destination_path(relative_destination)
89
+ content = File.read(path).gsub(regexp, *args, &block)
90
+ File.open(path, 'wb') { |file| file.write(content) }
91
+ end
92
+
86
93
  private
87
94
  # Ask the user interactively whether to force collision.
88
- def force_file_collision?(destination)
89
- $stdout.print "overwrite #{destination}? [Ynaq] "
95
+ def force_file_collision?(destination, src, dst, file_options = {}, &block)
96
+ $stdout.print "overwrite #{destination}? [Ynaqd] "
90
97
  case $stdin.gets
98
+ when /d/i
99
+ Tempfile.open(File.basename(destination), File.dirname(dst)) do |temp|
100
+ temp.write render_file(src, file_options, &block)
101
+ temp.rewind
102
+ $stdout.puts `#{diff_cmd} #{dst} #{temp.path}`
103
+ end
104
+ puts "retrying"
105
+ raise 'retry diff'
91
106
  when /a/i
92
107
  $stdout.puts "forcing #{spec.name}"
93
108
  options[:collision] = :force
@@ -101,6 +116,10 @@ module Rails
101
116
  retry
102
117
  end
103
118
 
119
+ def diff_cmd
120
+ ENV['RAILS_DIFF'] || 'diff -u'
121
+ end
122
+
104
123
  def render_template_part(template_options)
105
124
  # Getting Sandbox to evaluate part template in it
106
125
  part_binding = template_options[:sandbox].call.sandbox_binding
@@ -191,7 +210,7 @@ module Rails
191
210
  # Make a choice whether to overwrite the file. :force and
192
211
  # :skip already have their mind made up, but give :ask a shot.
193
212
  choice = case (file_options[:collision] || options[:collision]).to_sym #|| :ask
194
- when :ask then force_file_collision?(relative_destination)
213
+ when :ask then force_file_collision?(relative_destination, source, destination, file_options, &block)
195
214
  when :force then :force
196
215
  when :skip then :skip
197
216
  else raise "Invalid collision option: #{options[:collision].inspect}"
@@ -217,27 +236,15 @@ module Rails
217
236
  # if block given so templaters may render the source file. If a
218
237
  # shebang is requested, replace the existing shebang or insert a
219
238
  # new one.
220
- File.open(destination, 'wb') do |df|
221
- File.open(source, 'rb') do |sf|
222
- if block_given?
223
- df.write(yield(sf))
224
- else
225
- if file_options[:shebang]
226
- df.puts("#!#{file_options[:shebang]}")
227
- if line = sf.gets
228
- df.puts(line) if line !~ /^#!/
229
- end
230
- end
231
- df.write(sf.read)
232
- end
233
- end
239
+ File.open(destination, 'wb') do |dest|
240
+ dest.write render_file(source, file_options, &block)
234
241
  end
235
242
 
236
243
  # Optionally change permissions.
237
244
  if file_options[:chmod]
238
245
  FileUtils.chmod(file_options[:chmod], destination)
239
246
  end
240
-
247
+
241
248
  # Optionally add file to subversion
242
249
  system("svn add #{destination}") if options[:svn]
243
250
  end
@@ -293,12 +300,26 @@ module Rails
293
300
  logger.exists relative_path
294
301
  else
295
302
  logger.create relative_path
296
- FileUtils.mkdir_p(path) unless options[:pretend]
297
-
298
- # Optionally add file to subversion
299
- system("svn add #{path}") if options[:svn]
300
- end
301
- end
303
+ unless options[:pretend]
304
+ FileUtils.mkdir_p(path)
305
+
306
+ # Subversion doesn't do path adds, so we need to add
307
+ # each directory individually.
308
+ # So stack up the directory tree and add the paths to
309
+ # subversion in order without recursion.
310
+ if options[:svn]
311
+ stack=[relative_path]
312
+ until File.dirname(stack.last) == stack.last # dirname('.') == '.'
313
+ stack.push File.dirname(stack.last)
314
+ end
315
+ stack.reverse_each do |rel_path|
316
+ svn_path = destination_path(rel_path)
317
+ system("svn add -N #{svn_path}") unless File.directory?(File.join(svn_path, '.svn'))
318
+ end
319
+ end
320
+ end
321
+ end
322
+ end
302
323
 
303
324
  # Display a README.
304
325
  def readme(*relative_sources)
@@ -316,7 +337,36 @@ module Rails
316
337
  template(relative_source, "#{relative_destination}/#{next_migration_string}_#{migration_file_name}.rb", template_options)
317
338
  end
318
339
 
340
+ def route_resources(*resources)
341
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
342
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
343
+
344
+ logger.route "map.resources #{resource_list}"
345
+ unless options[:pretend]
346
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
347
+ "#{match}\n map.resources #{resource_list}\n"
348
+ end
349
+ end
350
+ end
351
+
319
352
  private
353
+ def render_file(path, options = {})
354
+ File.open(path, 'rb') do |file|
355
+ if block_given?
356
+ yield file
357
+ else
358
+ content = ''
359
+ if shebang = options[:shebang]
360
+ content << "#!#{shebang}\n"
361
+ if line = file.gets
362
+ content << "line\n" if line !~ /^#!/
363
+ end
364
+ end
365
+ content << file.read
366
+ end
367
+ end
368
+ end
369
+
320
370
  # Raise a usage error with an informative WordNet suggestion.
321
371
  # Thanks to Florian Gross (flgr).
322
372
  def raise_class_collision(class_name)
@@ -438,6 +488,13 @@ end_message
438
488
  file(relative_source, file_path, template_options)
439
489
  end
440
490
  end
491
+
492
+ def route_resources(*resources)
493
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
494
+ look_for = "\n map.resources #{resource_list}\n"
495
+ logger.route "map.resources #{resource_list}"
496
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
497
+ end
441
498
  end
442
499
 
443
500
 
@@ -475,6 +532,11 @@ end_message
475
532
  migration_directory relative_destination
476
533
  logger.migration_template file_name
477
534
  end
535
+
536
+ def route_resources(*resources)
537
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
538
+ logger.route "map.resources #{resource_list}"
539
+ end
478
540
  end
479
541
 
480
542
  # Update generator's action manifest.
@@ -0,0 +1,42 @@
1
+ require 'optparse'
2
+
3
+ module Rails
4
+ module Generator
5
+ class GeneratedAttribute
6
+ attr_accessor :name, :type, :column
7
+
8
+ def initialize(name, type)
9
+ @name, @type = name, type.to_sym
10
+ @column = ActiveRecord::ConnectionAdapters::Column.new(name, nil, @type)
11
+ end
12
+
13
+ def field_type
14
+ @field_type ||= case type
15
+ when :integer, :float, :decimal then :text_field
16
+ when :datetime, :timestamp, :time then :datetime_select
17
+ when :date then :date_select
18
+ when :string then :text_field
19
+ when :text then :text_area
20
+ when :boolean then :check_box
21
+ else
22
+ :text_field
23
+ end
24
+ end
25
+
26
+ def default
27
+ @default ||= case type
28
+ when :integer then 1
29
+ when :float then 1.5
30
+ when :decimal then "9.99"
31
+ when :datetime, :timestamp, :time then Time.now.to_s(:db)
32
+ when :date then Date.today.to_s(:db)
33
+ when :string then "MyString"
34
+ when :text then "MyText"
35
+ when :boolean then false
36
+ else
37
+ ""
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -3,9 +3,9 @@ require 'rbconfig'
3
3
  class AppGenerator < Rails::Generator::Base
4
4
  DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
5
5
  Config::CONFIG['ruby_install_name'])
6
-
7
- DATABASES = %w( mysql oracle postgresql sqlite2 sqlite3 )
8
-
6
+
7
+ DATABASES = %w(mysql oracle postgresql sqlite2 sqlite3 frontbase)
8
+
9
9
  default_options :db => "mysql", :shebang => DEFAULT_SHEBANG, :freeze => false
10
10
  mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
11
11
 
@@ -14,6 +14,7 @@ class AppGenerator < Rails::Generator::Base
14
14
  usage if args.empty?
15
15
  usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if (options[:db] && !DATABASES.include?(options[:db]))
16
16
  @destination_root = args.shift
17
+ @app_name = File.basename(File.expand_path(@destination_root))
17
18
  end
18
19
 
19
20
  def manifest
@@ -31,13 +32,13 @@ class AppGenerator < Rails::Generator::Base
31
32
  m.file "README", "README"
32
33
 
33
34
  # Application
34
- m.template "helpers/application.rb", "app/controllers/application.rb"
35
+ m.template "helpers/application.rb", "app/controllers/application.rb", :assigns => { :app_name => @app_name }
35
36
  m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
36
37
  m.template "helpers/test_helper.rb", "test/test_helper.rb"
37
38
 
38
39
  # database.yml and .htaccess
39
40
  m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
40
- :app_name => File.basename(File.expand_path(@destination_root)),
41
+ :app_name => @app_name,
41
42
  :socket => options[:db] == "mysql" ? mysql_socket_location : nil
42
43
  }
43
44
  m.template "configs/routes.rb", "config/routes.rb"
@@ -51,7 +52,7 @@ class AppGenerator < Rails::Generator::Base
51
52
  m.file "environments/test.rb", "config/environments/test.rb"
52
53
 
53
54
  # Scripts
54
- %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner runner server plugin ).each do |file|
55
+ %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin ).each do |file|
55
56
  m.file "bin/#{file}", "script/#{file}", script_options
56
57
  end
57
58
 
@@ -64,7 +65,7 @@ class AppGenerator < Rails::Generator::Base
64
65
  %w(404 500 index).each do |file|
65
66
  m.template "html/#{file}.html", "public/#{file}.html"
66
67
  end
67
-
68
+
68
69
  m.template "html/favicon.ico", "public/favicon.ico"
69
70
  m.template "html/robots.txt", "public/robots.txt"
70
71
  m.file "html/images/rails.png", "public/images/rails.png"
@@ -102,11 +103,11 @@ class AppGenerator < Rails::Generator::Base
102
103
  "Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite2/sqlite3).",
103
104
  "Default: mysql") { |v| options[:db] = v }
104
105
 
105
- opt.on("-f", "--freeze",
106
+ opt.on("-f", "--freeze",
106
107
  "Freeze Rails in vendor/rails from the gems generating the skeleton",
107
108
  "Default: false") { |v| options[:freeze] = v }
108
109
  end
109
-
110
+
110
111
  def mysql_socket_location
111
112
  RUBY_PLATFORM =~ /mswin32/ ? MYSQL_SOCKET_LOCATIONS.find { |f| File.exists?(f) } : nil
112
113
  end
@@ -142,6 +143,7 @@ class AppGenerator < Rails::Generator::Base
142
143
  tmp/sessions
143
144
  tmp/sockets
144
145
  tmp/cache
146
+ tmp/pids
145
147
  )
146
148
 
147
149
  MYSQL_SOCKET_LOCATIONS = [
@@ -152,6 +154,7 @@ class AppGenerator < Rails::Generator::Base
152
154
  "/opt/local/lib/mysql/mysql.sock", # fedora
153
155
  "/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
154
156
  "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
155
- "/opt/local/var/run/mysql5/mysqld.sock" # mac + darwinports + mysql5
157
+ "/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
158
+ "/opt/lampp/var/mysql/mysql.sock" # xampp for linux
156
159
  ]
157
160
  end