Class: TrackerDeliveries::PivotalTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal_tracker.rb

Constant Summary collapse

PIVOTAL_API_URL =
'https://www.pivotaltracker.com/services/v5/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of PivotalTracker.



9
10
11
12
13
14
15
# File 'lib/pivotal_tracker.rb', line 9

def initialize project_id, api_key, options = {}
  @api_key = api_key
  @project_id = project_id
  @format_tools = TrackerDeliveries::FormatTools.new options[:format] || :plaintext
  @api = Blanket.wrap PIVOTAL_API_URL,
                      headers: { 'X-TrackerToken' => @api_key }
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



7
8
9
# File 'lib/pivotal_tracker.rb', line 7

def api
  @api
end

Instance Method Details

#delivered_storiesObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/pivotal_tracker.rb', line 17

def delivered_stories
  options = {with_state: "delivered"}
  wrap_output(api
                .projects(@project_id)
                .stories
                .get(params: options)
                .payload
                .map{|s| story_formatter s }
                .join("\n"))
end

#story_formatter(story) ⇒ Object



32
33
34
# File 'lib/pivotal_tracker.rb', line 32

def story_formatter story
  @format_tools.story_formatter story
end

#wrap_output(output) ⇒ Object



28
29
30
# File 'lib/pivotal_tracker.rb', line 28

def wrap_output output
  @format_tools.wrap_output output
end