# class Gem::Commands::DependencyCommand

### Public Class Methods

new() click to toggle source
Calls superclass method `Gem::Command::new`

    # File lib/rubygems/commands/dependency_command.rb, line 10
    def initialize
      super 'dependency',
            'Show the dependencies of an installed gem',
            :version => Gem::Requirement.default, :domain => :local

      add_version_option
      add_platform_option
      add_prerelease_option

      add_option('-R', '--[no-]reverse-dependencies',
                 'Include reverse dependencies in the output') do
        |value, options|
        options[:reverse_dependencies] = value
      end

      add_option('-p', '--pipe',
                 "Pipe Format (name --version ver)") do |value, options|
        options[:pipe_format] = value
      end

      add_local_remote_options
    end

### Public Instance Methods

execute() click to toggle source

    # File lib/rubygems/commands/dependency_command.rb, line 118
    def execute
      ensure_local_only_reverse_dependencies

      pattern = name_pattern options[:args]

      dependency =
        gem_dependency pattern, options[:version], options[:prerelease]

      specs = fetch_specs pattern, dependency

      reverse = reverse_dependencies specs

      if options[:pipe_format]
        display_pipe specs
      else
        display_readable specs, reverse
      end
    end

### Private Instance Methods

name_pattern(args) click to toggle source

    # File lib/rubygems/commands/dependency_command.rb, line 207
    def name_pattern(args)
      args << '' if args.empty?

      if args.length == 1 and args.first =~ /\A(.*)(i)?\z/m
        flags = $2 ? Regexp::IGNORECASE : nil
        Regexp.new $1, flags
      else
        /\A#{Regexp.union(*args)}/
      end
    end