Class: GemWhy::Formatters::DirectFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/gem_why/formatters/direct_formatter.rb

Overview

Formats direct dependencies output

Instance Attribute Summary

Attributes inherited from BaseFormatter

#command

Instance Method Summary collapse

Methods inherited from BaseFormatter

#initialize

Constructor Details

This class inherits a constructor from GemWhy::Formatters::BaseFormatter

Instance Method Details

#format(gem_name, dependents) ⇒ void

This method returns an undefined value.

Formats and displays direct dependencies

Parameters:

  • gem_name (String)

    the target gem name

  • dependents (Array<Dependent>)

    the dependent gems



13
14
15
16
17
18
19
# File 'lib/gem_why/formatters/direct_formatter.rb', line 13

def format(gem_name, dependents)
  return say "No gems depend on #{colorize(gem_name, :yellow)}" if dependents.empty?

  say "Gems that depend on #{colorize(gem_name, :cyan)}:\n\n"
  print_direct_dependents(dependents, gem_name)
  say "\n#{colorize("Total:", :green)} #{dependents.size} gem(s)"
end