Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged 1.3.7/ruby-core changes to master

  • Loading branch information...
commit 36e6afff7bb3c14e03a71c1cf1a61c03a7da685c 1 parent 124dfbc
@zenspider zenspider authored
View
2  lib/rbconfig/datadir.rb
@@ -9,5 +9,5 @@
# once.
warn 'rbconfig/datadir.rb and {Rb}Config.datadir is being deprecated from '\
- 'RubyGems. It will be removed completely on or after January 2011. If you '\
+ 'RubyGems. It will be removed completely on or after June 2011. If you '\
'wish to rely on a datadir, please use Gem.datadir.'
View
58 lib/rubygems.rb
@@ -5,21 +5,18 @@
# See LICENSE.txt for permissions.
#++
-gem_preluded = defined? Gem
+# TODO: remove when 1.9.1 no longer supported
+QUICKLOADER_SUCKAGE = RUBY_VERSION >= "1.9.1" and RUBY_VERSION < "1.9.2"
+# TODO: remove when 1.9.2 no longer supported
+GEM_PRELUDE_SUCKAGE = RUBY_VERSION >= "1.9.2" and RUBY_VERSION < "1.9.3"
-if defined?(Gem::QuickLoader) then
+gem_preluded = GEM_PRELUDE_SUCKAGE and defined? Gem
+
+if GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
Gem::QuickLoader.load_full_rubygems_library
class << Gem
remove_method :try_activate if Gem.respond_to?(:try_activate, true)
-
- def try_activate(path)
- spec = Gem.searcher.find(path)
- return false unless spec
-
- Gem.activate(spec.name, "= #{spec.version}")
- return true
- end
end
end
@@ -202,6 +199,19 @@ def version_requirement= requirement
@pre_install_hooks ||= []
##
+ # Try to activate a gem containing +path+. Returns true if
+ # activation succeeded or wasn't needed because it was already
+ # activated. Returns false if it can't find the path in a gem.
+
+ def self.try_activate path
+ spec = Gem.searcher.find path
+ return false unless spec
+
+ Gem.activate spec.name, "= #{spec.version}"
+ return true
+ end
+
+ ##
# Activates an installed gem matching +gem+. The gem must satisfy
# +requirements+.
#
@@ -644,11 +654,13 @@ def self.latest_partials(gemdir)
def self.load_path_insert_index
index = $LOAD_PATH.index ConfigMap[:sitelibdir]
- $LOAD_PATH.each_with_index do |path, i|
- if path.instance_variables.include?(:@gem_prelude_index) or
- path.instance_variables.include?('@gem_prelude_index') then
- index = i
- break
+ if QUICKLOADER_SUCKAGE then
+ $LOAD_PATH.each_with_index do |path, i|
+ if path.instance_variables.include?(:@gem_prelude_index) or
+ path.instance_variables.include?('@gem_prelude_index') then
+ index = i
+ break
+ end
end
end
@@ -974,7 +986,13 @@ def self.suffix_pattern
# Suffixes for require-able paths.
def self.suffixes
- ['', '.rb', '.rbw', '.so', '.bundle', '.dll', '.sl', '.jar']
+ @suffixes ||= ['',
+ '.rb',
+ *%w(DLEXT DLEXT2).map { |key|
+ val = RbConfig::CONFIG[key]
+ ".#{val}" unless val.empty?
+ }
+ ].compact.uniq
end
##
@@ -1131,7 +1149,7 @@ class << self
module Kernel
- undef gem if respond_to? :gem # defined in gem_prelude.rb on 1.9
+ remove_method :gem if respond_to? :gem # defined in gem_prelude.rb on 1.9
##
# Use Kernel#gem to activate a specific version of +gem_name+.
@@ -1176,14 +1194,14 @@ def gem(gem_name, *requirements) # :doc:
# "#{ConfigMap[:datadir]}/#{package_name}".
def RbConfig.datadir(package_name)
- require 'rbconfig/datadir' # TODO Deprecate after January 2010.
+ require 'rbconfig/datadir' # TODO Deprecate after June 2010.
Gem.datadir(package_name) ||
File.join(Gem::ConfigMap[:datadir], package_name)
end
require 'rubygems/exceptions'
-unless gem_preluded then
+unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
begin
##
# Defaults the operating system (or packager) wants to provide for RubyGems.
@@ -1209,7 +1227,7 @@ def RbConfig.datadir(package_name)
# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem
# constant at rubygems.rb load time.
-require 'rubygems/custom_require' unless gem_preluded and RUBY_VERSION > '1.9'
+require 'rubygems/custom_require' unless RUBY_VERSION > '1.9'
Gem.clear_paths
View
38 lib/rubygems/config_file.rb
@@ -47,23 +47,29 @@ class Gem::ConfigFile
system_config_path =
begin
- require 'Win32API'
-
- CSIDL_COMMON_APPDATA = 0x0023
- path = 0.chr * 260
- if RUBY_VERSION > '1.9' then
- SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP',
- 'L', :stdcall
- SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
- else
- SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP',
- 'L'
- SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
+ require "etc"
+ Etc.sysconfdir
+ rescue LoadError, NoMethodError
+ begin
+ # TODO: remove after we drop 1.8.7 and 1.9.1
+ require 'Win32API'
+
+ CSIDL_COMMON_APPDATA = 0x0023
+ path = 0.chr * 260
+ if RUBY_VERSION > '1.9' then
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP',
+ 'L', :stdcall
+ SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
+ else
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP',
+ 'L'
+ SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
+ end
+
+ path.strip
+ rescue LoadError
+ "/etc"
end
-
- path.strip
- rescue LoadError
- '/etc'
end
SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
View
10 lib/rubygems/custom_require.rb
@@ -28,13 +28,11 @@ module Kernel
def require(path) # :doc:
gem_original_require path
rescue LoadError => load_error
- if load_error.message =~ /#{Regexp.escape path}\z/ and
- spec = Gem.searcher.find(path) then
- Gem.activate(spec.name, "= #{spec.version}")
- gem_original_require path
- else
- raise load_error
+ if load_error.message.end_with?(path) and Gem.try_activate(path) then
+ return gem_original_require(path)
end
+
+ raise load_error
end
private :require
View
4 lib/rubygems/installer.rb
@@ -38,7 +38,7 @@ class ExtensionBuildError < Gem::InstallError; end
include Gem::UserInteraction
- include Gem::RequirePathsBuilder
+ include Gem::RequirePathsBuilder if QUICKLOADER_SUCKAGE
##
# The directory a gem's executables will be installed into
@@ -198,7 +198,7 @@ def install
build_extensions
write_spec
- write_require_paths_file_if_needed
+ write_require_paths_file_if_needed if QUICKLOADER_SUCKAGE
# HACK remove? Isn't this done in multiple places?
cached_gem = File.join @gem_home, "cache", @gem.split(/\//).pop
View
3  lib/rubygems/require_paths_builder.rb
@@ -1,5 +1,6 @@
require 'rubygems'
+# TODO: remove after 1.9.1 dropped
module Gem::RequirePathsBuilder
def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home)
return if spec.require_paths == ["lib"] &&
@@ -13,5 +14,5 @@ def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home)
file.puts spec.bindir if spec.bindir
end
end
-end
+end if QUICKLOADER_SUCKAGE
View
27 lib/rubygems/test_utilities.rb
@@ -131,30 +131,17 @@ def self.fetcher=(fetcher)
#--
# This class was added to flush out problems in Rubinius' IO implementation.
-class TempIO
-
- @@count = 0
-
+class TempIO < Tempfile
def initialize(string = '')
- @tempfile = Tempfile.new "TempIO-#{@@count += 1}"
- @tempfile.binmode
- @tempfile.write string
- @tempfile.rewind
- end
-
- def method_missing(meth, *args, &block)
- @tempfile.send(meth, *args, &block)
- end
-
- def respond_to?(meth)
- @tempfile.respond_to? meth
+ super "TempIO"
+ binmode
+ write string
+ rewind
end
def string
- @tempfile.flush
-
- Gem.read_binary @tempfile.path
+ flush
+ Gem.read_binary path
end
-
end
View
84 lib/rubygems/user_interaction.rb
@@ -218,48 +218,66 @@ def ask(question)
result
end
- ##
- # Ask for a password. Does not echo response to terminal.
+ if RUBY_VERSION >= "1.9" then
+ ##
+ # Ask for a password. Does not echo response to terminal.
- def ask_for_password(question)
- return nil if not @ins.tty?
+ def ask_for_password(question)
+ return nil if not @ins.tty?
- @outs.print(question + " ")
- @outs.flush
+ require 'io/console'
- Gem.win_platform? ? ask_for_password_on_windows : ask_for_password_on_unix
- end
+ @outs.print(question + " ")
+ @outs.flush
- ##
- # Asks for a password that works on windows. Ripped from the Heroku gem.
+ password = @ins.noecho {@ins.gets}
+ password.chomp! if password
+ password
+ end
+ else
+ ##
+ # Ask for a password. Does not echo response to terminal.
- def ask_for_password_on_windows
- require "Win32API"
- char = nil
- password = ''
+ def ask_for_password(question)
+ return nil if not @ins.tty?
- while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
- break if char == 10 || char == 13 # received carriage return or newline
- if char == 127 || char == 8 # backspace and delete
- password.slice!(-1, 1)
- else
- password << char.chr
- end
+ @outs.print(question + " ")
+ @outs.flush
+
+ Gem.win_platform? ? ask_for_password_on_windows : ask_for_password_on_unix
end
- puts
- password
- end
+ ##
+ # Asks for a password that works on windows. Ripped from the Heroku gem.
+
+ def ask_for_password_on_windows
+ require "Win32API"
+ char = nil
+ password = ''
+
+ while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
+ break if char == 10 || char == 13 # received carriage return or newline
+ if char == 127 || char == 8 # backspace and delete
+ password.slice!(-1, 1)
+ else
+ password << char.chr
+ end
+ end
- ##
- # Asks for a password that works on unix
-
- def ask_for_password_on_unix
- system "stty -echo"
- password = @ins.gets
- password.chomp! if password
- system "stty echo"
- password
+ puts
+ password
+ end
+
+ ##
+ # Asks for a password that works on unix
+
+ def ask_for_password_on_unix
+ system "stty -echo"
+ password = @ins.gets
+ password.chomp! if password
+ system "stty echo"
+ password
+ end
end
##
View
4 test/gemutilities.rb
@@ -502,7 +502,7 @@ def vc_windows?
# other platforms, including Cygwin, it will return 'make'.
#
def self.make_command
- vc_windows? ? 'nmake' : 'make'
+ ENV["make"] || (vc_windows? ? 'nmake' : 'make')
end
# Returns the make command for the current platform. For versions of Ruby
@@ -510,7 +510,7 @@ def self.make_command
# other platforms, including Cygwin, it will return 'make'.
#
def make_command
- vc_windows? ? 'nmake' : 'make'
+ ENV["make"] || (vc_windows? ? 'nmake' : 'make')
end
# Returns whether or not the nmake command could be found.
View
3  test/mockgemui.rb
@@ -13,6 +13,9 @@ def tty?()
@tty
end
+ def noecho
+ yield self
+ end
end
def initialize(input = "")
View
1  test/test_gem.rb
@@ -301,6 +301,7 @@ def test_self_find_files
]
assert_equal expected, Gem.find_files('sff/discover')
+ assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]'
ensure
assert_equal cwd, $LOAD_PATH.shift
end
View
4 test/test_gem_ext_configure_builder.rb
@@ -30,9 +30,9 @@ def test_self_build
assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
assert_equal "", output.shift
- assert_equal "make", output.shift
+ assert_equal make_command, output.shift
assert_match(/^ok$/m, output.shift)
- assert_equal "make install", output.shift
+ assert_equal make_command + " install", output.shift
assert_match(/^ok$/m, output.shift)
end
View
10 test/test_gem_ext_ext_conf_builder.rb
@@ -42,7 +42,6 @@ def test_class_build
def test_class_build_rbconfig_make_prog
configure_args = RbConfig::CONFIG['configure_args']
- RbConfig::CONFIG['configure_args'] = '--with-make-prog=mymake'
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
@@ -50,14 +49,13 @@ def test_class_build_rbconfig_make_prog
output = []
- assert_raises Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
- end
+ Dir.chdir @ext do
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end
assert_equal "creating Makefile\n", output[1]
- assert_equal "mymake", output[2]
+ assert_equal make_command, output[2]
+ assert_equal "#{make_command} install", output[4]
ensure
RbConfig::CONFIG['configure_args'] = configure_args
end
View
4 test/test_gem_stream_ui.rb
@@ -13,6 +13,10 @@ def tty?
end
alias_method :isatty, :tty?
+
+ def noecho
+ yield self
+ end
end
def setup
Please sign in to comment.
Something went wrong with that request. Please try again.