Class: GitHub::Actions::Annotation Private
- Inherits:
-
Object
- Object
- GitHub::Actions::Annotation
- Defined in:
- Library/Homebrew/utils/github/actions.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Helper class for formatting annotations on GitHub Actions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, message, file: nil, line: nil, column: nil) ⇒ Annotation
constructor
private
A new instance of Annotation.
-
#relevant? ⇒ Boolean
private
An annotation is only relevant if the corresponding
file
is relative to theGITHUB_WORKSPACE
directory or if nofile
is specified. - #to_s ⇒ Object private
Constructor Details
#initialize(type, message, file: nil, line: nil, column: nil) ⇒ Annotation
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Annotation.
28 29 30 31 32 33 34 35 36 |
# File 'Library/Homebrew/utils/github/actions.rb', line 28 def initialize(type, , file: nil, line: nil, column: nil) raise ArgumentError, "Unsupported type: #{type.inspect}" unless [:warning, :error].include?(type) @type = type @message = Tty.strip_ansi() @file = self.class.path_relative_to_workspace(file) if file @line = Integer(line) if line @column = Integer(column) if column end |
Class Method Details
.path_relative_to_workspace(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 |
# File 'Library/Homebrew/utils/github/actions.rb', line 20 def self.path_relative_to_workspace(path) workspace = Pathname(ENV.fetch("GITHUB_WORKSPACE", Dir.pwd)).realpath path = Pathname(path) return path unless path.exist? path.realpath.relative_path_from(workspace) end |
Instance Method Details
#relevant? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
An annotation is only relevant if the corresponding file
is relative to
the GITHUB_WORKSPACE
directory or if no file
is specified.
50 51 52 53 54 |
# File 'Library/Homebrew/utils/github/actions.rb', line 50 def relevant? return true if @file.nil? @file.descend.next.to_s != ".." end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 46 |
# File 'Library/Homebrew/utils/github/actions.rb', line 38 def to_s file = "file=#{Actions.escape(@file.to_s)}" if @file line = "line=#{@line}" if @line column = "col=#{@column}" if @column = [*file, *line, *column].join(",").presence&.prepend(" ") "::#{@type}#{}::#{Actions.escape(@message)}" end |