mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Don't pass regexp to Gem::Dependency.new
during gem dependency
89dd5158a4
This commit is contained in:
parent
1d530ae27a
commit
0dd8c6157d
1 changed files with 20 additions and 22 deletions
|
@ -53,41 +53,41 @@ use with other commands.
|
||||||
"#{program_name} REGEXP"
|
"#{program_name} REGEXP"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_remote_specs(dependency) # :nodoc:
|
def fetch_remote_specs(name, requirement, prerelease) # :nodoc:
|
||||||
fetcher = Gem::SpecFetcher.fetcher
|
fetcher = Gem::SpecFetcher.fetcher
|
||||||
|
|
||||||
ss, = fetcher.spec_for_dependency dependency
|
specs_type = prerelease ? :complete : :released
|
||||||
|
|
||||||
ss.map {|spec, _| spec }
|
ss = if name.nil?
|
||||||
|
fetcher.detect(specs_type) { true }
|
||||||
|
else
|
||||||
|
fetcher.detect(specs_type) do |name_tuple|
|
||||||
|
name === name_tuple.name && requirement.satisfied_by?(name_tuple.version)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_specs(name_pattern, dependency) # :nodoc:
|
ss.map {|tuple, source| source.fetch_spec(tuple) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_specs(name_pattern, requirement, prerelease) # :nodoc:
|
||||||
specs = []
|
specs = []
|
||||||
|
|
||||||
if local?
|
if local?
|
||||||
specs.concat Gem::Specification.stubs.find_all {|spec|
|
specs.concat Gem::Specification.stubs.find_all {|spec|
|
||||||
name_pattern =~ spec.name and
|
name_matches = name_pattern ? name_pattern =~ spec.name : true
|
||||||
dependency.requirement.satisfied_by? spec.version
|
version_matches = requirement.satisfied_by?(spec.version)
|
||||||
|
|
||||||
|
name_matches and version_matches
|
||||||
}.map(&:to_spec)
|
}.map(&:to_spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
specs.concat fetch_remote_specs dependency if remote?
|
specs.concat fetch_remote_specs name_pattern, requirement, prerelease if remote?
|
||||||
|
|
||||||
ensure_specs specs
|
ensure_specs specs
|
||||||
|
|
||||||
specs.uniq.sort
|
specs.uniq.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def gem_dependency(pattern, version, prerelease) # :nodoc:
|
|
||||||
dependency = Gem::Deprecate.skip_during do
|
|
||||||
Gem::Dependency.new pattern, version
|
|
||||||
end
|
|
||||||
|
|
||||||
dependency.prerelease = prerelease
|
|
||||||
|
|
||||||
dependency
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_pipe(specs) # :nodoc:
|
def display_pipe(specs) # :nodoc:
|
||||||
specs.each do |spec|
|
specs.each do |spec|
|
||||||
unless spec.dependencies.empty?
|
unless spec.dependencies.empty?
|
||||||
|
@ -119,11 +119,9 @@ use with other commands.
|
||||||
ensure_local_only_reverse_dependencies
|
ensure_local_only_reverse_dependencies
|
||||||
|
|
||||||
pattern = name_pattern options[:args]
|
pattern = name_pattern options[:args]
|
||||||
|
requirement = Gem::Requirement.new options[:version]
|
||||||
|
|
||||||
dependency =
|
specs = fetch_specs pattern, requirement, options[:prerelease]
|
||||||
gem_dependency pattern, options[:version], options[:prerelease]
|
|
||||||
|
|
||||||
specs = fetch_specs pattern, dependency
|
|
||||||
|
|
||||||
reverse = reverse_dependencies specs
|
reverse = reverse_dependencies specs
|
||||||
|
|
||||||
|
@ -197,7 +195,7 @@ use with other commands.
|
||||||
private
|
private
|
||||||
|
|
||||||
def name_pattern(args)
|
def name_pattern(args)
|
||||||
args << '' if args.empty?
|
return if args.empty?
|
||||||
|
|
||||||
if args.length == 1 and args.first =~ /\A(.*)(i)?\z/m
|
if args.length == 1 and args.first =~ /\A(.*)(i)?\z/m
|
||||||
flags = $2 ? Regexp::IGNORECASE : nil
|
flags = $2 ? Regexp::IGNORECASE : nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue