Class: TicketMaster::Provider::Basecamp::Project

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

Overview

Project class for ticketmaster-basecamp

Remaps

description => announcement created_at => created_on updated_at => last_changed_on

Constant Summary collapse

API =
BasecampAPI::Project

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Project

Returns a new instance of Project.


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

def initialize(*object) 
  if object.first 
    object = object.first
    unless object.is_a? Hash
      hash = {:id => object.id,
              :created_at => created_on,
              :updated_at => updated_on,
              :description => object.announcement,
              :name => object.name}

    else
      hash = object
    end
    super hash
  end
end

Class Method Details

.find_by_attributes(attributes = {}) ⇒ Object


70
71
72
# File 'lib/provider/project.rb', line 70

def self.find_by_attributes(attributes = {})
  self.search(attributes)
end

.find_by_id(id) ⇒ Object


66
67
68
# File 'lib/provider/project.rb', line 66

def self.find_by_id(id)
  self.new API.find(id)
end

.search(options = {}, limit = 1000) ⇒ Object


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

def self.search(options = {}, limit = 1000)
  projects = API.find(:all).collect { |project| self.new project }
  search_by_attribute(projects, options, limit)
end

Instance Method Details

#copy(project) ⇒ Object

copy from this.copy(that) copies that into this


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

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

#created_atObject


38
39
40
41
42
43
44
# File 'lib/provider/project.rb', line 38

def created_at
  begin
    created_on.to_time
  rescue
    created_on
  end
end

#created_at=(created) ⇒ Object


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

def created_at=(created)
  created_on = created
end

#descriptionObject


30
31
32
# File 'lib/provider/project.rb', line 30

def description
  announcement
end

#description=(desc) ⇒ Object


34
35
36
# File 'lib/provider/project.rb', line 34

def description=(desc)
  announcement = desc
end

#ticket!(attributes_hash) ⇒ Object


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

def ticket!(attributes_hash)
  provider_parent(self.class)::Ticket.create attributes_hash.merge :project_id => id
end

#updated_atObject


50
51
52
53
54
55
56
# File 'lib/provider/project.rb', line 50

def updated_at
  begin
    last_changed_on.to_time
  rescue
    last_changed_on
  end
end

#updated_at=(updated) ⇒ Object


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

def updated_at=(updated)
  last_changed_on = updated
end