Class: TaskMapper::Provider::Trac::Project

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

Overview

Project class for taskmapper-yoursystem

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Project

Returns a new instance of Project.



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

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

Instance Attribute Details

#created_atObject (readonly)

declare needed overloaded methods here



9
10
11
# File 'lib/provider/project.rb', line 9

def created_at
  @created_at
end

#updated_atObject (readonly)

declare needed overloaded methods here



9
10
11
# File 'lib/provider/project.rb', line 9

def updated_at
  @updated_at
end

Class Method Details

.find(*options) ⇒ Object



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

def self.find(*options)
  mode = options.first
  trac = TaskMapper::Provider::Trac.api
  if mode.is_a? String
    self.new({:url => trac[:url], :username => trac[:username], :name=> "#{trac[:username]}-project"})
  end
end

Instance Method Details

#copy(project) ⇒ Object

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



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

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



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

def id
  1
end

#ticket(*options) ⇒ Object



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

def ticket(*options)
  unless options.empty?
    options = options.first
    trac = TaskMapper::Provider::Trac.api
    if options.is_a? Hash
      Ticket.find_by_id(trac[:trac].tickets.query(options).first, self[:name])
    end
  else
    TaskMapper::Provider::Trac::Ticket
  end
end

#ticket!(*options) ⇒ Object



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

def ticket!(*options)
  options = options.first
  Ticket.create options
end

#tickets(*options) ⇒ Object



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

def tickets(*options)
  Ticket.find(self.name, options)
end