class Packwerk::Formatters::OffensesFormatter
Public Class Methods
new(style: OutputStyles::Plain.new)
click to toggle source
# File lib/packwerk/formatters/offenses_formatter.rb, line 12 def initialize(style: OutputStyles::Plain.new) @style = style end
Public Instance Methods
show_offenses(offenses)
click to toggle source
# File lib/packwerk/formatters/offenses_formatter.rb, line 17 def show_offenses(offenses) return "No offenses detected" if offenses.empty? <<~EOS #{offenses_list(offenses)} #{offenses_summary(offenses)} EOS end
show_stale_violations(offense_collection)
click to toggle source
# File lib/packwerk/formatters/offenses_formatter.rb, line 27 def show_stale_violations(offense_collection) if offense_collection.stale_violations? "There were stale violations found, please run `packwerk update-deprecations`" else "No stale violations detected" end end
Private Instance Methods
offenses_list(offenses)
click to toggle source
# File lib/packwerk/formatters/offenses_formatter.rb, line 38 def offenses_list(offenses) offenses .compact .map { |offense| offense.to_s(@style) } .join("\n") end
offenses_summary(offenses)
click to toggle source
# File lib/packwerk/formatters/offenses_formatter.rb, line 46 def offenses_summary(offenses) offenses_string = Inflector.default.pluralize("offense", offenses.length) "#{offenses.length} #{offenses_string} detected" end