Class: Lazylead::LogsLink

Inherits:
Logs show all
Defined in:
lib/lazylead/task/accuracy/logs_link.rb

Overview

Check that ticket has link/reference to log record(s) in another system like ELK, GrayLog, etc.

or attachment with plain log file

Instance Attribute Summary

Attributes inherited from Requirement

#desc, #field, #score

Instance Method Summary collapse

Methods inherited from Logs

#matches?

Methods inherited from Attachment

#matches?

Methods inherited from Requirement

#blank?, #non_blank?

Constructor Details

#initialize(link) ⇒ LogsLink

Returns a new instance of LogsLink.



32
33
34
35
# File 'lib/lazylead/task/accuracy/logs_link.rb', line 32

def initialize(link)
  super()
  @link = link
end

Instance Method Details

#link?(issue) ⇒ Boolean

Ensure that ticket has a link to external logs system like ELK, GrayLog, etc.

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/lazylead/task/accuracy/logs_link.rb', line 43

def link?(issue)
  return false if issue.description.nil?
  issue.description
       .split("\n")
       .reject(&:blank?)
       .flat_map(&:split)
       .reject(&:blank?)
       .any? do |word|
    @link.is_a?(Array) ? @link.any? { |l| word.include? l } : word.include?(@link)
  end
end

#passed(issue) ⇒ Object



37
38
39
40
# File 'lib/lazylead/task/accuracy/logs_link.rb', line 37

def passed(issue)
  return false if @link.nil? || (@link.is_a?(Array) && @link.empty?)
  super(issue) || link?(issue)
end