Class: Pivotal::Connection
- Inherits:
-
Object
- Object
- Pivotal::Connection
- 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']
- COOKIE_FILE =
'pivotal_session.txt'
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#logged_in ⇒ Object
Returns the value of attribute logged_in.
-
#password ⇒ Object
Returns the value of attribute password.
Instance Method Summary collapse
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
- #login ⇒ Object
- #post_form(data, path) ⇒ Object
Constructor Details
#initialize ⇒ Connection
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
#email ⇒ Object
Returns the value of attribute email.
14 15 16 |
# File 'lib/pivotal/connection.rb', line 14 def email @email end |
#logged_in ⇒ Object
Returns the value of attribute logged_in.
14 15 16 |
# File 'lib/pivotal/connection.rb', line 14 def logged_in @logged_in end |
#password ⇒ Object
Returns the value of attribute password.
14 15 16 |
# File 'lib/pivotal/connection.rb', line 14 def password @password end |
Instance Method Details
#login ⇒ Object
20 21 22 23 |
# File 'lib/pivotal/connection.rb', line 20 def login `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) login unless @logged_in `curl -b #{COOKIE_FILE} -c #{COOKIE_FILE} -d '#{data}' #{HOST}/#{path}` end |