Skip to content

Commit effdbf5

Browse files
committed
* lib/rubygems: Update to RubyGems HEAD(c202db2).
this version contains many enhancements see http://git.io/vtNwF * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 9c4ef4b commit effdbf5

File tree

90 files changed

+2471
-1141
lines changed

Some content is hidden

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

90 files changed

+2471
-1141
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Thu Jul 2 06:49:44 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
2+
3+
* lib/rubygems: Update to RubyGems HEAD(c202db2).
4+
this version contains many enhancements see http://git.io/vtNwF
5+
* test/rubygems: ditto.
6+
17
Wed Jul 1 23:50:34 2015 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
28

39
* test/net/http/test_httpresponse.rb

lib/rubygems.rb

Lines changed: 17 additions & 14 deletions
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

@@ -598,7 +595,7 @@ def self.load_yaml
598595

599596
unless test_syck
600597
begin
601-
gem 'psych', '~> 1.2', '>= 1.2.1'
598+
gem 'psych', '>= 1.2.1'
602599
rescue Gem::LoadError
603600
# It's OK if the user does not have the psych gem installed. We will
604601
# attempt to require the stdlib version
@@ -1052,7 +1049,7 @@ def self.use_gemdeps path = nil
10521049
end
10531050

10541051
rs = Gem::RequestSet.new
1055-
rs.load_gemdeps path
1052+
@gemdeps = rs.load_gemdeps path
10561053

10571054
rs.resolve_current.map do |s|
10581055
sp = s.full_spec
@@ -1082,6 +1079,12 @@ class << self
10821079

10831080
attr_reader :loaded_specs
10841081

1082+
##
1083+
# GemDependencyAPI object, which is set when .use_gemdeps is called.
1084+
# This contains all the information from the Gemfile.
1085+
1086+
attr_reader :gemdeps
1087+
10851088
##
10861089
# Register a Gem::Specification for default gem.
10871090
#

lib/rubygems/basic_specification.rb

Lines changed: 31 additions & 9 deletions
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}"
286+
end
287+
266288
##
267289
# Return a Gem::Specification from this gem
268290

lib/rubygems/commands/dependency_command.rb

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,24 @@ def fetch_remote_specs dependency # :nodoc:
6161
ss.map { |spec, _| spec }
6262
end
6363

64-
def fetch_specs dependency # :nodoc:
64+
def fetch_specs name_pattern, dependency # :nodoc:
6565
specs = []
6666

67-
specs.concat dependency.matching_specs if local?
67+
if local?
68+
specs.concat Gem::Specification.stubs.find_all { |spec|
69+
name_pattern =~ spec.name and
70+
dependency.requirement.satisfied_by? spec.version
71+
}.map(&:to_spec)
72+
end
73+
6874
specs.concat fetch_remote_specs dependency if remote?
6975

7076
ensure_specs specs
7177

7278
specs.uniq.sort
7379
end
7480

75-
def gem_dependency args, version, prerelease # :nodoc:
76-
args << '' if args.empty?
77-
78-
pattern = if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
79-
flags = $2 ? Regexp::IGNORECASE : nil
80-
Regexp.new $1, flags
81-
else
82-
/\A#{Regexp.union(*args)}/
83-
end
84-
81+
def gem_dependency pattern, version, prerelease # :nodoc:
8582
dependency = Gem::Deprecate.skip_during {
8683
Gem::Dependency.new pattern, version
8784
}
@@ -121,10 +118,12 @@ def display_readable specs, reverse # :nodoc:
121118
def execute
122119
ensure_local_only_reverse_dependencies
123120

121+
pattern = name_pattern options[:args]
122+
124123
dependency =
125-
gem_dependency options[:args], options[:version], options[:prerelease]
124+
gem_dependency pattern, options[:version], options[:prerelease]
126125

127-
specs = fetch_specs dependency
126+
specs = fetch_specs pattern, dependency
128127

129128
reverse = reverse_dependencies specs
130129

@@ -203,5 +202,16 @@ def find_reverse_dependencies spec # :nodoc:
203202
result
204203
end
205204

206-
end
205+
private
207206

207+
def name_pattern args
208+
args << '' if args.empty?
209+
210+
if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
211+
flags = $2 ? Regexp::IGNORECASE : nil
212+
Regexp.new $1, flags
213+
else
214+
/\A#{Regexp.union(*args)}/
215+
end
216+
end
217+
end

lib/rubygems/commands/install_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def install_gem_without_dependencies name, req # :nodoc:
275275
gem = fetcher.download_to_cache dependency
276276
end
277277

278-
inst = Gem::Installer.new gem, options
278+
inst = Gem::Installer.at gem, options
279279
inst.install
280280

281281
require 'rubygems/dependency_installer'

lib/rubygems/commands/list_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def description # :nodoc:
3333
end
3434

3535
def usage # :nodoc:
36-
"#{program_name} [STRING ...]"
36+
"#{program_name} [REGEXP ...]"
3737
end
3838

3939
end

lib/rubygems/commands/pristine_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def execute
156156
install_defaults.to_s['--env-shebang']
157157
end
158158

159-
installer = Gem::Installer.new(gem,
159+
installer = Gem::Installer.at(gem,
160160
:wrappers => true,
161161
:force => true,
162162
:install_dir => spec.base_dir,

lib/rubygems/commands/query_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def entry_details entry, detail_tuple, specs, platforms
227227

228228
name_tuple, spec = detail_tuple
229229

230-
spec = spec.fetch_spec name_tuple unless Gem::Specification === spec
230+
spec = spec.fetch_spec name_tuple if spec.respond_to? :fetch_spec
231231

232232
entry << "\n"
233233

lib/rubygems/core_ext/kernel_require.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def require path
6666

6767
begin
6868
RUBYGEMS_ACTIVATION_MONITOR.exit
69-
return gem_original_require(spec.to_fullpath(path) || path)
69+
return gem_original_require(path)
7070
end if spec
7171

7272
# Attempt to find +path+ in any unresolved gems...
@@ -105,7 +105,7 @@ def require path
105105

106106
# Ok, now find a gem that has no conflicts, starting
107107
# at the highest version.
108-
valid = found_specs.select { |s| s.conflicts.empty? }.last
108+
valid = found_specs.reject { |s| s.has_conflicts? }.last
109109

110110
unless valid then
111111
le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"

lib/rubygems/dependency.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ def type
164164
@type ||= :runtime
165165
end
166166

167+
def runtime?
168+
@type == :runtime || !@type
169+
end
170+
167171
def == other # :nodoc:
168172
Gem::Dependency === other &&
169173
self.name == other.name &&
@@ -270,9 +274,8 @@ def merge other
270274
end
271275

272276
def matching_specs platform_only = false
273-
matches = Gem::Specification.stubs.find_all { |spec|
274-
self.name === spec.name and # TODO: == instead of ===
275-
requirement.satisfied_by? spec.version
277+
matches = Gem::Specification.stubs_for(name).find_all { |spec|
278+
requirement.satisfied_by? spec.version
276279
}.map(&:to_spec)
277280

278281
if platform_only

0 commit comments

Comments
 (0)