Class: Lazylead::Servers

Inherits:
Requirement show all
Defined in:
lib/lazylead/task/accuracy/servers.rb

Overview

Check that ticket has expected links to failed entities on dedicated

servers.

Instance Attribute Summary

Attributes inherited from Requirement

#desc, #field, #score

Instance Method Summary collapse

Methods inherited from Requirement

#blank?, #non_blank?

Constructor Details

#initialize(score: 2, envs: [], desc: "Internal reproducing results") ⇒ Servers

Returns a new instance of Servers.

Parameters:

  • envs (defaults to: [])

    regexp expressions to match servers in description.



34
35
36
37
# File 'lib/lazylead/task/accuracy/servers.rb', line 34

def initialize(score: 2, envs: [], desc: "Internal reproducing results")
  super desc, score, "Description/Environment"
  @envs = envs
end

Instance Method Details

#match?(url) ⇒ Boolean

Ensure that particular url matches expected servers urls

Returns:

  • (Boolean)


55
56
57
# File 'lib/lazylead/task/accuracy/servers.rb', line 55

def match?(url)
  @envs.any? { |e| url.match? e }
end

#passed(issue) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/lazylead/task/accuracy/servers.rb', line 39

def passed(issue)
  return true if @envs.empty?
  "#{issue['environment']}\n#{issue.description}".split("\n")
                                                 .reject(&:blank?)
                                                 .map(&:strip)
                                                 .flat_map { |l| l.split.map(&:strip) }
                                                 .select { |u| url?(u) }
                                                 .any? { |u| match?(u) }
end

#url?(text) ⇒ Boolean

Ensure that particular text contains web url

Returns:

  • (Boolean)


50
51
52
# File 'lib/lazylead/task/accuracy/servers.rb', line 50

def url?(text)
  text.include?("http://") || text.include?("https://")
end