Class: Lazylead::HasLabel

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

Overview

Check that ticket has specified label.

Instance Attribute Summary

Attributes inherited from Requirement

#desc, #field, #score

Instance Method Summary collapse

Methods inherited from Requirement

#blank?, #non_blank?

Constructor Details

#initialize(label, desc: "Has label", score: 0.5) ⇒ HasLabel

Returns a new instance of HasLabel.

Parameters:

  • label

    which should be present in ticket.



33
34
35
36
# File 'lib/lazylead/task/accuracy/has_label.rb', line 33

def initialize(label, desc: "Has label", score: 0.5)
  super(desc, score, "Labels")
  @label = label
end

Instance Method Details

#match?(label) ⇒ Boolean

Ensure that particular label matches expected label.

Returns:

  • (Boolean)


44
45
46
# File 'lib/lazylead/task/accuracy/has_label.rb', line 44

def match?(label)
  @label.eql? label
end

#passed(issue) ⇒ Object



38
39
40
41
# File 'lib/lazylead/task/accuracy/has_label.rb', line 38

def passed(issue)
  return false if issue.labels.empty?
  issue.labels.any? { |l| match?(l) }
end