Module: BetterJira

Defined in:
lib/better_jira/version.rb,
lib/better_jira/jira.rb,
lib/better_jira/utils.rb,
lib/better_jira/exceptions.rb,
lib/better_jira/jira_issue.rb,
lib/better_jira/jira_version.rb

Overview

Copyright © 2010 Eric Anderson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Modules: Exceptions Classes: Jira, JiraIssue, JiraVersion

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.array_of_remote_fields_to_map(remote_fields) ⇒ Hash

Converts an array of RemoteFields into a map of id => name

Returns:

  • (Hash)

    the converted map



31
32
33
34
35
# File 'lib/better_jira/utils.rb', line 31

def self.array_of_remote_fields_to_map(remote_fields)
  ret = {}
  remote_fields.each{|q| ret[q['id']] = q['name']}
  ret
end

.convert_custom_field_value_to_happy_jira_time(value) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/better_jira/utils.rb', line 43

def self.convert_custom_field_value_to_happy_jira_time(value)
  if (value != nil) then
    if (Array === value) then
      value = value.map { |x| 
        q = nil
        q = x if String === x
        q = x['id'] if SOAP::Mapping::Object === x
        q
      }
    elsif (SOAP::Mapping::Object === value) then
      value = [value['id']]
    elsif (String === value) then
      value = [value]
    elsif (DateTime === value) then
      value = [value.strftime('%d/%b/%y')]
    else
      value = [value.to_s]
    end
  end
end

.custom_field_value(issue, field, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/better_jira/utils.rb', line 12

def self.custom_field_value(issue, field, &block) 
  if (block == nil) then
    block = Proc.new {|x| x}
  end

  values = custom_field_values(issue, field)

  return block.call(values.first) if (values != nil)

  return nil
end

.custom_field_value_as_date_time(issue, field) ⇒ Object



24
25
26
# File 'lib/better_jira/utils.rb', line 24

def self.custom_field_value_as_date_time(issue, field)
  custom_field_value(issue, field) { |x| DateTime.parse(x, true) }
end

.custom_field_values(issue, field) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/better_jira/utils.rb', line 2

def self.custom_field_values(issue, field) 
  issue.customFieldValues.each { |cfv|
    if (cfv.customfieldId == field) then
      return cfv.values
    end
  }

  return nil
end

.simple_soap_mapping(a) ⇒ Object



37
38
39
40
41
# File 'lib/better_jira/utils.rb', line 37

def self.simple_soap_mapping(a)
  ret = {}
  a.each{|q| ret[q['id']] = q['name']}
  ret
end