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, silent) ⇒ Version

Returns a new instance of Version.



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

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

Instance Attribute Details

#issueObject (readonly)

Returns the value of attribute issue.



56
57
58
# File 'lib/lazylead/task/fix_version.rb', line 56

def issue
  @issue
end

Instance Method Details

#add_labelObject



85
86
87
# File 'lib/lazylead/task/fix_version.rb', line 85

def add_label
  @issue.add_label("LL.IllegalChangeOfFixVersion") unless @silent
end

#changed?Boolean

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

by not authorized person.

Returns:

  • (Boolean)


66
67
68
69
70
71
# File 'lib/lazylead/task/fix_version.rb', line 66

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



74
75
76
77
78
79
80
81
82
83
# File 'lib/lazylead/task/fix_version.rb', line 74

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

#toObject



89
90
91
92
93
# File 'lib/lazylead/task/fix_version.rb', line 89

def to
  versions = @issue.fields["fixVersions"]
  return "" if versions.nil? || versions.empty?
  versions.map { |x| x["name"] }.join(",")
end