Class: Danger::DangerfileMessagingPlugin
- Defined in:
- lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb
Overview
Provides the feedback mechanism for Danger. Danger can keep track of messages, warnings, failure and post arbitrary markdown into a comment.
The message within which Danger communicates back is amended on each run in a session.
Each of ‘message`, `warn` and `fail` have a `sticky` flag, `true` by default, which means that the message will be crossed out instead of being removed. If it’s not use on subsequent runs.
By default, using ‘fail` would fail the corresponding build. Either via an API call, or via the return value for the danger command.
It is possible to have Danger ignore specific warnings or errors by writing ‘Danger: Ignore “[warning/error text]`.
Sidenote: Messaging is the only plugin which adds functions to the root of the Dangerfile.
Core collapse
-
#fail(message, sticky: true) ⇒ Object
Declares a CI blocking error.
-
#markdown(message) ⇒ Object
Print markdown to below the table.
-
#message(message, sticky: true) ⇒ Object
Print out a generate message on the PR.
-
#warn(message, sticky: true) ⇒ Object
Specifies a problem, but not critical.
Reporting collapse
-
#status_report ⇒ Object
A list of all messages passed to Danger, including the markdowns.
-
#violation_report ⇒ Object
A list of all violations passed to Danger, we don’t anticipate users of Danger needing to use this.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dangerfile) ⇒ DangerfileMessagingPlugin
constructor
A new instance of DangerfileMessagingPlugin.
Methods inherited from Plugin
all_plugins, clear_external_plugins, inherited, #method_missing
Constructor Details
#initialize(dangerfile) ⇒ DangerfileMessagingPlugin
Returns a new instance of DangerfileMessagingPlugin.
47 48 49 50 51 52 53 54 |
# File 'lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb', line 47 def initialize(dangerfile) super(dangerfile) @warnings = [] @errors = [] = [] @markdowns = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Danger::Plugin
Class Method Details
.instance_name ⇒ Object
56 57 58 |
# File 'lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb', line 56 def self.instance_name "messaging" end |
Instance Method Details
#fail(message, sticky: true) ⇒ Object
Declares a CI blocking error
100 101 102 103 |
# File 'lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb', line 100 def fail(, sticky: true) return if should_ignore_violation() @errors << Violation.new(, sticky) end |
#markdown(message) ⇒ Object
Print markdown to below the table
65 66 67 |
# File 'lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb', line 65 def markdown() @markdowns << end |
#message(message, sticky: true) ⇒ Object
Print out a generate message on the PR
76 77 78 |
# File 'lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb', line 76 def (, sticky: true) << Violation.new(, sticky) end |
#status_report ⇒ Object
A list of all messages passed to Danger, including the markdowns.
110 111 112 113 114 115 116 117 |
# File 'lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb', line 110 def status_report { errors: @errors.map(&:message).clone.freeze, warnings: @warnings.map(&:message).clone.freeze, messages: .map(&:message).clone.freeze, markdowns: @markdowns.clone.freeze } end |
#violation_report ⇒ Object
A list of all violations passed to Danger, we don’t anticipate users of Danger needing to use this.
125 126 127 128 129 130 131 |
# File 'lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb', line 125 def violation_report { errors: @errors.clone.freeze, warnings: @warnings.clone.freeze, messages: .clone.freeze } end |
#warn(message, sticky: true) ⇒ Object
Specifies a problem, but not critical
87 88 89 90 |
# File 'lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb', line 87 def warn(, sticky: true) return if should_ignore_violation() @warnings << Violation.new(, sticky) end |