Skip to content

Commit d56ef8e

Browse files
committedDec 1, 2015
Updated RubyGems to 2.5.0.
1 parent 7c8dcb7 commit d56ef8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2198
-728
lines changed
 

‎library/rubygems.rb

+32-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
require 'thread'
1010

1111
module Gem
12-
VERSION = '2.4.8'
12+
VERSION = '2.5.0'
1313
end
1414

1515
# Must be first since it unloads the prelude from 1.9.2
@@ -26,12 +26,12 @@ module Gem
2626
# For user documentation, see:
2727
#
2828
# * <tt>gem help</tt> and <tt>gem help [command]</tt>
29-
# * {RubyGems User Guide}[http://docs.rubygems.org/read/book/1]
30-
# * {Frequently Asked Questions}[http://docs.rubygems.org/read/book/3]
29+
# * {RubyGems User Guide}[http://guides.rubygems.org/]
30+
# * {Frequently Asked Questions}[http://guides.rubygems.org/faqs]
3131
#
3232
# For gem developer documentation see:
3333
#
34-
# * {Creating Gems}[http://docs.rubygems.org/read/chapter/5]
34+
# * {Creating Gems}[http://guides.rubygems.org/make-your-own-gem]
3535
# * Gem::Specification
3636
# * Gem::Version for version dependency notes
3737
#
@@ -156,6 +156,7 @@ module Gem
156156
@@win_platform = nil
157157

158158
@configuration = nil
159+
@gemdeps = nil
159160
@loaded_specs = {}
160161
LOADED_SPECS_MUTEX = Mutex.new
161162
@path_to_default_spec_map = {}
@@ -184,13 +185,9 @@ def self.try_activate path
184185
# or if it was ambiguous (and thus unresolved) the code in our custom
185186
# require will try to activate the more specific version.
186187

187-
spec = Gem::Specification.find_inactive_by_path path
188-
189-
unless spec
190-
spec = Gem::Specification.find_by_path path
191-
return true if spec && spec.activated?
192-
return false
193-
end
188+
spec = Gem::Specification.find_by_path path
189+
return false unless spec
190+
return true if spec.activated?
194191

195192
begin
196193
spec.activate
@@ -433,7 +430,7 @@ def self.find_files(glob, check_load_path=true)
433430

434431
files = find_files_from_load_path glob if check_load_path
435432

436-
files.concat Gem::Specification.map { |spec|
433+
files.concat Gem::Specification.stubs.map { |spec|
437434
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
438435
}.flatten
439436

@@ -580,6 +577,10 @@ def self.host= host
580577
# gem's paths are inserted before site lib directory by default.
581578

582579
def self.load_path_insert_index
580+
$LOAD_PATH.each_with_index do |path, i|
581+
return i if path.instance_variable_defined?(:@gem_prelude_index)
582+
end
583+
583584
index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
584585

585586
index
@@ -596,6 +597,9 @@ def self.load_yaml
596597

597598
test_syck = ENV['TEST_SYCK']
598599

600+
# Only Ruby 1.8 and 1.9 have syck
601+
test_syck = false unless /^1\./ =~ RUBY_VERSION
602+
599603
unless test_syck
600604
begin
601605
gem 'psych', '>= 1.2.1'
@@ -777,6 +781,14 @@ def self.read_binary(path)
777781
open path, 'rb' do |f|
778782
f.read
779783
end
784+
rescue Errno::ENOLCK # NFS
785+
if Thread.main != Thread.current
786+
raise
787+
else
788+
open path, 'rb' do |f|
789+
f.read
790+
end
791+
end
780792
end
781793

782794
##
@@ -1052,7 +1064,7 @@ def self.use_gemdeps path = nil
10521064
end
10531065

10541066
rs = Gem::RequestSet.new
1055-
rs.load_gemdeps path
1067+
@gemdeps = rs.load_gemdeps path
10561068

10571069
rs.resolve_current.map do |s|
10581070
sp = s.full_spec
@@ -1082,6 +1094,12 @@ class << self
10821094

10831095
attr_reader :loaded_specs
10841096

1097+
##
1098+
# GemDependencyAPI object, which is set when .use_gemdeps is called.
1099+
# This contains all the information from the Gemfile.
1100+
1101+
attr_reader :gemdeps
1102+
10851103
##
10861104
# Register a Gem::Specification for default gem.
10871105
#
@@ -1196,6 +1214,7 @@ def clear_default_specs
11961214
autoload :DependencyList, 'rubygems/dependency_list'
11971215
autoload :DependencyResolver, 'rubygems/resolver'
11981216
autoload :Installer, 'rubygems/installer'
1217+
autoload :Licenses, 'rubygems/util/licenses'
11991218
autoload :PathSupport, 'rubygems/path_support'
12001219
autoload :Platform, 'rubygems/platform'
12011220
autoload :RequestSet, 'rubygems/request_set'
@@ -1242,4 +1261,3 @@ def clear_default_specs
12421261
require 'rubygems/core_ext/kernel_require'
12431262

12441263
Gem.use_gemdeps
1245-

‎library/rubygems/basic_specification.rb

+31-9
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ class Gem::BasicSpecification
2222
##
2323
# The path this gemspec was loaded from. This attribute is not persisted.
2424

25-
attr_reader :loaded_from
25+
attr_accessor :loaded_from
2626

2727
##
2828
# Allows correct activation of git: and path: gems.
2929

3030
attr_writer :full_gem_path # :nodoc:
3131

32+
def initialize
33+
internal_init
34+
end
35+
3236
def self.default_specifications_dir
3337
File.join(Gem.default_dir, "specifications", "default")
3438
end
@@ -141,7 +145,7 @@ def full_require_paths
141145
@full_require_paths ||=
142146
begin
143147
full_paths = raw_require_paths.map do |path|
144-
File.join full_gem_path, path
148+
File.join full_gem_path, path.untaint
145149
end
146150

147151
full_paths << extension_dir unless @extensions.nil? || @extensions.empty?
@@ -189,13 +193,7 @@ def gems_dir
189193
@gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
190194
end
191195

192-
##
193-
# Set the path the Specification was loaded from. +path+ is converted to a
194-
# String.
195-
196-
def loaded_from= path
197-
@loaded_from = path && path.to_s
198-
196+
def internal_init # :nodoc:
199197
@extension_dir = nil
200198
@extensions_dir = nil
201199
@full_gem_path = nil
@@ -263,6 +261,30 @@ def source_paths
263261
paths.uniq
264262
end
265263

264+
##
265+
# Return all files in this gem that match for +glob+.
266+
267+
def matches_for_glob glob # TODO: rename?
268+
# TODO: do we need these?? Kill it
269+
glob = File.join(self.lib_dirs_glob, glob)
270+
271+
Dir[glob].map { |f| f.untaint } # FIX our tests are broken, run w/ SAFE=1
272+
end
273+
274+
##
275+
# Returns a string usable in Dir.glob to match all requirable paths
276+
# for this spec.
277+
278+
def lib_dirs_glob
279+
dirs = if self.require_paths.size > 1 then
280+
"{#{self.require_paths.join(',')}}"
281+
else
282+
self.require_paths.first
283+
end
284+
285+
"#{self.full_gem_path}/#{dirs}".untaint
286+
end
287+
266288
##
267289
# Return a Gem::Specification from this gem
268290

0 commit comments

Comments
 (0)
Please sign in to comment.