Class: Danger::MessageGroup
- Inherits:
-
Object
- Object
- Danger::MessageGroup
- Defined in:
- lib/danger/danger_core/message_group.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
-
#<<(message) ⇒ Object
Adds a message to the group.
-
#initialize(file: nil, line: nil) ⇒ MessageGroup
constructor
A new instance of MessageGroup.
-
#merge(other) ⇒ Object
Merges two ‘MessageGroup`s that represent the same line of code In future, perhaps `MessageGroup` will be able to represent a group of messages for multiple lines.
-
#messages ⇒ Object
The list of messages in this group.
-
#same_line?(other) ⇒ Boolean
Returns whether this ‘MessageGroup` is for the same line of code as `other`, taking which file they are in to account.
Constructor Details
#initialize(file: nil, line: nil) ⇒ MessageGroup
Returns a new instance of MessageGroup.
5 6 7 8 |
# File 'lib/danger/danger_core/message_group.rb', line 5 def initialize(file: nil, line: nil) @file = file @line = line end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
40 41 42 |
# File 'lib/danger/danger_core/message_group.rb', line 40 def file @file end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
40 41 42 |
# File 'lib/danger/danger_core/message_group.rb', line 40 def line @line end |
Instance Method Details
#<<(message) ⇒ Object
Adds a message to the group.
29 30 31 32 |
# File 'lib/danger/danger_core/message_group.rb', line 29 def <<() # TODO: insertion sort << if same_line?() end |
#merge(other) ⇒ Object
Merges two ‘MessageGroup`s that represent the same line of code In future, perhaps `MessageGroup` will be able to represent a group of messages for multiple lines.
21 22 23 24 25 |
# File 'lib/danger/danger_core/message_group.rb', line 21 def merge(other) raise ArgumentError, "Cannot merge with MessageGroup for a different line" unless same_line?(other) = ( + other.).uniq end |
#messages ⇒ Object
The list of messages in this group. This list will be sorted in decreasing order of severity (error, warning, message, markdown)
36 37 38 |
# File 'lib/danger/danger_core/message_group.rb', line 36 def ||= [] end |
#same_line?(other) ⇒ Boolean
Returns whether this ‘MessageGroup` is for the same line of code as
`other`, taking which file they are in to account.
14 15 16 |
# File 'lib/danger/danger_core/message_group.rb', line 14 def same_line?(other) other.file == file && other.line == line end |