Class: TicketMaster::Provider::Jira::Project

Inherits:
Base::Project
  • Object
show all
Defined in:
lib/provider/project.rb

Overview

Project class for ticketmaster-jira

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Project

API = Jira::Project # The class to access the api’s projects declare needed overloaded methods here copy from this.copy(that) copies that into this



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/provider/project.rb', line 10

def initialize(*object)
  if object.first
    object = object.first
    unless object.is_a? Hash
      @system_data = {:client => object}
      hash = {:id => object.id.to_i, 
              :name => object.name,
              :description => object.description,
              :updated_at => nil,
              :created_at => nil}
    else
      hash = object
    end
    super(hash)
  end
end

Class Method Details

.find(*options) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/provider/project.rb', line 41

def self.find(*options)
  if options[0].first.is_a? Array
    self.find_all.select do |project| 
      project if options.first.any? { |id| project.id == id }
    end
  elsif options[0].first.is_a? Hash
    find_by_attributes(options[0].first)
  else
    self.find_all
  end
end

.find_allObject



57
58
59
60
61
# File 'lib/provider/project.rb', line 57

def self.find_all
  $jira.getProjectsNoSchemes().map do |project| 
    Project.new project 
  end
end

.find_by_attributes(attributes = {}) ⇒ Object



53
54
55
# File 'lib/provider/project.rb', line 53

def self.find_by_attributes(attributes = {})
  search_by_attribute(self.find_all, attributes)
end

.find_by_id(id) ⇒ Object



63
64
65
# File 'lib/provider/project.rb', line 63

def self.find_by_id(id)
  self.find_all.select { |project| project.id == id }.first
end

Instance Method Details

#copy(project) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/provider/project.rb', line 31

def copy(project)
  project.tickets.each do |ticket|
    copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
    ticket.comments.each do |comment|
      copy_ticket.comment!(:body => comment.body)
      sleep 1
    end
  end
end

#idObject



27
28
29
# File 'lib/provider/project.rb', line 27

def id
  self[:id].to_i
end