Class: Torque::ProjectManager
- Inherits:
-
Object
- Object
- Torque::ProjectManager
- Defined in:
- lib/torque/project/project_manager.rb
Overview
Retrieves the list of Pivotal Tracker projects from the Pivotal API, automates the switching of projects
Instance Method Summary collapse
-
#current_project ⇒ Object
The current project if ‘load_project_list’ has been called and one exists, else returns nil.
-
#format_project_list ⇒ Object
Prepends an asterisk to the current project.
-
#initialize(torque_info_parser = TorqueInfoParser.new) ⇒ ProjectManager
constructor
A new instance of ProjectManager.
-
#load_project_list(token = nil) ⇒ Object
Requests and processes the project list from the Pivotal Tracker API.
-
#project_list ⇒ Object
Does not do any processing.
Constructor Details
#initialize(torque_info_parser = TorqueInfoParser.new) ⇒ ProjectManager
Returns a new instance of ProjectManager.
24 25 26 |
# File 'lib/torque/project/project_manager.rb', line 24 def initialize(torque_info_parser=TorqueInfoParser.new) @torque_info_parser = torque_info_parser end |
Instance Method Details
#current_project ⇒ Object
Returns The current project if ‘load_project_list’ has been called and one exists, else returns nil.
48 49 50 51 52 |
# File 'lib/torque/project/project_manager.rb', line 48 def current_project @project_list.nil? \ ? nil : @project_list.select{|project| project.current}[0] end |
#format_project_list ⇒ Object
Prepends an asterisk to the current project
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/torque/project/project_manager.rb', line 58 def format_project_list list_str = "PROJECTS\n" @project_list.each do |project| project.current \ ? list_str += "* " \ : list_str += " " list_str += "#{project.id} #{project.name}" list_str += "\n" end list_str end |
#load_project_list(token = nil) ⇒ Object
Requests and processes the project list from the Pivotal Tracker API
33 34 35 36 |
# File 'lib/torque/project/project_manager.rb', line 33 def load_project_list(token=nil) get_project_list(token) @project_list end |
#project_list ⇒ Object
Does not do any processing
42 43 44 |
# File 'lib/torque/project/project_manager.rb', line 42 def project_list @project_list end |