diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-06-02 12:29:28 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-06-02 12:29:28 +0100 |
commit | 719aa13b0781d662673dba2225bc707fc4182b5e (patch) | |
tree | 057cabf17152a1ab0ccc749dd361eeaf754c38de /railties/lib/rails | |
parent | ad3c97cea6dd0714652db7d9b5b4d06b81e5c035 (diff) | |
parent | a980eb8c7734f14109d8c2a02a88dafdf682e0dc (diff) | |
download | rails-719aa13b0781d662673dba2225bc707fc4182b5e.tar.gz rails-719aa13b0781d662673dba2225bc707fc4182b5e.tar.bz2 rails-719aa13b0781d662673dba2225bc707fc4182b5e.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/gem_dependency.rb | 15 | ||||
-rw-r--r-- | railties/lib/rails/plugin.rb | 17 | ||||
-rw-r--r-- | railties/lib/rails/rack.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/rack/static.rb | 35 | ||||
-rw-r--r-- | railties/lib/rails/version.rb | 4 |
5 files changed, 59 insertions, 17 deletions
diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index 2034841cd2..9f088a18dd 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -31,12 +31,13 @@ module Rails args << @requirement.to_s if @requirement gem *args else - $LOAD_PATH << File.join(unpacked_paths.first, 'lib') + $LOAD_PATH.unshift File.join(unpacked_paths.first, 'lib') + ext = File.join(unpacked_paths.first, 'ext') + $LOAD_PATH.unshift(ext) if File.exist?(ext) @frozen = true end @load_paths_added = true rescue Gem::LoadError - puts $!.to_s end def dependencies @@ -73,7 +74,9 @@ module Rails end def install - Gem::GemRunner.new.run(install_command) + cmd = "#{gem_command} #{install_command.join(' ')}" + puts cmd + puts %x(#{cmd}) end def unpack_to(directory) @@ -100,10 +103,14 @@ private ################################################################### def specification @spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last end + + def gem_command + RUBY_PLATFORM =~ /win32/ ? 'gem.bat' : 'gem' + end def install_command cmd = %w(install) << @name - cmd << "--version" << "#{@requirement.to_s}" if @requirement + cmd << "--version" << %("#{@requirement.to_s}") if @requirement cmd << "--source" << @source if @source cmd end diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 04f7e37a20..256f4b0132 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -98,23 +98,18 @@ module Rails end end - # This Plugin subclass represents a Gem plugin. It behaves exactly like a - # "traditional" Rails plugin, but doesn't expose any additional load paths, - # since RubyGems has already taken care of things. + # This Plugin subclass represents a Gem plugin. Although RubyGems has already + # taken care of $LOAD_PATHs, it exposes its load_paths to add them + # to Dependencies.load_paths. class GemPlugin < Plugin - # Initialize this plugin from a Gem::Specification. def initialize(spec) - super(File.join(spec.full_gem_path, "rails")) + super(File.join(spec.full_gem_path)) @name = spec.name end - def valid? - true - end - - def load_paths - [] + def init_path + File.join(directory, 'rails', 'init.rb') end end end
\ No newline at end of file diff --git a/railties/lib/rails/rack.rb b/railties/lib/rails/rack.rb new file mode 100644 index 0000000000..abcd0741bf --- /dev/null +++ b/railties/lib/rails/rack.rb @@ -0,0 +1,5 @@ +module Rails + module Rack + autoload :Static, "rails/rack/static" + end +end diff --git a/railties/lib/rails/rack/static.rb b/railties/lib/rails/rack/static.rb new file mode 100644 index 0000000000..45eb0e5921 --- /dev/null +++ b/railties/lib/rails/rack/static.rb @@ -0,0 +1,35 @@ +module Rails + module Rack + class Static + FILE_METHODS = %w(GET HEAD).freeze + + def initialize(app) + @app = app + @file_server = ::Rack::File.new(File.join(RAILS_ROOT, "public")) + end + + def call(env) + path = env['PATH_INFO'].chomp('/') + method = env['REQUEST_METHOD'] + cached_path = (path.empty? ? 'index' : path) + ::ActionController::Base.page_cache_extension + + if FILE_METHODS.include?(method) + if file_exist?(path) + return @file_server.call(env) + elsif file_exist?(cached_path) + env['PATH_INFO'] = cached_path + return @file_server.call(env) + end + end + + @app.call(env) + end + + private + def file_exist?(path) + full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path)) + File.file?(full_path) && File.readable?(full_path) + end + end + end +end diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb index fea63beea9..48d24da52e 100644 --- a/railties/lib/rails/version.rb +++ b/railties/lib/rails/version.rb @@ -1,8 +1,8 @@ module Rails module VERSION #:nodoc: MAJOR = 2 - MINOR = 0 - TINY = 991 + MINOR = 1 + TINY = 0 STRING = [MAJOR, MINOR, TINY].join('.') end |