Class: TaskMapper::Provider::Bugzilla::Ticket

Inherits:
TaskMapper::Provider::Base::Ticket
  • Object
show all
Defined in:
lib/provider/ticket.rb

Overview

Ticket class for taskmapper-bugzilla

Constant Summary collapse

TICKETS_API =

declare needed overloaded methods here

Rubyzilla::Product

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Ticket

Returns a new instance of Ticket.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/provider/ticket.rb', line 9

def initialize(*object)
  return super(object.first) if object.first.is_a? Hash
  if object.first
    object = object.first
    unless object.is_a? Hash
      @system_data = {:client => object}
      hash = {:product_id => object.product_id,
        :id => object.id,
        :project_id => object.product_id,
        :component_id => object.component_id,
        :summary => object.summary,
        :title => object.summary,
        :version => object.version,
        :op_sys => object.op_sys,
        :platform => object.platform,
        :priority => object.priority,
        :description => object.description,
        :alias => object.alias,
        :qa_contact => object.qa_contact,
        :assignee => object.assigned_to,
        :requestor => object.qa_contact,
        :status => object.status,
        :target_milestone => object.target_milestone,
        :severity => object.severity,
        :created_at => nil,
        :updated_at => nil}
    else
      hash = object
    end
    super hash
  end
end

Class Method Details

.create(project_id, *options) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/provider/ticket.rb', line 90

def self.create(project_id, *options)
  begin
    bug = Rubyzilla::Bug.new   
    bug.product = TICKETS_API.new project_id
    options.first.each_pair do |k, v|
      bug.send "#{k}=", v
    end
    self.new bug.create
  rescue
    self.find(project_id, []).last
  end
end

.find(project_id, *options) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/provider/ticket.rb', line 79

def self.find(project_id, *options)
  if options.first.empty?
    TICKETS_API.new(project_id).bugs.collect { |bug| self.new bug }
  elsif options[0].first.is_a? Array
   options[0].first.collect { |bug_id| self.find_by_id bug_id }
  elsif options[0].first.is_a? Hash
    bugs = TICKETS_API.new(project_id).bugs.collect { |bug| self.new bug }
    search_by_attribute(bugs, options[0].first)
  end
end

.find_by_id(id) ⇒ Object



74
75
76
77
# File 'lib/provider/ticket.rb', line 74

def self.find_by_id(id)
  bug = Rubyzilla::Bug.new id
  self.new bug
end

Instance Method Details

#assigneeObject



54
55
56
# File 'lib/provider/ticket.rb', line 54

def assignee
  self[:assignee]
end

#comment(*options) ⇒ Object



107
108
109
# File 'lib/provider/ticket.rb', line 107

def comment(*options)
  Comment.find_by_id(self.id, options.first)
end

#comments(*options) ⇒ Object



103
104
105
# File 'lib/provider/ticket.rb', line 103

def comments(*options)
  Comment.find(self.id, options)
end

#created_atObject



58
59
60
61
62
63
64
# File 'lib/provider/ticket.rb', line 58

def created_at
  begin
    normalize_datetime(self[:last_change_time])
  rescue
    self[:created_at]
  end
end

#descriptionObject



46
47
48
# File 'lib/provider/ticket.rb', line 46

def description
  self[:description]
end

#requestorObject



50
51
52
# File 'lib/provider/ticket.rb', line 50

def requestor
  self[:requestor]
end

#titleObject



42
43
44
# File 'lib/provider/ticket.rb', line 42

def title
  self[:summary]
end

#updated_atObject



66
67
68
69
70
71
72
# File 'lib/provider/ticket.rb', line 66

def updated_at
  begin
    normalize_datetime(self[:last_change_time])
  rescue
    self[:updated_at]
  end
end