Class: PivotalTracker::Project

Inherits:
Object
  • Object
show all
Includes:
HappyMapper, Validation
Defined in:
lib/pivotal-tracker/project.rb,
lib/pivotal-tracker/project.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Validation

#create_with_validations, #errors, included, #update_with_validations

Constructor Details

#initialize(attributes = {}) ⇒ Project

Returns a new instance of Project.



38
39
40
# File 'lib/pivotal-tracker/project.rb', line 38

def initialize(attributes={})
  update_attributes(attributes)
end

Class Method Details

.allObject



6
7
8
# File 'lib/pivotal-tracker/project.rb', line 6

def all
  @found = parse(Client.connection['/projects'].get)
end

.find(id) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/pivotal-tracker/project.rb', line 10

def find(id)
  if @found
    @found.detect { |document| document.id == id }
  else
    parse(Client.connection["/projects/#{id}"].get)
  end
end

.parse_projects(xml_string) ⇒ Object



18
19
20
# File 'lib/pivotal-tracker/project.rb', line 18

def parse_projects(xml_string)
  parse(xml_string)
end

Instance Method Details

#activitiesObject



48
49
50
# File 'lib/pivotal-tracker/project.rb', line 48

def activities
  @activities ||= Proxy.new(self, Activity)
end

#createObject



42
43
44
45
46
# File 'lib/pivotal-tracker/project.rb', line 42

def create
  response = Client.connection["/projects"].post(self.to_xml, :content_type => 'application/xml')
  project = Project.parse(response)
  return project
end

#iteration(group) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/pivotal-tracker/project.rb', line 64

def iteration(group)
  case group.to_sym
  when :done then Iteration.done(self)
  when :current then Iteration.current(self)
  when :backlog then Iteration.backlog(self)
  when :current_backlog then Iteration.current_backlog(self)
  else
    raise ArgumentError, "Invalid group. Use :done, :current, :backlog or :current_backlog instead."
  end
end

#iterationsObject



52
53
54
# File 'lib/pivotal-tracker/project.rb', line 52

def iterations
  @iterations ||= Proxy.new(self, Iteration)
end

#membershipsObject



60
61
62
# File 'lib/pivotal-tracker/project.rb', line 60

def memberships
  @memberships ||= Proxy.new(self, Membership)
end

#storiesObject



56
57
58
# File 'lib/pivotal-tracker/project.rb', line 56

def stories
  @stories ||= Proxy.new(self, Story)
end