Class: QuietQuality::Annotators::GithubStdout
- Inherits:
-
Object
- Object
- QuietQuality::Annotators::GithubStdout
- Defined in:
- lib/quiet_quality/annotators/github_stdout.rb
Constant Summary collapse
- MAX_ANNOTATIONS =
github will only accept the first 10 annotations of each type in this form.
10
Class Method Summary collapse
-
.format(message) ⇒ Object
Example annotation output from github’s docs: ::warning file=name,line=line,title=title::message See docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message.
Instance Method Summary collapse
- #annotate!(messages) ⇒ Object
-
#initialize(output_stream: $stdout) ⇒ GithubStdout
constructor
A new instance of GithubStdout.
Constructor Details
#initialize(output_stream: $stdout) ⇒ GithubStdout
Returns a new instance of GithubStdout.
7 8 9 |
# File 'lib/quiet_quality/annotators/github_stdout.rb', line 7 def initialize(output_stream: $stdout) @output_stream = output_stream end |
Class Method Details
.format(message) ⇒ Object
Example annotation output from github’s docs: ::warning file=name,line=line,title=title::message See docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/quiet_quality/annotators/github_stdout.rb', line 20 def self.format() title = .tool_name.to_s title += " #{.rule}" if .rule attributes = { file: .path, line: .annotated_line || .start_line, title: title }.compact attributes_string = attributes.map { |k, v| "#{k}=#{v}" }.join(",") "::warning #{attributes_string}::#{.body}" end |
Instance Method Details
#annotate!(messages) ⇒ Object
11 12 13 14 15 |
# File 'lib/quiet_quality/annotators/github_stdout.rb', line 11 def annotate!() .first(MAX_ANNOTATIONS).each do || output_stream.puts self.class.format() end end |