Class: TaskMapper::Provider::Basecamp::Project

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

Overview

Project class for taskampper-basecamp

Remaps

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

Constant Summary collapse

API =
::Basecamp::Project

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*backend_info) ⇒ Project

Returns a new instance of Project.



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

def initialize(*backend_info) 
  @system_data ||= {}
  data = backend_info.first
  case data 
  when Hash
    super data.to_hash
  else
    @system_data[:client] = data
    super data.attributes
  end
end

Class Method Details

.find_by_attributes(attributes = {}) ⇒ Object



49
50
51
# File 'lib/provider/project.rb', line 49

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

.find_by_id(id) ⇒ Object



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

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

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



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

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



59
60
61
62
63
64
65
66
67
# File 'lib/provider/project.rb', line 59

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



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

def created_at
  created_on.to_time
rescue
  created_on
end

#descriptionObject



25
26
27
# File 'lib/provider/project.rb', line 25

def description
  announcement
end

#ticket!(attributes_hash) ⇒ Object



41
42
43
# File 'lib/provider/project.rb', line 41

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

#updated_atObject



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

def updated_at
  last_changed_on.to_time
rescue
  last_changed_on
end