Class: Pivotal::Connection

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/pivotal/connection.rb

Constant Summary collapse

HOST =
'https://www.pivotaltracker.com'
EMAIL =
ENV['PIVOTAL_EMAIL']
PASSWORD =
ENV['PIVOTAL_PASSWORD']
PERSON_ID =
ENV['PIVOTAL_PERSON_ID']
PROJECT_ID =
ENV['PIVOTAL_PROJECT_ID']
'pivotal_session.txt'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConnection

Returns a new instance of Connection.



16
17
18
# File 'lib/pivotal/connection.rb', line 16

def initialize
  @logged_in = false
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



14
15
16
# File 'lib/pivotal/connection.rb', line 14

def email
  @email
end

#logged_inObject

Returns the value of attribute logged_in.



14
15
16
# File 'lib/pivotal/connection.rb', line 14

def logged_in
  @logged_in
end

#passwordObject

Returns the value of attribute password.



14
15
16
# File 'lib/pivotal/connection.rb', line 14

def password
  @password
end

Instance Method Details

#loginObject



20
21
22
23
# File 'lib/pivotal/connection.rb', line 20

def 
  `curl -c #{COOKIE_FILE} -d 'credentials[username]=#{EMAIL}&credentials[password]=#{PASSWORD}' #{HOST}/signin` unless @logged_in
  @logged_in = true
end

#post_form(data, path) ⇒ Object



25
26
27
28
# File 'lib/pivotal/connection.rb', line 25

def post_form(data, path)
   unless @logged_in
  `curl -b #{COOKIE_FILE} -c #{COOKIE_FILE} -d '#{data}' #{HOST}/#{path}`
end