Sha256: 91deaf298ed469438aa034d0bf9c2c5f06c07a6e4cc01ef94bb12bb40f20c271

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

module Bundler
  module Dependencies
    class CLI < ::Thor
      class Find < Command
        include WithGem

      private

        def to_s
          if dependents.empty?
            error("No gems in the bundle depend on #{gem}.")
            exit(1)
          end

          banner
          paths unless options.quiet
        end

        def dependents
          Bundler::Dependencies::Visitors::Paths.new.walk(gems, gem).each_with_object({}) do |path, acc|
            acc[path.first] ||= []
            acc[path.first] << path.join(' → ')
          end
        end

        def paths
          dependents.each do |gem, paths|
            puts
            say(gem, %i(bold))
            paths.each { |p| say "  * #{p}" }
          end
        end

        def banner
          if options.quiet?
            puts dependents.count
          else
            say("#{dependents.count} gems depend on #{gem}:", :bold)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bundler-dependencies-0.6.0 lib/bundler/dependencies/cli/find.rb