class PivotalTracker::Client

Attributes

api_version[W]
token[W]
tracker_host[W]
use_ssl[W]

Public Class Methods

api_ssl_url(user=nil, password=nil) click to toggle source
# File lib/pivotal-tracker/client.rb, line 39
def api_ssl_url(user=nil, password=nil)
  user_password = (user && password) ? "#{user}:#{password}@" : ''
  "https://#{user_password}#{tracker_host}#{api_path}"
end
api_url() click to toggle source
# File lib/pivotal-tracker/client.rb, line 44
def api_url
  "http://#{tracker_host}#{api_path}"
end
api_version() click to toggle source
# File lib/pivotal-tracker/client.rb, line 48
def api_version
  @api_version ||= 3
end
clear_connections() click to toggle source
# File lib/pivotal-tracker/client.rb, line 31
def clear_connections
  @connections = nil
end
connection(options={}) click to toggle source

this is your connection for the entire module

# File lib/pivotal-tracker/client.rb, line 23
def connection(options={})
  raise NoToken if @token.to_s.empty?

  @connections ||= {}

  cached_connection? && !protocol_changed? ? cached_connection : new_connection
end
token(username, password, method='post') click to toggle source
# File lib/pivotal-tracker/client.rb, line 13
def token(username, password, method='post')
  response = if method == 'post'
    RestClient.post api_ssl_url + '/tokens/active', :username => username, :password => password
  else
    RestClient.get "#{api_ssl_url(username, password)}/tokens/active"
  end
  @token= Nokogiri::XML(response.body).search('guid').inner_html
end
tracker_host() click to toggle source
# File lib/pivotal-tracker/client.rb, line 35
def tracker_host
  @tracker_host ||= "www.pivotaltracker.com"
end
use_ssl() click to toggle source
# File lib/pivotal-tracker/client.rb, line 9
def use_ssl
  @use_ssl || false
end

Protected Class Methods

api_path() click to toggle source
# File lib/pivotal-tracker/client.rb, line 78
def api_path
  '/services/v' + api_version.to_s
end
cached_connection() click to toggle source
# File lib/pivotal-tracker/client.rb, line 62
def cached_connection
  @connections[@token]
end
cached_connection?() click to toggle source
# File lib/pivotal-tracker/client.rb, line 58
def cached_connection?
  !@connections[@token].nil?
end
cached_connection_protocol() click to toggle source
# File lib/pivotal-tracker/client.rb, line 74
def cached_connection_protocol
  cached_connection.url.match(/^(.*):\/\//).captures.first
end
new_connection() click to toggle source
# File lib/pivotal-tracker/client.rb, line 66
def new_connection
  @connections[@token] = RestClient::Resource.new("#{use_ssl ? api_ssl_url : api_url}", :headers => {'X-TrackerToken' => @token, 'Content-Type' => 'application/xml'})
end
protocol() click to toggle source
# File lib/pivotal-tracker/client.rb, line 54
def protocol
  use_ssl ? 'https' : 'http'
end
protocol_changed?() click to toggle source
# File lib/pivotal-tracker/client.rb, line 70
def protocol_changed?
  cached_connection? ? (cached_connection_protocol != protocol) : false
end