diff options
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Rakefile | 15 | ||||
m--------- | rack | 0 | ||||
-rw-r--r-- | rails.gemspec (renamed from railties/rails.gemspec) | 12 | ||||
-rw-r--r-- | railties/Rakefile | 4 | ||||
-rw-r--r-- | railties/lib/rails.rb | 21 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 52 | ||||
-rw-r--r-- | railties/lib/rails/commands/server.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/initializable.rb | 22 | ||||
-rw-r--r-- | railties/lib/rails/initializer.rb | 2 | ||||
-rw-r--r-- | railties/railties.gemspec | 28 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 9 | ||||
-rw-r--r-- | railties/test/application/generators_test.rb | 26 | ||||
-rw-r--r-- | railties/test/application/initializer_test.rb | 20 | ||||
-rw-r--r-- | railties/test/initializer/check_ruby_version_test.rb | 7 |
16 files changed, 123 insertions, 116 deletions
diff --git a/.gitignore b/.gitignore index 70b7c0057a..9a65e4996f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.gitmodules b/.gitmodules index fd4fd34d3e..d0be7ff194 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "arel"] path = arel url = git://github.com/rails/arel.git +[submodule "rack"] + path = rack + url = git://github.com/rails/rack.git @@ -1,9 +1,10 @@ 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" diff --git a/rack b/rack new file mode 160000 +Subproject adf996587aecdd604eff441b8b69e4c47a8c261 diff --git a/railties/rails.gemspec b/rails.gemspec index dc66e1efea..878a342903 100644 --- a/railties/rails.gemspec +++ b/rails.gemspec @@ -8,22 +8,16 @@ Gem::Specification.new do |s| 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" diff --git a/railties/Rakefile b/railties/Rakefile index e6f698fc74..cb482c90bf 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -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 diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index c23b67e321..b7cae9a9ac 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -1,5 +1,9 @@ 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/core' 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 diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 73198d68ca..110311558c 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -82,8 +82,21 @@ module Rails @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 @@ module Rails # 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 @@ module Rails 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 @@ module Rails 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+ diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 57b7c6a49c..3687b4460e 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -41,9 +41,9 @@ module Rails 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 @@ module Rails 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 @@ module Rails :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 diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb index 3866b856b2..96234739cf 100644 --- a/railties/lib/rails/initializable.rb +++ b/railties/lib/rails/initializable.rb @@ -106,26 +106,4 @@ module Rails 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 diff --git a/railties/lib/rails/initializer.rb b/railties/lib/rails/initializer.rb index 44101dcc94..95478428ec 100644 --- a/railties/lib/rails/initializer.rb +++ b/railties/lib/rails/initializer.rb @@ -1,7 +1,5 @@ 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 diff --git a/railties/railties.gemspec b/railties/railties.gemspec new file mode 100644 index 0000000000..a060c3c301 --- /dev/null +++ b/railties/railties.gemspec @@ -0,0 +1,28 @@ +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 diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index a3e1916494..fc21d4e5fd 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -44,5 +44,14 @@ module ApplicationTests 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 diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index ccbcd84176..2ed49d1057 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -11,8 +11,16 @@ module ApplicationTests 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 @@ module ApplicationTests 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 @@ module ApplicationTests 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 @@ module ApplicationTests 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 @@ module ApplicationTests 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 @@ module ApplicationTests 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" }, diff --git a/railties/test/application/initializer_test.rb b/railties/test/application/initializer_test.rb index 719520bf68..56582c5772 100644 --- a/railties/test/application/initializer_test.rb +++ b/railties/test/application/initializer_test.rb @@ -10,22 +10,6 @@ module ApplicationTests 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 @@ module ApplicationTests config.frameworks << :action_foo end - assert_raises RuntimeError do + require "active_support/core_ext/load_error" + + assert_raises MissingSourceFile do Rails.initialize! end end diff --git a/railties/test/initializer/check_ruby_version_test.rb b/railties/test/initializer/check_ruby_version_test.rb index 97d884e1be..0691caad9d 100644 --- a/railties/test/initializer/check_ruby_version_test.rb +++ b/railties/test/initializer/check_ruby_version_test.rb @@ -7,7 +7,6 @@ module InitializerTests 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 @@ module InitializerTests 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 @@ module InitializerTests 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 |