Class: DataChecks::Notifiers::SlackDefaultFormatter
- Inherits:
-
Object
- Object
- DataChecks::Notifiers::SlackDefaultFormatter
- Defined in:
- lib/data_checks/notifiers/slack_default_formatter.rb
Instance Method Summary collapse
- #color ⇒ Object
-
#initialize(check_result) ⇒ SlackDefaultFormatter
constructor
A new instance of SlackDefaultFormatter.
- #text ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(check_result) ⇒ SlackDefaultFormatter
Returns a new instance of SlackDefaultFormatter.
6 7 8 9 |
# File 'lib/data_checks/notifiers/slack_default_formatter.rb', line 6 def initialize(check_result) @check_run = check_result.check.check_run @check_result = check_result end |
Instance Method Details
#color ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/data_checks/notifiers/slack_default_formatter.rb', line 36 def color if @check_run.status == CheckRun.statuses[:passing] "good" else "danger" end end |
#text ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/data_checks/notifiers/slack_default_formatter.rb', line 15 def text error = @check_run. count = @check_result.count entries = @check_result.entries&.map { |entry| format_entry(entry) } if error escape(error) else text = ["Checker found #{count} element(s)."] if entries if count > 10 text << "Showing 10 of #{count} entries" end text += entries.first(10).map { |entry| "- #{entry}" } end escape(text.join("\n")) end end |
#title ⇒ Object
11 12 13 |
# File 'lib/data_checks/notifiers/slack_default_formatter.rb', line 11 def title escape("Check #{@check_run.status.titleize}: #{@check_run.name}") end |