Class: TaskMapper::Provider::Kanbanpad::Project

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

Overview

Project class for taskmapper-kanbanpad

Constant Summary collapse

API =

declare needed overloaded methods here

KanbanpadAPI::Project
COMMENT_API =
KanbanpadAPI::ProjectComment

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Project

Returns a new instance of Project.



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

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

Instance Method Details

#comment!(attributes) ⇒ Object



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

def comment!(attributes)
  comment = create_comment attributes
  Comment.new(comment.attributes.merge :project_id => id) if comment.save
end

#commentsObject



68
69
70
# File 'lib/provider/project.rb', line 68

def comments
  find_comments.map { |c| Comment.new c.attributes }
end

#copy(project) ⇒ Object

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



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

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



47
48
49
50
51
52
53
# File 'lib/provider/project.rb', line 47

def created_at
  begin
    Time.parse(self[:created_at])
  rescue
    self[:created_at]
  end
end

#idObject



39
40
41
# File 'lib/provider/project.rb', line 39

def id
  self[:slug]
end

#ticket!(attributes) ⇒ Object



43
44
45
# File 'lib/provider/project.rb', line 43

def ticket!(attributes)
  Ticket.create(attributes.merge!(:project_id => id))
end

#updated_atObject



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

def updated_at
  begin
    Time.parse(self[:updated_at])
  rescue
    self[:updated_at]
  end
end