summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/dependency_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/commands/dependency_command.rb')
-rw-r--r--lib/rubygems/commands/dependency_command.rb40
1 files changed, 25 insertions, 15 deletions
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index 4a54a3e385..9d4b3e0f50 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -61,10 +61,16 @@ use with other commands.
ss.map { |spec, _| spec }
end
- def fetch_specs dependency # :nodoc:
+ def fetch_specs name_pattern, dependency # :nodoc:
specs = []
- specs.concat dependency.matching_specs if local?
+ if local?
+ specs.concat Gem::Specification.stubs.find_all { |spec|
+ name_pattern =~ spec.name and
+ dependency.requirement.satisfied_by? spec.version
+ }.map(&:to_spec)
+ end
+
specs.concat fetch_remote_specs dependency if remote?
ensure_specs specs
@@ -72,16 +78,7 @@ use with other commands.
specs.uniq.sort
end
- def gem_dependency args, version, prerelease # :nodoc:
- args << '' if args.empty?
-
- pattern = if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
- flags = $2 ? Regexp::IGNORECASE : nil
- Regexp.new $1, flags
- else
- /\A#{Regexp.union(*args)}/
- end
-
+ def gem_dependency pattern, version, prerelease # :nodoc:
dependency = Gem::Deprecate.skip_during {
Gem::Dependency.new pattern, version
}
@@ -121,10 +118,12 @@ use with other commands.
def execute
ensure_local_only_reverse_dependencies
+ pattern = name_pattern options[:args]
+
dependency =
- gem_dependency options[:args], options[:version], options[:prerelease]
+ gem_dependency pattern, options[:version], options[:prerelease]
- specs = fetch_specs dependency
+ specs = fetch_specs pattern, dependency
reverse = reverse_dependencies specs
@@ -203,5 +202,16 @@ use with other commands.
result
end
-end
+ private
+ def name_pattern args
+ args << '' if args.empty?
+
+ if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
+ flags = $2 ? Regexp::IGNORECASE : nil
+ Regexp.new $1, flags
+ else
+ /\A#{Regexp.union(*args)}/
+ end
+ end
+end