Class: Lazylead::Task::Accuracy

Inherits:
Object
  • Object
show all
Defined in:
lib/lazylead/task/accuracy/accuracy.rb

Overview

Evaluate ticket format and accuracy

The task supports the following features:

- fetch issues from remote ticketing system by query
- evaluate each field within the ticket
- post the score to the ticket

Instance Method Summary collapse

Constructor Details

#initialize(log = Log.new) ⇒ Accuracy

Returns a new instance of Accuracy.



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

def initialize(log = Log.new)
  @log = log
end

Instance Method Details

#init_rules(opts) ⇒ Object

Initialize accuracy rules and configuration for tickets verification.



63
64
65
66
67
68
# File 'lib/lazylead/task/accuracy/accuracy.rb', line 63

def init_rules(opts)
  Requires.new(__dir__).load
  opts[:rules] = opts.construct("rules")
  opts[:total] = opts[:rules].sum(&:score)
  opts[:memes] = Memes.new(opts["memes"])
end

#run(sys, postman, opts) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/lazylead/task/accuracy/accuracy.rb', line 47

def run(sys, postman, opts)
  init_rules(opts)
  tasks = sys.issues(opts["jql"], opts.jira_defaults.merge(expand: "changelog"))
             .map { |i| Score.new(i, opts) }
             .each do |s|
    s.evaluate
    s.post
  end
  unless tasks.empty? && tasks.size <= opts.fetch(:limit, 300).to_i
    opts[:tickets] = tasks
    postman.send(opts)
  end
  opts
end