aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-04-01 06:29:32 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-04-01 06:29:32 +0000
commitd08f838c0e4d626a1b78c7799e0cad878ce4943c (patch)
tree4912c4fcf6ee7da1b0c1635ae16e344985a95d48
parent237cc945bb82c3428b85646fe1688fe61d4cc535 (diff)
downloadrails-d08f838c0e4d626a1b78c7799e0cad878ce4943c.tar.gz
rails-d08f838c0e4d626a1b78c7799e0cad878ce4943c.tar.bz2
rails-d08f838c0e4d626a1b78c7799e0cad878ce4943c.zip
Added -f/--freeze option to rails command for freezing the application to the Rails version it was generated with [DHH] Fixed rake rails:freeze:gems (closes #4518) [benji@silverinsanity.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4115 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--railties/CHANGELOG8
-rwxr-xr-xrailties/bin/rails5
-rw-r--r--railties/environments/environment.rb2
-rw-r--r--railties/lib/rails_generator/generators/applications/app/app_generator.rb8
-rw-r--r--railties/lib/tasks/framework.rake2
5 files changed, 19 insertions, 6 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 6abdbf8347..875bc527a6 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,8 +1,12 @@
*SVN*
-* Make Rails::VERSION implicitly loadable. Closes #4491. [Nicholas Seckar]
+* Make Rails::VERSION implicitly loadable #4491. [Nicholas Seckar]
-* Teach Rails apps to only load gems of the same Rails version they were generated with. [Nicholas Seckar]
+* Fixed rake rails:freeze:gems #4518 [benji@silverinsanity.com]
+
+* Added -f/--freeze option to rails command for freezing the application to the Rails version it was generated with [DHH]
+
+* Added gem binding of apps generated through the rails command to the gems of they were generated with [Nicholas Seckar]
* Added expiration settings for JavaScript, CSS, HTML, and images to default lighttpd.conf [DHH]
diff --git a/railties/bin/rails b/railties/bin/rails
index 5c03eed58f..d83f5b8b8e 100755
--- a/railties/bin/rails
+++ b/railties/bin/rails
@@ -4,8 +4,13 @@ Signal.trap("INT") { puts; exit }
require File.dirname(__FILE__) + '/../lib/rails/version'
abort "Rails #{Rails::VERSION::STRING}" if %w(--version -v).include? ARGV.first
+freeze = ARGV.any? { |option| %w(--freeze -f).include?(option) }
+app_path = ARGV.first
+
require File.dirname(__FILE__) + '/../lib/rails_generator'
require 'rails_generator/scripts/generate'
Rails::Generator::Base.use_application_sources!
Rails::Generator::Scripts::Generate.new.run(ARGV, :generator => 'app')
+
+Dir.chdir(app_path) { `rake rails:freeze:gems`; puts "froze" } if freeze \ No newline at end of file
diff --git a/railties/environments/environment.rb b/railties/environments/environment.rb
index 5fbceb69dc..839da1c53d 100644
--- a/railties/environments/environment.rb
+++ b/railties/environments/environment.rb
@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '<%= Rails::VERSION::STRING %>'
+<%= '# ' if freeze %>RAILS_GEM_VERSION = '<%= Rails::VERSION::STRING %>'
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
index 145f354052..b07133240b 100644
--- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb
+++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -6,7 +6,7 @@ class AppGenerator < Rails::Generator::Base
DATABASES = %w( mysql oracle postgresql sqlite2 sqlite3 )
- default_options :db => "mysql", :shebang => DEFAULT_SHEBANG
+ default_options :db => "mysql", :shebang => DEFAULT_SHEBANG, :freeze => false
mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
def initialize(runtime_args, runtime_options = {})
@@ -44,7 +44,7 @@ class AppGenerator < Rails::Generator::Base
# Environments
m.file "environments/boot.rb", "config/boot.rb"
- m.template "environments/environment.rb", "config/environment.rb"
+ m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] }
m.file "environments/production.rb", "config/environments/production.rb"
m.file "environments/development.rb", "config/environments/development.rb"
m.file "environments/test.rb", "config/environments/test.rb"
@@ -100,6 +100,10 @@ class AppGenerator < Rails::Generator::Base
opt.on("-d", "--database=name", String,
"Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite2/sqlite3).",
"Default: mysql") { |options[:db]| }
+
+ opt.on("-f", "--freeze",
+ "Freeze Rails in vendor/rails from the gems generating the skeleton",
+ "Default: false") { |options[:freeze]| }
end
def mysql_socket_location
diff --git a/railties/lib/tasks/framework.rake b/railties/lib/tasks/framework.rake
index c837b73922..ff2bd78edb 100644
--- a/railties/lib/tasks/framework.rake
+++ b/railties/lib/tasks/framework.rake
@@ -6,7 +6,7 @@ namespace :rails do
require 'rubygems'
Gem.manage_gems
- rails = version = ENV['VERSION'] ?
+ rails = (version = ENV['VERSION']) ?
Gem.cache.search('rails', "= #{version}").first :
Gem.cache.search('rails').sort_by { |g| g.version }.last