Sha256: 3fe58c0a7efbdf78ade6adf89b4005d6e1a84306ac1cbcf25a35e4c58f3c881a

Contents?: true

Size: 1011 Bytes

Versions: 1

Compression:

Stored size: 1011 Bytes

Contents

# frozen_string_literal: true

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-1.0.0 lib/bundler/dependencies/cli/find.rb