提交 de2cd8e3 编写于 作者: J Joshua Peek

Merge branch 'master' of github.com:rails/rails

......@@ -7,16 +7,9 @@ activerecord/doc
actionpack/doc
actionmailer/doc
activesupport/doc
activemodel/pkg
activeresource/pkg
activerecord/pkg
actionpack/pkg
activemodel/test/fixtures/fixture_database.sqlite3
actionmailer/pkg
activesupport/pkg
actionpack/test/tmp
activesupport/test/fixtures/isolation_test
railties/pkg
railties/test/500.html
railties/test/fixtures/tmp
railties/test/initializer/root/log
......@@ -31,3 +24,4 @@ railties/guides/output
bin
vendor/gems/
railties/tmp
pkg
[submodule "arel"]
path = arel
url = git://github.com/rails/arel.git
[submodule "rack"]
path = rack
url = git://github.com/rails/rack.git
require 'rake'
require 'rake/rdoctask'
require 'rake/gempackagetask'
env = %(PKG_BUILD="#{ENV['PKG_BUILD']}") if ENV['PKG_BUILD']
PROJECTS = %w(activesupport actionpack actionmailer activeresource activerecord activemodel railties)
PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
Dir["#{File.dirname(__FILE__)}/*/lib/*/version.rb"].each do |version_path|
require version_path
......@@ -23,11 +24,21 @@ task :default => %w(test test:isolated)
end
end
spec = eval(File.read('rails.gemspec'))
Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
task :install => :gem do
system %(cd arel && gem build arel.gemspec && gem install arel-0.2.pre.gem --no-ri --no-rdoc --ignore-dependencies)
system %(cd rack && rake gem VERSION=1.0.2.pre && gem install rack-1.0.2.pre.gem --no-ri --no-rdoc --ignore-dependencies)
(PROJECTS - ["railties"]).each do |project|
puts "INSTALLING #{project}"
system("gem install #{project}/pkg/#{project}-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc")
end
system("gem install railties/pkg/rails-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc")
system("gem install railties/pkg/railties-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc")
system("gem install pkg/rails-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc")
end
desc "Generate documentation for the Rails framework"
......
Subproject commit adf996587aecdd604eff441b8b69e4c47a8c2617
......@@ -8,22 +8,16 @@
on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates.
EOF
s.add_dependency('rake', '>= 0.8.3')
s.add_dependency('activesupport', '= 3.0.pre')
s.add_dependency('activerecord', '= 3.0.pre')
s.add_dependency('actionpack', '= 3.0.pre')
s.add_dependency('actionmailer', '= 3.0.pre')
s.add_dependency('activerecord', '= 3.0.pre')
s.add_dependency('activeresource', '= 3.0.pre')
s.add_dependency('actionmailer', '= 3.0.pre')
s.add_dependency('railties', '= 3.0.pre')
s.rdoc_options << '--exclude' << '.'
s.has_rdoc = false
s.files = Dir['CHANGELOG', 'README', 'bin/**/*', 'builtin/**/*', 'guides/**/*', 'lib/**/{*,.[a-z]*}']
s.require_path = 'lib'
s.bindir = "bin"
s.executables = ["rails"]
s.default_executable = "rails"
s.author = "David Heinemeier Hansson"
s.email = "david@loudthinking.com"
s.homepage = "http://www.rubyonrails.org"
......
......@@ -10,7 +10,7 @@ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
require 'rails/version'
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
PKG_NAME = ENV['PKG_NAME'] || 'rails'
PKG_NAME = ENV['PKG_NAME'] || 'railties'
PKG_VERSION = Rails::VERSION::STRING + PKG_BUILD
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
......@@ -141,7 +141,7 @@ Rake::RDocTask.new { |rdoc|
# Generate GEM ----------------------------------------------------------------------------
spec = eval(File.read('rails.gemspec'))
spec = eval(File.read('railties.gemspec'))
Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
......
require "pathname"
require 'active_support'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/logger'
require 'rails/initializable'
require 'rails/application'
require 'rails/railties_path'
......@@ -10,4 +14,19 @@
require 'rails/configuration'
require 'rails/deprecation'
require 'rails/initializer'
require 'rails/plugin'
\ No newline at end of file
require 'rails/plugin'
require 'rails/ruby_version_check'
# For Ruby 1.8, this initialization sets $KCODE to 'u' to enable the
# multibyte safe operations. Plugin authors supporting other encodings
# should override this behaviour and set the relevant +default_charset+
# on ActionController::Base.
#
# For Ruby 1.9, UTF-8 is the default internal and external encoding.
if RUBY_VERSION < '1.9'
$KCODE='u'
else
Encoding.default_external = Encoding::UTF_8
end
RAILS_ENV = (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").dup unless defined?(RAILS_ENV)
\ No newline at end of file
......@@ -82,8 +82,21 @@ def call(env)
@app.call(env)
end
initializer :initialize_rails do
Rails.run_initializers
# Loads the environment specified by Configuration#environment_path, which
# is typically one of development, test, or production.
initializer :load_environment do
next unless File.file?(config.environment_path)
config = self.config
Kernel.class_eval do
meth = instance_method(:config) if Object.respond_to?(:config)
define_method(:config) { config }
require config.environment_path
remove_method :config
define_method(:config, &meth) if meth
end
end
# Set the <tt>$LOAD_PATH</tt> based on the value of
......@@ -97,18 +110,8 @@ def call(env)
# list. By default, all frameworks (Active Record, Active Support,
# Action Pack, Action Mailer, and Active Resource) are loaded.
initializer :require_frameworks do
begin
require 'active_support'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/logger'
# TODO: This is here to make Sam Ruby's tests pass. Needs discussion.
require 'active_support/core_ext/numeric/bytes'
config.frameworks.each { |framework| require(framework.to_s) }
rescue LoadError => e
# Re-raise as RuntimeError because Mongrel would swallow LoadError.
raise e.to_s
end
require 'active_support/all' unless config.active_support.bare
config.frameworks.each { |framework| require(framework.to_s) }
end
# Set the paths from which Rails will automatically load source files, and
......@@ -137,24 +140,6 @@ def call(env)
end
end
# Loads the environment specified by Configuration#environment_path, which
# is typically one of development, test, or production.
initializer :load_environment do
silence_warnings do
next if @environment_loaded
next unless File.file?(config.environment_path)
@environment_loaded = true
constants = self.class.constants
eval(IO.read(config.environment_path), binding, config.environment_path)
(self.class.constants - constants).each do |const|
Object.const_set(const, self.class.const_get(const))
end
end
end
# Preload all frameworks specified by the Configuration#frameworks.
# Used by Passenger to ensure everything's loaded before forking and
# to avoid autoload race conditions in JRuby.
......@@ -312,9 +297,6 @@ def call(env)
base_class.send("#{setting}=", value)
end
end
config.active_support.each do |setting, value|
ActiveSupport.send("#{setting}=", value)
end
end
# Sets +ActionController::Base#view_paths+ and +ActionMailer::Base#template_root+
......
......@@ -41,9 +41,9 @@ def self.start(app)
new(app).start
end
def initialize(app)
def initialize(app_const)
super() # Call Rack::Server#initialize without passing any options to use.
@app = app
@app_const = app_const
end
def start
......@@ -69,7 +69,7 @@ def middleware
end
def log_path
"#{File.expand_path(@app.root)}/log/#{options[:environment]}.log"
"#{File.expand_path(@app_const.root)}/log/#{options[:environment]}.log"
end
def default_options
......@@ -77,10 +77,10 @@ def default_options
:Port => 3000,
:Host => "0.0.0.0",
:environment => (ENV['RAILS_ENV'] || "development").dup,
:rack_file => "#{@app.root}/config.ru",
:rack_file => "#{@app_const.root}/config.ru",
:daemonize => false,
:debugger => false,
:pid => "#{@app.root}/tmp/pids/server.pid",
:pid => "#{@app_const.root}/tmp/pids/server.pid",
:AccessLog => []
}
end
......
......@@ -106,26 +106,4 @@ def run_initializers(*args)
end
end
end
include Initializable
# Check for valid Ruby version (1.8.2 or 1.8.4 or higher). This is done in an
# external file, so we can use it from the `rails` program as well without duplication.
initializer :check_ruby_version, :global => true do
require 'rails/ruby_version_check'
end
# For Ruby 1.8, this initialization sets $KCODE to 'u' to enable the
# multibyte safe operations. Plugin authors supporting other encodings
# should override this behaviour and set the relevant +default_charset+
# on ActionController::Base.
#
# For Ruby 1.9, UTF-8 is the default internal and external encoding.
initializer :initialize_encoding, :global => true do
if RUBY_VERSION < '1.9'
$KCODE='u'
else
Encoding.default_external = Encoding::UTF_8
end
end
end
\ No newline at end of file
require "rails" # In case people require this file directly
RAILS_ENV = (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development').dup unless defined?(RAILS_ENV)
module Rails
class Initializer
class Error < StandardError ; end
......
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'railties'
s.version = '3.0.pre'
s.summary = "Controls boot-up, rake tasks and generators for the Rails framework."
s.description = <<-EOF
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.
EOF
s.add_dependency('rake', '>= 0.8.3')
s.add_dependency('activesupport', '= 3.0.pre')
s.add_dependency('actionpack', '= 3.0.pre')
s.rdoc_options << '--exclude' << '.'
s.has_rdoc = false
s.files = Dir['CHANGELOG', 'README', 'bin/**/*', 'builtin/**/*', 'guides/**/*', 'lib/**/{*,.[a-z]*}']
s.require_path = 'lib'
s.bindir = "bin"
s.executables = ["rails"]
s.default_executable = "rails"
s.author = "David Heinemeier Hansson"
s.email = "david@loudthinking.com"
s.homepage = "http://www.rubyonrails.org"
s.rubyforge_project = "rails"
end
......@@ -44,5 +44,14 @@ def setup
assert_equal Pathname.new("#{app_path}/app"), Rails.application.root
end
end
test "config.active_support.bare does not require all of ActiveSupport" do
add_to_config "config.frameworks = []; config.active_support.bare = true"
Dir.chdir("#{app_path}/app") do
require "#{app_path}/config/environment"
assert_raises(NoMethodError, /day/) { 1.day }
end
end
end
end
\ No newline at end of file
......@@ -11,8 +11,16 @@ def setup
require "rails/generators"
end
def app_const
@app_const ||= Class.new(Rails::Application)
end
def with_config
yield app_const.config
end
test "generators default values" do
Rails::Initializer.run do |c|
with_config do |c|
assert_equal(true, c.generators.colorize_logging)
assert_equal({}, c.generators.aliases)
assert_equal({}, c.generators.options)
......@@ -20,7 +28,7 @@ def setup
end
test "generators set rails options" do
Rails::Initializer.run do |c|
with_config do |c|
c.generators.orm = :datamapper
c.generators.test_framework = :rspec
c.generators.helper = false
......@@ -30,7 +38,7 @@ def setup
end
test "generators set rails aliases" do
Rails::Initializer.run do |c|
with_config do |c|
c.generators.aliases = { :rails => { :test_framework => "-w" } }
expected = { :rails => { :test_framework => "-w" } }
assert_equal expected, c.generators.aliases
......@@ -38,14 +46,14 @@ def setup
end
test "generators aliases and options on initialization" do
Rails::Initializer.run do |c|
application = with_config do |c|
c.frameworks = []
c.generators.rails :aliases => { :test_framework => "-w" }
c.generators.orm :datamapper
c.generators.test_framework :rspec
end
# Initialize the application
Rails.initialize!
app_const.initialize!
Rails::Generators.configure!
assert_equal :rspec, Rails::Generators.options[:rails][:test_framework]
......@@ -53,19 +61,19 @@ def setup
end
test "generators no color on initialization" do
Rails::Initializer.run do |c|
with_config do |c|
c.frameworks = []
c.generators.colorize_logging = false
end
# Initialize the application
Rails.initialize!
app_const.initialize!
Rails::Generators.configure!
assert_equal Thor::Base.shell, Thor::Shell::Basic
end
test "generators with hashes for options and aliases" do
Rails::Initializer.run do |c|
with_config do |c|
c.generators do |g|
g.orm :datamapper, :migration => false
g.plugin :aliases => { :generator => "-g" },
......@@ -84,7 +92,7 @@ def setup
end
test "generators with hashes are deep merged" do
Rails::Initializer.run do |c|
with_config do |c|
c.generators do |g|
g.orm :datamapper, :migration => false
g.plugin :aliases => { :generator => "-g" },
......
......@@ -10,22 +10,6 @@ def setup
require "rails"
end
test "initializing an application initializes rails" do
Rails::Initializer.run do |config|
config.root = app_path
end
if RUBY_VERSION < '1.9'
$KCODE = ''
Rails.initialize!
assert_equal 'UTF8', $KCODE
else
Encoding.default_external = Encoding::US_ASCII
Rails.initialize!
assert_equal Encoding::UTF_8, Encoding.default_external
end
end
test "initializing an application adds the application paths to the load path" do
Rails::Initializer.run do |config|
config.root = app_path
......@@ -41,7 +25,9 @@ def setup
config.frameworks << :action_foo
end
assert_raises RuntimeError do
require "active_support/core_ext/load_error"
assert_raises MissingSourceFile do
Rails.initialize!
end
end
......
......@@ -7,7 +7,6 @@ class PathsTest < Test::Unit::TestCase
def setup
build_app
boot_rails
require "rails"
end
test "rails does not initialize with ruby version 1.8.1" do
......@@ -50,8 +49,7 @@ def set_ruby_version(version)
def assert_rails_boots(version = nil)
set_ruby_version(version) if version
assert_nothing_raised "It appears that rails does not boot" do
Rails::Initializer.run { |c| c.frameworks = [] }
Rails.initialize!
require "rails"
end
end
......@@ -59,8 +57,7 @@ def assert_rails_does_not_boot(version)
set_ruby_version(version)
$stderr = File.open("/dev/null", "w")
assert_raises(SystemExit) do
Rails::Initializer.run { |c| c.frameworks = [] }
Rails.initialize!
require "rails"
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册