Class: Lazylead::Task::Version

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

Overview

Instance of “Fix Version” field for the particular task.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue, allowed) ⇒ Version



52
53
54
55
# File 'lib/lazylead/task/fix_version.rb', line 52

def initialize(issue, allowed)
  @issue = issue
  @allowed = allowed
end

Instance Attribute Details

#issueObject (readonly)

Returns the value of attribute issue.



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

def issue
  @issue
end

Instance Method Details

#changed?Boolean

Gives true when last change of “Fix Version” field was done

by not authorized person.


59
60
61
62
63
64
# File 'lib/lazylead/task/fix_version.rb', line 59

def changed?
  @allowed.none? do |a|
    return false if last.nil?
    a == last["author"]["name"]
  end
end

#lastObject

Detect details about last change of “Fix Version” to non-null value



67
68
69
70
71
72
73
74
75
76
# File 'lib/lazylead/task/fix_version.rb', line 67

def last
  return @last if defined? @last
  @last = issue.history
               .reverse
               .find do |h|
    h["items"].any? do |i|
      i["field"] == "Fix Version" && !i["to"].nil?
    end
  end
end