rails 2.1.0 → 2.1.1

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.

data/CHANGELOG CHANGED
@@ -1,3 +1,18 @@
1
+ *2.1.1 (September 4th, 2008)*
2
+
3
+ * Fix script/about in production mode. #370 [Cheah Chu Yeow, Xavier Noria, David Krmpotic]
4
+
5
+ * Add the gem load paths before the framework is loaded, so certain gems like RedCloth and BlueCloth can be frozen.
6
+
7
+ * Fix discrepancies with loading rails/init.rb from gems.
8
+
9
+ * Plugins check for the gem init path (rails/init.rb) before the standard plugin init path (init.rb) [Jacek Becela]
10
+
11
+ * Wrapped Rails.env in StringInquirer so you can do Rails.env.development? [DHH]
12
+
13
+ * Fixed that RailsInfoController wasn't considering all requests local in development mode (Edgard Castro) [#310 state:resolved]
14
+
15
+
1
16
  *2.1.0 (May 31st, 2008)*
2
17
 
3
18
  * script/dbconsole fires up the command-line database client. #102 [Steve Purcell]
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
  require 'rake/gempackagetask'
5
+ require 'rake/contrib/sshpublisher'
5
6
  require 'rake/contrib/rubyforgepublisher'
6
7
 
7
8
  require 'date'
@@ -264,9 +265,10 @@ Rake::RDocTask.new { |rdoc|
264
265
  rdoc.title = "Railties -- Gluing the Engine to the Rails"
265
266
  rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object'
266
267
  rdoc.options << '--charset' << 'utf-8'
267
- rdoc.template = "#{ENV['template']}.rb" if ENV['template']
268
+ rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
268
269
  rdoc.rdoc_files.include('README', 'CHANGELOG')
269
270
  rdoc.rdoc_files.include('lib/*.rb')
271
+ rdoc.rdoc_files.include('lib/rails/*.rb')
270
272
  rdoc.rdoc_files.include('lib/rails_generator/*.rb')
271
273
  rdoc.rdoc_files.include('lib/commands/**/*.rb')
272
274
  }
@@ -304,11 +306,11 @@ spec = Gem::Specification.new do |s|
304
306
  EOF
305
307
 
306
308
  s.add_dependency('rake', '>= 0.8.1')
307
- s.add_dependency('activesupport', '= 2.1.0' + PKG_BUILD)
308
- s.add_dependency('activerecord', '= 2.1.0' + PKG_BUILD)
309
- s.add_dependency('actionpack', '= 2.1.0' + PKG_BUILD)
310
- s.add_dependency('actionmailer', '= 2.1.0' + PKG_BUILD)
311
- s.add_dependency('activeresource', '= 2.1.0' + PKG_BUILD)
309
+ s.add_dependency('activesupport', '= 2.1.1' + PKG_BUILD)
310
+ s.add_dependency('activerecord', '= 2.1.1' + PKG_BUILD)
311
+ s.add_dependency('actionpack', '= 2.1.1' + PKG_BUILD)
312
+ s.add_dependency('actionmailer', '= 2.1.1' + PKG_BUILD)
313
+ s.add_dependency('activeresource', '= 2.1.1' + PKG_BUILD)
312
314
 
313
315
  s.rdoc_options << '--exclude' << '.'
314
316
  s.has_rdoc = false
@@ -331,10 +333,10 @@ end
331
333
 
332
334
 
333
335
  # Publishing -------------------------------------------------------
334
- desc "Publish the API documentation"
336
+ desc "Publish the rails gem"
335
337
  task :pgem => [:gem] do
336
- Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
337
- `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
338
+ Rake::SshFilePublisher.new("david@greed.loudthinking.com", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
339
+ `ssh david@greed.loudthinking.com '/u/sites/gems/gemupdate.sh'`
338
340
  end
339
341
 
340
342
  desc "Publish the release files to RubyForge."
data/bin/about CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/about'
3
+ $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4
+ require 'commands/about'
File without changes
data/bin/rails CHANGED
File without changes
@@ -1,6 +1,6 @@
1
1
  class Rails::InfoController < ActionController::Base
2
2
  def properties
3
- if local_request?
3
+ if consider_all_requests_local || local_request?
4
4
  render :inline => Rails::Info.to_html
5
5
  else
6
6
  render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500
File without changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Add new inflection rules using the following format
4
4
  # (all these examples are active by default):
5
- # Inflector.inflections do |inflect|
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
6
  # inflect.plural /^(ox)$/i, '\1en'
7
7
  # inflect.singular /^(ox)en/i, '\1'
8
8
  # inflect.irregular 'person', 'people'
@@ -1,11 +1,13 @@
1
1
  # These settings change the behavior of Rails 2 apps and will be defaults
2
2
  # for Rails 3. You can remove this initializer when Rails 3 is released.
3
3
 
4
- # Include Active Record class name as root for JSON serialized output.
5
- ActiveRecord::Base.include_root_in_json = true
4
+ if defined?(ActiveRecord)
5
+ # Include Active Record class name as root for JSON serialized output.
6
+ ActiveRecord::Base.include_root_in_json = true
6
7
 
7
- # Store the full class name (including module namespace) in STI type column.
8
- ActiveRecord::Base.store_full_sti_class = true
8
+ # Store the full class name (including module namespace) in STI type column.
9
+ ActiveRecord::Base.store_full_sti_class = true
10
+ end
9
11
 
10
12
  # Use ISO 8601 format for JSON serialized times and dates.
11
13
  ActiveSupport.use_standard_json_time_format = true
@@ -36,6 +36,8 @@ ActionController::Routing::Routes.draw do |map|
36
36
  # See how all your routes lay out with "rake routes"
37
37
 
38
38
  # Install the default routes as the lowest priority.
39
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
40
+ # consider removing the them or commenting them out if you're using named routes and resources.
39
41
  map.connect ':controller/:action/:id'
40
42
  map.connect ':controller/:action/:id.:format'
41
43
  end
File without changes
File without changes
@@ -82,14 +82,14 @@ module Rails
82
82
 
83
83
  def load_rubygems
84
84
  require 'rubygems'
85
-
86
- unless rubygems_version >= '0.9.4'
87
- $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
85
+ min_version = '1.1.1'
86
+ unless rubygems_version >= min_version
87
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
88
88
  exit 1
89
89
  end
90
90
 
91
91
  rescue LoadError
92
- $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
92
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
93
93
  exit 1
94
94
  end
95
95
 
@@ -40,7 +40,7 @@ Rails::Initializer.run do |config|
40
40
 
41
41
  # Make Time.zone default to the specified zone, and make Active Record store time values
42
42
  # in the database in UTC, and return them converted to the specified local zone.
43
- # Run "rake -D time" for a list of tasks for finding time zone names. Uncomment to use default local time.
43
+ # Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
44
44
  config.time_zone = 'UTC'
45
45
 
46
46
  # Your secret key for verifying cookie session data integrity.
File without changes
@@ -1,2 +1,3 @@
1
1
  require 'environment'
2
+ require 'rails/info'
2
3
  puts Rails::Info
@@ -41,6 +41,8 @@ when "mysql"
41
41
 
42
42
  if config['password'] && include_password
43
43
  args << "--password=#{config['password']}"
44
+ elsif config['password'] && !config['password'].empty?
45
+ args << "-p"
44
46
  end
45
47
 
46
48
  args << config['database']
File without changes
File without changes
@@ -632,7 +632,7 @@ module Commands
632
632
  def options
633
633
  OptionParser.new do |o|
634
634
  o.set_summary_indent(' ')
635
- o.banner = "Usage: #{@base_command.script_name} source URI [URI [URI]...]"
635
+ o.banner = "Usage: #{@base_command.script_name} unsource URI [URI [URI]...]"
636
636
  o.define_head "Remove repositories from the default search list."
637
637
  o.separator ""
638
638
  o.on_tail("-h", "--help", "Show this help message.") { puts o; exit }
@@ -890,7 +890,7 @@ class RecursiveHTTPFetcher
890
890
 
891
891
  def ls
892
892
  @urls_to_fetch.collect do |url|
893
- if url =~ /^svn:\/\/.*/
893
+ if url =~ /^svn(\+ssh)?:\/\/.*/
894
894
  `svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil
895
895
  else
896
896
  open(url) do |stream|
@@ -16,7 +16,7 @@ def helper(*helper_names)
16
16
  end
17
17
  end
18
18
 
19
- require 'application'
19
+ require_dependency 'application'
20
20
 
21
21
  class << helper
22
22
  include_all_modules_from ActionView
@@ -36,7 +36,8 @@ module Rails
36
36
  end
37
37
 
38
38
  def env
39
- RAILS_ENV
39
+ require 'active_support/string_inquirer'
40
+ ActiveSupport::StringInquirer.new(RAILS_ENV)
40
41
  end
41
42
 
42
43
  def cache
@@ -78,7 +79,10 @@ module Rails
78
79
 
79
80
  # The set of loaded plugins.
80
81
  attr_reader :loaded_plugins
81
-
82
+
83
+ # Whether or not all the gem dependencies have been met
84
+ attr_reader :gems_dependencies_loaded
85
+
82
86
  # Runs the initializer. By default, this will invoke the #process method,
83
87
  # which simply executes all of the initialization routines. Alternately,
84
88
  # you can specify explicitly which initialization routine you want:
@@ -109,10 +113,10 @@ module Rails
109
113
  check_ruby_version
110
114
  install_gem_spec_stubs
111
115
  set_load_path
112
-
116
+ add_gem_load_paths
117
+
113
118
  require_frameworks
114
119
  set_autoload_paths
115
- add_gem_load_paths
116
120
  add_plugin_load_paths
117
121
  load_environment
118
122
 
@@ -200,10 +204,10 @@ module Rails
200
204
  # Set the paths from which Rails will automatically load source files, and
201
205
  # the load_once paths.
202
206
  def set_autoload_paths
203
- Dependencies.load_paths = configuration.load_paths.uniq
204
- Dependencies.load_once_paths = configuration.load_once_paths.uniq
207
+ ActiveSupport::Dependencies.load_paths = configuration.load_paths.uniq
208
+ ActiveSupport::Dependencies.load_once_paths = configuration.load_once_paths.uniq
205
209
 
206
- extra = Dependencies.load_once_paths - Dependencies.load_paths
210
+ extra = ActiveSupport::Dependencies.load_once_paths - ActiveSupport::Dependencies.load_paths
207
211
  unless extra.empty?
208
212
  abort <<-end_error
209
213
  load_once_paths must be a subset of the load_paths.
@@ -230,7 +234,7 @@ module Rails
230
234
  end
231
235
 
232
236
  # Adds all load paths from plugins to the global set of load paths, so that
233
- # code from plugins can be required (explicitly or automatically via Dependencies).
237
+ # code from plugins can be required (explicitly or automatically via ActiveSupport::Dependencies).
234
238
  def add_plugin_load_paths
235
239
  plugin_loader.add_plugin_load_paths
236
240
  end
@@ -238,12 +242,12 @@ module Rails
238
242
  def add_gem_load_paths
239
243
  unless @configuration.gems.empty?
240
244
  require "rubygems"
241
- @configuration.gems.each &:add_load_paths
245
+ @configuration.gems.each { |gem| gem.add_load_paths }
242
246
  end
243
247
  end
244
248
 
245
249
  def load_gems
246
- @configuration.gems.each(&:load)
250
+ @configuration.gems.each { |gem| gem.load }
247
251
  end
248
252
 
249
253
  def check_gem_dependencies
@@ -252,11 +256,16 @@ module Rails
252
256
  @gems_dependencies_loaded = false
253
257
  # don't print if the gems rake tasks are being run
254
258
  unless $rails_gem_installer
255
- puts %{These gems that this application depends on are missing:}
256
- unloaded_gems.each do |gem|
257
- puts " - #{gem.name}"
258
- end
259
- puts %{Run "rake gems:install" to install them.}
259
+ abort <<-end_error
260
+ Missing these required gems:
261
+ #{unloaded_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "}
262
+
263
+ You're running:
264
+ ruby #{Gem.ruby_version} at #{Gem.ruby}
265
+ rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '}
266
+
267
+ Run `rake gems:install` to install the missing gems.
268
+ end_error
260
269
  end
261
270
  else
262
271
  @gems_dependencies_loaded = true
@@ -306,7 +315,7 @@ module Rails
306
315
  end
307
316
 
308
317
  def load_observers
309
- if @gems_dependencies_loaded && configuration.frameworks.include?(:active_record)
318
+ if gems_dependencies_loaded && configuration.frameworks.include?(:active_record)
310
319
  ActiveRecord::Base.instantiate_observers
311
320
  end
312
321
  end
@@ -412,7 +421,7 @@ module Rails
412
421
  # Sets the dependency loading mechanism based on the value of
413
422
  # Configuration#cache_classes.
414
423
  def initialize_dependency_mechanism
415
- Dependencies.mechanism = configuration.cache_classes ? :require : :load
424
+ ActiveSupport::Dependencies.mechanism = configuration.cache_classes ? :require : :load
416
425
  end
417
426
 
418
427
  # Loads support for "whiny nil" (noisy warnings when methods are invoked
@@ -462,7 +471,7 @@ module Rails
462
471
 
463
472
  # Fires the user-supplied after_initialize block (Configuration#after_initialize)
464
473
  def after_initialize
465
- if @gems_dependencies_loaded
474
+ if gems_dependencies_loaded
466
475
  configuration.after_initialize_blocks.each do |block|
467
476
  block.call
468
477
  end
@@ -470,7 +479,7 @@ module Rails
470
479
  end
471
480
 
472
481
  def load_application_initializers
473
- if @gems_dependencies_loaded
482
+ if gems_dependencies_loaded
474
483
  Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer|
475
484
  load(initializer)
476
485
  end
@@ -478,6 +487,7 @@ module Rails
478
487
  end
479
488
 
480
489
  def prepare_dispatcher
490
+ return unless configuration.frameworks.include?(:action_controller)
481
491
  require 'dispatcher' unless defined?(::Dispatcher)
482
492
  Dispatcher.define_dispatcher_callbacks(configuration.cache_classes)
483
493
  Dispatcher.new(RAILS_DEFAULT_LOGGER).send :run_callbacks, :prepare_dispatch
@@ -598,12 +608,12 @@ module Rails
598
608
  # If <tt>reload_plugins?</tt> is false, add this to your plugin's <tt>init.rb</tt>
599
609
  # to make it reloadable:
600
610
  #
601
- # Dependencies.load_once_paths.delete lib_path
611
+ # ActiveSupport::Dependencies.load_once_paths.delete lib_path
602
612
  #
603
613
  # If <tt>reload_plugins?</tt> is true, add this to your plugin's <tt>init.rb</tt>
604
614
  # to only load it once:
605
615
  #
606
- # Dependencies.load_once_paths << lib_path
616
+ # ActiveSupport::Dependencies.load_once_paths << lib_path
607
617
  #
608
618
  attr_accessor :reload_plugins
609
619
 
@@ -620,13 +630,17 @@ module Rails
620
630
  # You can add gems with the #gem method.
621
631
  attr_accessor :gems
622
632
 
623
- # Adds a single Gem dependency to the rails application.
633
+ # Adds a single Gem dependency to the rails application. By default, it will require
634
+ # the library with the same name as the gem. Use :lib to specify a different name.
624
635
  #
625
636
  # # gem 'aws-s3', '>= 0.4.0'
626
637
  # # require 'aws/s3'
627
638
  # config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \
628
639
  # :source => "http://code.whytheluckystiff.net"
629
640
  #
641
+ # To require a library be installed, but not attempt to load it, pass :lib => false
642
+ #
643
+ # config.gem 'qrp', :version => '0.4.1', :lib => false
630
644
  def gem(name, options = {})
631
645
  @gems << Rails::GemDependency.new(name, options)
632
646
  end
@@ -698,6 +712,7 @@ module Rails
698
712
  # contents of the file are processed via ERB before being sent through
699
713
  # YAML::load.
700
714
  def database_configuration
715
+ require 'erb'
701
716
  YAML::load(ERB.new(IO.read(database_configuration_file)).result)
702
717
  end
703
718
 
@@ -23,9 +23,13 @@ module Rails
23
23
  @unpack_directory = nil
24
24
  end
25
25
 
26
+ def unpacked_paths
27
+ Dir[File.join(self.class.unpacked_path, "#{@name}-#{@version || "*"}")]
28
+ end
29
+
26
30
  def add_load_paths
27
31
  return if @loaded || @load_paths_added
28
- unpacked_paths = Dir[File.join(self.class.unpacked_path, "#{@name}-#{@version || "*"}")]
32
+ unpacked_paths = self.unpacked_paths
29
33
  if unpacked_paths.empty?
30
34
  args = [@name]
31
35
  args << @requirement.to_s if @requirement
@@ -39,7 +43,7 @@ module Rails
39
43
  @load_paths_added = true
40
44
  rescue Gem::LoadError
41
45
  end
42
-
46
+
43
47
  def dependencies
44
48
  all_dependencies = specification.dependencies.map do |dependency|
45
49
  GemDependency.new(dependency.name, :requirement => dependency.version_requirements)
@@ -47,14 +51,14 @@ module Rails
47
51
  all_dependencies += all_dependencies.map(&:dependencies).flatten
48
52
  all_dependencies.uniq
49
53
  end
50
-
54
+
51
55
  def gem_dir(base_directory)
52
56
  File.join(base_directory, specification.full_name)
53
57
  end
54
58
 
55
59
  def load
56
60
  return if @loaded || @load_paths_added == false
57
- require(@lib || @name)
61
+ require(@lib || @name) unless @lib == false
58
62
  @loaded = true
59
63
  rescue LoadError
60
64
  puts $!.to_s
@@ -78,13 +82,13 @@ module Rails
78
82
  puts cmd
79
83
  puts %x(#{cmd})
80
84
  end
81
-
85
+
82
86
  def unpack_to(directory)
83
87
  FileUtils.mkdir_p directory
84
88
  Dir.chdir directory do
85
89
  Gem::GemRunner.new.run(unpack_command)
86
90
  end
87
-
91
+
88
92
  # copy the gem's specification into GEMDIR/.specification so that
89
93
  # we can access information about the gem on deployment systems
90
94
  # without having the gem installed
@@ -98,27 +102,26 @@ module Rails
98
102
  self.name == other.name && self.requirement == other.requirement
99
103
  end
100
104
 
101
- private ###################################################################
102
-
103
105
  def specification
104
106
  @spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last
105
107
  end
106
-
107
- def gem_command
108
- RUBY_PLATFORM =~ /win32/ ? 'gem.bat' : 'gem'
109
- end
110
108
 
111
- def install_command
112
- cmd = %w(install) << @name
113
- cmd << "--version" << %("#{@requirement.to_s}") if @requirement
114
- cmd << "--source" << @source if @source
115
- cmd
116
- end
117
-
118
- def unpack_command
119
- cmd = %w(unpack) << @name
120
- cmd << "--version" << "#{@requirement.to_s}" if @requirement
121
- cmd
122
- end
109
+ private
110
+ def gem_command
111
+ RUBY_PLATFORM =~ /win32/ ? 'gem.bat' : 'gem'
112
+ end
113
+
114
+ def install_command
115
+ cmd = %w(install) << @name
116
+ cmd << "--version" << %("#{@requirement.to_s}") if @requirement
117
+ cmd << "--source" << @source if @source
118
+ cmd
119
+ end
120
+
121
+ def unpack_command
122
+ cmd = %w(unpack) << @name
123
+ cmd << "--version" << %("#{@requirement.to_s}") if @requirement
124
+ cmd
125
+ end
123
126
  end
124
- end
127
+ end
@@ -87,14 +87,14 @@ module Rails
87
87
  end
88
88
 
89
89
  def evaluate_init_rb(initializer)
90
- if has_init_file?
91
- silence_warnings do
92
- # Allow plugins to reference the current configuration object
93
- config = initializer.configuration
94
-
95
- eval(IO.read(init_path), binding, init_path)
96
- end
97
- end
90
+ if has_init_file?
91
+ silence_warnings do
92
+ # Allow plugins to reference the current configuration object
93
+ config = initializer.configuration
94
+
95
+ eval(IO.read(init_path), binding, init_path)
96
+ end
97
+ end
98
98
  end
99
99
  end
100
100
 
@@ -103,8 +103,9 @@ module Rails
103
103
  # to Dependencies.load_paths.
104
104
  class GemPlugin < Plugin
105
105
  # Initialize this plugin from a Gem::Specification.
106
- def initialize(spec)
107
- super(File.join(spec.full_gem_path))
106
+ def initialize(spec, gem)
107
+ directory = (gem.frozen? && gem.unpacked_paths.first) || File.join(spec.full_gem_path)
108
+ super(directory)
108
109
  @name = spec.name
109
110
  end
110
111
 
@@ -45,9 +45,9 @@ module Rails
45
45
  plugins.each do |plugin|
46
46
  plugin.load_paths.each do |path|
47
47
  $LOAD_PATH.insert(application_lib_index + 1, path)
48
- Dependencies.load_paths << path
48
+ ActiveSupport::Dependencies.load_paths << path
49
49
  unless Rails.configuration.reload_plugins?
50
- Dependencies.load_once_paths << path
50
+ ActiveSupport::Dependencies.load_once_paths << path
51
51
  end
52
52
  end
53
53
  end
@@ -63,7 +63,7 @@ module Rails
63
63
  # => <Rails::Plugin name: 'acts_as_chunky_bacon' ... >
64
64
  #
65
65
  def locate_plugins_under(base_path)
66
- Dir.glob(File.join(base_path, '*')).inject([]) do |plugins, path|
66
+ Dir.glob(File.join(base_path, '*')).sort.inject([]) do |plugins, path|
67
67
  if plugin = create_plugin(path)
68
68
  plugins << plugin
69
69
  elsif File.directory?(path)
@@ -78,8 +78,9 @@ module Rails
78
78
  # a <tt>rails/init.rb</tt> file.
79
79
  class GemLocator < Locator
80
80
  def plugins
81
- specs = initializer.configuration.gems.map(&:specification)
82
- specs += Gem.loaded_specs.values.select do |spec|
81
+ gem_index = initializer.configuration.gems.inject({}) { |memo, gem| memo.update gem.specification => gem }
82
+ specs = gem_index.keys
83
+ specs += Gem.loaded_specs.values.select do |spec|
83
84
  spec.loaded_from && # prune stubs
84
85
  File.exist?(File.join(spec.full_gem_path, "rails", "init.rb"))
85
86
  end
@@ -91,7 +92,7 @@ module Rails
91
92
  deps.add(*specs) unless specs.empty?
92
93
 
93
94
  deps.dependency_order.collect do |spec|
94
- Rails::GemPlugin.new(spec)
95
+ Rails::GemPlugin.new(spec, gem_index[spec])
95
96
  end
96
97
  end
97
98
  end
@@ -2,7 +2,7 @@ module Rails
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -57,6 +57,17 @@ module Rails
57
57
  end
58
58
 
59
59
  protected
60
+ def current_migration_number
61
+ Dir.glob("#{RAILS_ROOT}/#{@migration_directory}/[0-9]*_*.rb").inject(0) do |max, file_path|
62
+ n = File.basename(file_path).split('_', 2).first.to_i
63
+ if n > max then n else max end
64
+ end
65
+ end
66
+
67
+ def next_migration_number
68
+ current_migration_number + 1
69
+ end
70
+
60
71
  def migration_directory(relative_path)
61
72
  directory(@migration_directory = relative_path)
62
73
  end
@@ -70,7 +81,11 @@ module Rails
70
81
  end
71
82
 
72
83
  def next_migration_string(padding = 3)
73
- Time.now.utc.strftime("%Y%m%d%H%M%S")
84
+ if ActiveRecord::Base.timestamped_migrations
85
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
86
+ else
87
+ "%.#{padding}d" % next_migration_number
88
+ end
74
89
  end
75
90
 
76
91
  def gsub_file(relative_destination, regexp, *args, &block)
@@ -88,7 +103,7 @@ module Rails
88
103
  Tempfile.open(File.basename(destination), File.dirname(dst)) do |temp|
89
104
  temp.write render_file(src, file_options, &block)
90
105
  temp.rewind
91
- $stdout.puts `#{diff_cmd} #{dst} #{temp.path}`
106
+ $stdout.puts `#{diff_cmd} "#{dst}" "#{temp.path}"`
92
107
  end
93
108
  puts "retrying"
94
109
  raise 'retry diff'
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class <%= class_name %>ObserverTest < Test::Unit::TestCase
3
+ class <%= class_name %>ObserverTest < ActiveSupport::TestCase
4
4
  # Replace this with your real tests.
5
5
  def test_truth
6
6
  assert true
@@ -108,7 +108,7 @@ module Rails
108
108
  sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators")
109
109
  Rails.configuration.plugin_paths.each do |path|
110
110
  relative_path = Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(::RAILS_ROOT))
111
- sources << PathSource.new(:"plugins (#{relative_path})", "#{path}/**/{,rails_}generators")
111
+ sources << PathSource.new(:"plugins (#{relative_path})", "#{path}/*/**/{,rails_}generators")
112
112
  end
113
113
  end
114
114
  sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators")
@@ -215,14 +215,14 @@ namespace :db do
215
215
  desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
216
216
  task :dump => :environment do
217
217
  require 'active_record/schema_dumper'
218
- File.open(ENV['SCHEMA'] || "db/schema.rb", "w") do |file|
218
+ File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb", "w") do |file|
219
219
  ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
220
220
  end
221
221
  end
222
222
 
223
223
  desc "Load a schema.rb file into the database"
224
224
  task :load => :environment do
225
- file = ENV['SCHEMA'] || "db/schema.rb"
225
+ file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb"
226
226
  load(file)
227
227
  end
228
228
  end
@@ -234,7 +234,7 @@ namespace :db do
234
234
  case abcs[RAILS_ENV]["adapter"]
235
235
  when "mysql", "oci", "oracle"
236
236
  ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
237
- File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
237
+ File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
238
238
  when "postgresql"
239
239
  ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
240
240
  ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
@@ -252,25 +252,27 @@ namespace :db do
252
252
  when "firebird"
253
253
  set_firebird_env(abcs[RAILS_ENV])
254
254
  db_string = firebird_db_string(abcs[RAILS_ENV])
255
- sh "isql -a #{db_string} > db/#{RAILS_ENV}_structure.sql"
255
+ sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql"
256
256
  else
257
257
  raise "Task not supported by '#{abcs["test"]["adapter"]}'"
258
258
  end
259
259
 
260
260
  if ActiveRecord::Base.connection.supports_migrations?
261
- File.open("db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
261
+ File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
262
262
  end
263
263
  end
264
264
  end
265
265
 
266
266
  namespace :test do
267
- desc "Recreate the test database from the current environment's database schema"
268
- task :clone => %w(db:schema:dump db:test:purge) do
267
+ desc "Recreate the test database from the current schema.rb"
268
+ task :load => 'db:test:purge' do
269
269
  ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
270
270
  ActiveRecord::Schema.verbose = false
271
271
  Rake::Task["db:schema:load"].invoke
272
272
  end
273
273
 
274
+ desc "Recreate the test database from the current environment's database schema"
275
+ task :clone => %w(db:schema:dump db:test:load)
274
276
 
275
277
  desc "Recreate the test databases from the development structure"
276
278
  task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
@@ -279,28 +281,28 @@ namespace :db do
279
281
  when "mysql"
280
282
  ActiveRecord::Base.establish_connection(:test)
281
283
  ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
282
- IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
284
+ IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
283
285
  ActiveRecord::Base.connection.execute(table)
284
286
  end
285
287
  when "postgresql"
286
288
  ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
287
289
  ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
288
290
  ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
289
- `psql -U "#{abcs["test"]["username"]}" -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
291
+ `psql -U "#{abcs["test"]["username"]}" -f #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
290
292
  when "sqlite", "sqlite3"
291
293
  dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"]
292
- `#{abcs["test"]["adapter"]} #{dbfile} < db/#{RAILS_ENV}_structure.sql`
294
+ `#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql`
293
295
  when "sqlserver"
294
296
  `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
295
297
  when "oci", "oracle"
296
298
  ActiveRecord::Base.establish_connection(:test)
297
- IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
299
+ IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
298
300
  ActiveRecord::Base.connection.execute(ddl)
299
301
  end
300
302
  when "firebird"
301
303
  set_firebird_env(abcs["test"])
302
304
  db_string = firebird_db_string(abcs["test"])
303
- sh "isql -i db/#{RAILS_ENV}_structure.sql #{db_string}"
305
+ sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}"
304
306
  else
305
307
  raise "Task not supported by '#{abcs["test"]["adapter"]}'"
306
308
  end
@@ -337,10 +339,10 @@ namespace :db do
337
339
  end
338
340
  end
339
341
 
340
- desc 'Prepare the test database and load the schema'
341
- task :prepare => %w(environment db:abort_if_pending_migrations) do
342
+ desc 'Check for pending migrations and load the test schema'
343
+ task :prepare => 'db:abort_if_pending_migrations' do
342
344
  if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
343
- Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
345
+ Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:load" }[ActiveRecord::Base.schema_format]].invoke
344
346
  end
345
347
  end
346
348
  end
@@ -1,9 +1,9 @@
1
1
  namespace :doc do
2
- desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb"
2
+ desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
3
3
  Rake::RDocTask.new("app") { |rdoc|
4
4
  rdoc.rdoc_dir = 'doc/app'
5
5
  rdoc.template = ENV['template'] if ENV['template']
6
- rdoc.title = "Rails Application Documentation"
6
+ rdoc.title = ENV['title'] || "Rails Application Documentation"
7
7
  rdoc.options << '--line-numbers' << '--inline-source'
8
8
  rdoc.options << '--charset' << 'utf-8'
9
9
  rdoc.rdoc_files.include('doc/README_FOR_APP')
@@ -44,7 +44,7 @@ namespace :time do
44
44
  end
45
45
  end
46
46
  previous_offset = nil
47
- TimeZone.__send__(method).each do |zone|
47
+ ActiveSupport::TimeZone.__send__(method).each do |zone|
48
48
  if offset.nil? || offset == zone.utc_offset
49
49
  puts "\n* UTC #{zone.formatted_offset} *" unless zone.utc_offset == previous_offset
50
50
  puts zone.name
@@ -4,5 +4,5 @@ $VERBOSE = nil
4
4
  Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
5
5
 
6
6
  # Load any custom rakefile extensions
7
- Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
8
7
  Dir["#{RAILS_ROOT}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext }
8
+ Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-31 00:00:00 -07:00
12
+ date: 2008-09-04 00:00:00 +02:00
13
13
  default_executable: rails
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -23,48 +24,53 @@ dependencies:
23
24
  version:
24
25
  - !ruby/object:Gem::Dependency
25
26
  name: activesupport
27
+ type: :runtime
26
28
  version_requirement:
27
29
  version_requirements: !ruby/object:Gem::Requirement
28
30
  requirements:
29
31
  - - "="
30
32
  - !ruby/object:Gem::Version
31
- version: 2.1.0
33
+ version: 2.1.1
32
34
  version:
33
35
  - !ruby/object:Gem::Dependency
34
36
  name: activerecord
37
+ type: :runtime
35
38
  version_requirement:
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "="
39
42
  - !ruby/object:Gem::Version
40
- version: 2.1.0
43
+ version: 2.1.1
41
44
  version:
42
45
  - !ruby/object:Gem::Dependency
43
46
  name: actionpack
47
+ type: :runtime
44
48
  version_requirement:
45
49
  version_requirements: !ruby/object:Gem::Requirement
46
50
  requirements:
47
51
  - - "="
48
52
  - !ruby/object:Gem::Version
49
- version: 2.1.0
53
+ version: 2.1.1
50
54
  version:
51
55
  - !ruby/object:Gem::Dependency
52
56
  name: actionmailer
57
+ type: :runtime
53
58
  version_requirement:
54
59
  version_requirements: !ruby/object:Gem::Requirement
55
60
  requirements:
56
61
  - - "="
57
62
  - !ruby/object:Gem::Version
58
- version: 2.1.0
63
+ version: 2.1.1
59
64
  version:
60
65
  - !ruby/object:Gem::Dependency
61
66
  name: activeresource
67
+ type: :runtime
62
68
  version_requirement:
63
69
  version_requirements: !ruby/object:Gem::Requirement
64
70
  requirements:
65
71
  - - "="
66
72
  - !ruby/object:Gem::Version
67
- version: 2.1.0
73
+ version: 2.1.1
68
74
  version:
69
75
  description: Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates.
70
76
  email: david@loudthinking.com
@@ -346,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
346
352
  requirements: []
347
353
 
348
354
  rubyforge_project: rails
349
- rubygems_version: 1.0.1
355
+ rubygems_version: 1.2.0
350
356
  signing_key:
351
357
  specification_version: 2
352
358
  summary: Web-application framework with template engine, control-flow layer, and ORM.