Class: BetterJira::JiraIssue

Inherits:
Object
  • Object
show all
Defined in:
lib/better_jira/jira_issue.rb

Constant Summary collapse

FIELDS =
[:summary, :description]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(soap_jira_issue, jira) ⇒ JiraIssue

Returns a new instance of JiraIssue.



7
8
9
10
11
12
13
14
15
# File 'lib/better_jira/jira_issue.rb', line 7

def initialize(soap_jira_issue, jira)
  @soap_jira_issue = soap_jira_issue
  @jira = jira
  @changes = []
  @custom_fields = {}
  @soap_jira_issue.customFieldValues.each { |cf|
    @custom_fields[cf.customfieldId] = cf.values
  }
end

Instance Attribute Details

#custom_fieldsObject (readonly)

Returns the value of attribute custom_fields.



3
4
5
# File 'lib/better_jira/jira_issue.rb', line 3

def custom_fields
  @custom_fields
end

Instance Method Details

#[](key) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/better_jira/jira_issue.rb', line 48

def [](key)
  if (key.to_s =~ /customfield_/) then
    BetterJira::custom_field_values(@soap_jira_issue, key.to_s)
  elsif (Symbol === key) then
    begin
      @soap_jira_issue.send "[]", key.to_s
    rescue NoMethodError => e
      nil
    end
  else
  
  end
end

#add_comment(comment, options = {}) ⇒ Object

Adds a comment to the issue



81
82
83
# File 'lib/better_jira/jira_issue.rb', line 81

def add_comment(comment, options={})
  @jira.add_comment(self[:key], comment, options)
end

#available_actionsObject

Returns a list of available actions for this issue



67
68
69
70
71
# File 'lib/better_jira/jira_issue.rb', line 67

def available_actions
  ret = {}
  @jira.available_actions(self[:key]).each{|q| ret[q['id']] = q['name']}
  ret
end

#field_as_date_time(key) ⇒ Object



62
63
64
# File 'lib/better_jira/jira_issue.rb', line 62

def field_as_date_time(key)
  BetterJira::custom_field_value_as_date_time(@soap_jira_issue, key.to_s)
end

#field_value(key) ⇒ Object



38
39
40
41
42
# File 'lib/better_jira/jira_issue.rb', line 38

def field_value(key)
  r = self[key]
  r = r.first unless (r.nil?)
  return r
end

#field_values(key) ⇒ Object



44
45
46
# File 'lib/better_jira/jira_issue.rb', line 44

def field_values(key)
  self[key]
end

#fields_for_action_id(action_id) ⇒ Object

Returns a list of fields for a particular action_id



74
75
76
77
78
# File 'lib/better_jira/jira_issue.rb', line 74

def fields_for_action_id(action_id)
  ret = {}
  @jira.fields_for_action(self[:key], action_id).each {|q| ret[q['id']] = q['name']}
  ret
end

#fields_for_action_name(action_name) ⇒ Object



85
86
87
88
# File 'lib/better_jira/jira_issue.rb', line 85

def fields_for_action_name(action_name)
  action = available_actions.find {|k, v| v == action_name}
  fields_for_action_id(action[0])
end

#fields_for_editObject



91
92
93
# File 'lib/better_jira/jira_issue.rb', line 91

def fields_for_edit
  BetterJira::array_of_remote_fields_to_map(@jira.get_fields_for_edit(self[:key]))
end

#progress_workflow(workflow_action_id, custom_field_values, opts = {}) ⇒ Object



95
96
97
# File 'lib/better_jira/jira_issue.rb', line 95

def progress_workflow(workflow_action_id, custom_field_values, opts = {})
  @jira.progress_workflow(self[:key], workflow_action_id, custom_field_values, opts)
end

#update_fields(fields) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/better_jira/jira_issue.rb', line 17

def update_fields(fields)
  fields[:fixVersions] = fields[:fix_versions] if fields.has_key? :fix_versions
  fields[:versions] = fields[:affects_versions] if fields.has_key? :affects_versions

  fields.each {|k,v|
    case k
      when :fixVersions then
        fields[k] = @jira.map_version_fields(self[:project], v)
      when :versions
        fields[k] = @jira.map_version_fields(self[:project], v)
    end
  }


  fields = fields.map {|k,v|
    {:id => k, :values => BetterJira::convert_custom_field_value_to_happy_jira_time(v)}
  }
  @jira.update_issue(self[:key], fields)
  initialize(@jira.get_issue(self[:key]), @jira)
end