Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7964

Show
Ignore:
Timestamp:
10/18/07 17:28:55 (11 months ago)
Author:
bitsweat
Message:

Merge [7832] from 1-2-stable: Correct RAILS_GEM_VERSION regexp. Use =version gem requirement instead of ~>version so you don't get surprised by a beta gem in production.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/environments/boot.rb

    r6445 r7964  
    99    require 'rubygems' 
    1010 
    11     environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join 
    12     environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/ 
    13     rails_gem_version = $1 
     11    rails_gem_version = 
     12      if defined? RAILS_GEM_VERSION 
     13        RAILS_GEM_VERSION 
     14      else 
     15        File.read("#{File.dirname(__FILE__)}/environment.rb") =~ /^[^#]*RAILS_GEM_VERSION\s+=\s+'([\d.]+)'/ 
     16        $1 
     17      end 
    1418 
    15     if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version 
    16       # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems 
    17       rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last 
     19    if rails_gem_version 
     20      rails_gem = Gem.cache.search('rails', "=#{rails_gem_version}.0").sort_by { |g| g.version.version }.last 
    1821 
    1922      if rails_gem 
     
    2124        require rails_gem.full_gem_path + '/lib/initializer' 
    2225      else 
    23         STDERR.puts %(Cannot find gem for Rails ~>#{version}.0: 
    24     Install the missing gem with 'gem install -v=#{version} rails', or 
     26        STDERR.puts %(Cannot find gem for Rails =#{rails_gem_version}.0: 
     27    Install the missing gem with 'gem install -v=#{rails_gem_version} rails', or 
    2528    change environment.rb to define RAILS_GEM_VERSION with your desired version. 
    2629  )