Class: PivotalTracker::Client

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

Defined Under Namespace

Classes: NoToken

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.token(username, password, method = 'post') ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/pivotal-tracker/client.rb', line 14

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_hostObject



36
37
38
# File 'lib/pivotal-tracker/client.rb', line 36

def tracker_host
  @tracker_host ||= "www.pivotaltracker.com"
end

.use_sslObject



10
11
12
# File 'lib/pivotal-tracker/client.rb', line 10

def use_ssl
  @use_ssl || false
end

Class Method Details

.api_ssl_url(user = nil, password = nil) ⇒ Object



40
41
42
43
# File 'lib/pivotal-tracker/client.rb', line 40

def api_ssl_url(user=nil, password=nil)
  user_password = (user && password) ? "#{user}:#{password}@" : ''
  "https://#{user_password}#{tracker_host}#{api_path}"
end

.api_urlObject



45
46
47
# File 'lib/pivotal-tracker/client.rb', line 45

def api_url
  "http://#{tracker_host}#{api_path}"
end

.clear_connectionsObject



32
33
34
# File 'lib/pivotal-tracker/client.rb', line 32

def clear_connections
  @connections = nil
end

.connection(options = {}) ⇒ Object

this is your connection for the entire module

Raises:



24
25
26
27
28
29
30
# File 'lib/pivotal-tracker/client.rb', line 24

def connection(options={})
  raise NoToken if @token.to_s.empty?

  @connections ||= {}

  cached_connection? && !protocol_changed? ? cached_connection : new_connection
end