Class: TaskMapper::Provider::Pivotal::Project

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

Overview

Project class for taskmapper-pivotal

Constant Summary collapse

API =
PivotalAPI::Project

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*options) ⇒ Project

Returns a new instance of Project.



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

def initialize(*options)
  super(*options)
  self.id = self.id.to_i
end

Instance Attribute Details

#prefix_optionsObject

The finder method

It accepts all the find functionalities defined by taskmapper

+ find() and find(:all) - Returns all projects on the account + find(<project_id>) - Returns the project based on the id + find(:first, :name => <project_name>) - Returns the first project based on the attribute + find(:name => <project name>) - Returns all projects based on the attribute



16
17
18
# File 'lib/provider/project.rb', line 16

def prefix_options
  @prefix_options
end

Instance Method Details

#copy(project) ⇒ Object

copy from



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

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

#destroyObject

Delete this project



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

def destroy
  result = self.system_data[:client].destroy
  result.is_a?(Net::HTTPOK)
end

#saveObject

Save this project



21
22
23
24
# File 'lib/provider/project.rb', line 21

def save
  warn 'Warning: Pivotal does not allow editing of project attributes. This method does nothing.'
  true
end

#ticket!(*options) ⇒ Object



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

def ticket!(*options)
  options.first.merge!(:project_id => self.id)
  Ticket.create(options.first)
end