Module: CodeownerValidator::Group::Comment

Included in:
Error, Info, Verbose, Warn
Defined in:
lib/codeowner_validator/group/comment.rb,
lib/codeowner_validator/group/comment/info.rb,
lib/codeowner_validator/group/comment/warn.rb,
lib/codeowner_validator/group/comment/error.rb,
lib/codeowner_validator/group/comment/verbose.rb

Overview

Public: Object for storing base comment information that can be rendered appropriately by the consumer

Defined Under Namespace

Classes: Error, Info, Verbose, Warn

Constant Summary collapse

TYPE_VERBOSE =
1
TYPE_INFO =
2
TYPE_WARN =
3
TYPE_ERROR =
4

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



14
15
16
# File 'lib/codeowner_validator/group/comment.rb', line 14

def comment
  @comment
end

#parentObject

to keep track of hierarchical structure of comments and allow grouping



13
14
15
# File 'lib/codeowner_validator/group/comment.rb', line 13

def parent
  @parent
end

Class Method Details

.build(comment:, type: TYPE_INFO, **_args) ⇒ Info|

Public: Creates an instance of the comment for usage.

Parameters:

  • _args (Hash)

    The hash of arguments accepted

Options Hash (**_args):

  • :comment (String)

    The comment to create

  • :type (Integer)

    The comment type (info, warn, error, verbose)

Returns:



24
25
26
27
28
29
# File 'lib/codeowner_validator/group/comment.rb', line 24

def build(comment:, type: TYPE_INFO, **_args)
  subclasses.each do |klass|
    return klass.new(comment) if klass.match?(type)
  end
  raise "Type '#{type}' not supported" # rubocop:disable Style/ImplicitRuntimeError
end

.match?(type) ⇒ Boolean

Public: Returns <true> if the type of object requested is supported by the object; otherwise, <false>

Parameters:

  • type (Integer)

    The type of comment to match on a subclass

Returns:

  • (Boolean)


34
# File 'lib/codeowner_validator/group/comment.rb', line 34

def match?(type); end

Instance Method Details

#initialize(comment) ⇒ Object

Public: Creates an instance of the comment

Parameters:

  • comment (String)

    The string text of the comment



47
48
49
# File 'lib/codeowner_validator/group/comment.rb', line 47

def initialize(comment)
  @comment = comment
end