Skip to content

Commit

Permalink
Refactor RulePresenter to include Rule#since_version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Oct 8, 2024
1 parent d2c21be commit 708e970
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/ameba/presenter/rule_presenter.cr
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
module Ameba::Presenter
class RulePresenter < BasePresenter
def run(rule)
output.puts
output_title "Rule info"
output_paragraph "%s of a %s severity [enabled: %s]" % {

info = <<-INFO
Name: %s
Severity: %s
Enabled: %s
Since version: %s
INFO

output_paragraph info % {
rule.name.colorize(:magenta),
rule.severity.to_s.colorize(rule.severity.color),
rule.enabled? ? ENABLED_MARK : DISABLED_MARK,
(rule.since_version.try(&.to_s) || "N/A").colorize(:white),
}

if rule_description = colorize_code_fences(rule.description)
output_title "Description"
output_paragraph rule_description
end

Expand Down

0 comments on commit 708e970

Please sign in to comment.