Class: Neoneo::User
- Inherits:
-
Object
- Object
- Neoneo::User
- Defined in:
- lib/neoneo.rb
Overview
The starting point for any use of the NeoNeo library.
Other than a Neoneo::Member iy represents a user of No Kahuna of wich you have the full login credentials.
To initialize a connection to No Kahuna start with:
Neoneo::User.new('User Name', 'Password')
Neoneo then loggs you in to No Kahuna and gathers some first informations about your projects, task counts and so on.
Unfortunately the initialization process needs to do actually three HTTP requests at the moment. First it sets your language to English, than it has to get the login form to be aware of the CSRF id to actually log you in in a third request, the submission of the login form.
Also there is no way to check the stay logged in option of No Kahuna yet. This is planned for a future version.
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#authenticity_token ⇒ Object
readonly
Returns the value of attribute authenticity_token.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
Instance Method Summary collapse
-
#initialize(user, pass) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(user, pass) ⇒ User
Returns a new instance of User.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/neoneo.rb', line 138 def initialize(user, pass) @agent = Agent.new @agent.post("#{BASE_URL}settings/use_locale?locale=en-US") page = @agent.get("#{BASE_URL}login") form = page.forms.first @authenticity_token = form.authenticity_token form.login = user form.password = pass page = @agent.submit(form) @projects = SingleSelectArray.new page.search('ul.projectList li a').each do |project_link| name = project_link.children.last.clean total_taks = project_link.search('span.taskCount span.total').first.clean own_tasks = project_link.search('span.taskCount').first.children.first.clean.gsub(/^(\d+)\s\//, '\1').to_i id = project_link.attributes['href'].gsub(/^#{PROJECT_URL}(\d+)\/.*$/, '\1') @projects << Project.new(id, name, total_taks, own_tasks, self) end end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
136 137 138 |
# File 'lib/neoneo.rb', line 136 def agent @agent end |
#authenticity_token ⇒ Object (readonly)
Returns the value of attribute authenticity_token.
136 137 138 |
# File 'lib/neoneo.rb', line 136 def authenticity_token @authenticity_token end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
136 137 138 |
# File 'lib/neoneo.rb', line 136 def projects @projects end |