Class: Octopolo::Pivotal::Client

Inherits:
Object
  • Object
show all
Includes:
UserConfigWrapper
Defined in:
lib/octopolo/pivotal.rb

Overview

NOTE Should probably extract out to

Instance Attribute Summary

Attributes included from UserConfigWrapper

#user_config

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Public: Initialize a new instance of Pivotal::Client wrapper class



10
11
12
13
14
15
16
17
18
19
# File 'lib/octopolo/pivotal.rb', line 10

def initialize
  # no idea why this is off by default (as of 2013-04-18)
  ::PivotalTracker::Client.use_ssl = true
  begin
    ::PivotalTracker::Client.token = user_config.pivotal_token
  rescue UserConfig::MissingPivotalAuth
    Scripts::PivotalAuth.run
    ::PivotalTracker::Client.token = UserConfig.parse.pivotal_token
  end
end

Class Method Details

.fetch_token(email, password) ⇒ Object

Public: Fetch an API token for the given authentication

email - a String containing the email address used to log in password - a String containing the password

Returns a String or raises BadCredentials



27
28
29
30
31
# File 'lib/octopolo/pivotal.rb', line 27

def self.fetch_token(email, password)
  ::PivotalTracker::Client.token(email, password)
rescue RestClient::Unauthorized
  raise BadCredentials, "No token received from Pivotal Tracker. Please check your credentials and try again."
end

Instance Method Details

#find_story(story_id) ⇒ Object



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

def find_story(story_id)
  @projects = PivotalTracker::Project.all
  @projects.map{ |project| project.stories.find(story_id) }.compact.first || raise(StoryNotFound, "No Story was found with that ID in your Projects")
end