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, :timeout => timeout
  else
    RestClient.get "#{api_ssl_url(username, password)}/tokens/active", :timeout => timeout
  end
  @token= Nokogiri::XML(response.body).search('guid').inner_html
end

.tracker_hostObject


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

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


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

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

.api_urlObject


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

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

.clear_connectionsObject


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

def clear_connections
  @connections = nil
end

.connection(options = {}) ⇒ Object

this is your connection for the entire module

Raises:


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

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

  @connections ||= {}

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

.timeoutObject


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

def timeout
  @timeout ||= 60
end

.timeout=(timeout) ⇒ Object


23
24
25
# File 'lib/pivotal-tracker/client.rb', line 23

def timeout=(timeout)
  @timeout = timeout
end