Class: PivotalTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal-tracker.rb

Instance Method Summary collapse

Constructor Details

#initialize(project_id, token, options = {}) ⇒ PivotalTracker

Returns a new instance of PivotalTracker.



21
22
23
24
25
26
# File 'lib/pivotal-tracker.rb', line 21

def initialize(project_id, token, options = {})
  @project_id, @token = project_id, token

  @base_url = "http://www.pivotaltracker.com/services/v2" 
  @base_url.gsub! 'http', 'https'  if options[:use_ssl]
end

Instance Method Details

#create_note(id, note) ⇒ Object



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

def create_note(id, note)
  story_resource(id)["/notes"].post note.to_xml
end

#create_story(story) ⇒ Object



87
88
89
# File 'lib/pivotal-tracker.rb', line 87

def create_story(story)
  stories_resource.post story.to_xml
end

#create_task(id, task) ⇒ Object



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

def create_task(id, task)
  story_resource(id)["/tasks"].post task.to_xml
end

#current_iterationObject



66
67
68
69
# File 'lib/pivotal-tracker.rb', line 66

def current_iteration
  response = iterations_resource("/current").get
  Iteration.parse(response).first
end

#delete_story(story) ⇒ Object



95
96
97
# File 'lib/pivotal-tracker.rb', line 95

def delete_story(story)
  story_resource(story).delete
end

#deliver_all_finished_storiesObject



99
100
101
102
# File 'lib/pivotal-tracker.rb', line 99

def deliver_all_finished_stories
  response = stories_resource['/deliver_all_finished'].put ''
  Story.parse(response)
end

#find(*filters) ⇒ Object



76
77
78
79
80
# File 'lib/pivotal-tracker.rb', line 76

def find(*filters)
  filter_query = CGI::escape coerce_to_filter(filters)
  response = stories_resource["?filter=#{filter_query}"].get
  Story.parse(response)
end

#find_story(id) ⇒ Object



82
83
84
85
# File 'lib/pivotal-tracker.rb', line 82

def find_story(id)
  response = story_resource(id).get
  Story.parse(response)
end

#find_task(story_id, task_id) ⇒ Object



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

def find_task(story_id, task_id)
  response = story_resource(story_id)["/tasks/#{task_id}"].get
  Task.parse(response)
end

#iterationsObject



71
72
73
74
# File 'lib/pivotal-tracker.rb', line 71

def iterations
  response = iterations_resource.get
  Iteration.parse(response)
end

#notes(id) ⇒ Object



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

def notes(id)
  response = story_resource(id)["/notes"].get
  Note.parse(response)
end

#projectObject



28
29
30
31
# File 'lib/pivotal-tracker.rb', line 28

def project
  response = project_resource.get
  Project.parse(response)
end

#storiesObject



33
34
35
36
# File 'lib/pivotal-tracker.rb', line 33

def stories
  response = stories_resource.get
  Story.parse(response)
end

#tasks(id) ⇒ Object



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

def tasks(id)
  response = story_resource(id)["/tasks"].get
  Task.parse(response)
end

#update_story(story) ⇒ Object



91
92
93
# File 'lib/pivotal-tracker.rb', line 91

def update_story(story)
  story_resource(story).put story.to_xml
end

#update_task(story_id, task) ⇒ Object



61
62
63
64
# File 'lib/pivotal-tracker.rb', line 61

def update_task(story_id, task)
  task_id = task.id
  story_resource(id)["/tasks/#{task_id}"].put task.to_xml
end