Class: Redpomo::Tracker
- Inherits:
-
Object
- Object
- Redpomo::Tracker
- Defined in:
- lib/redpomo/tracker.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #close_issue!(id, message = nil) ⇒ Object
- #create_issue!(issue) ⇒ Object
-
#initialize(name, options) ⇒ Tracker
constructor
A new instance of Tracker.
- #issue_priority_id(priority_val) ⇒ Object
- #issues ⇒ Object
- #push_entry!(entry) ⇒ Object
- #pushable_entry?(entry) ⇒ Boolean
- #todo_priority(priority_name) ⇒ Object
Constructor Details
#initialize(name, options) ⇒ Tracker
Returns a new instance of Tracker.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/redpomo/tracker.rb', line 25 def initialize(name, ) .symbolize_keys! @name = name @base_url = [:url] @api_key = [:token] @default_project_id = [:default_project_id] @default_priority_id = [:default_priority_id] @closed_status_id = [:closed_status_id].to_i @default_activity_id = [:default_activity_id] @priorities = [:priority_ids] end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
23 24 25 |
# File 'lib/redpomo/tracker.rb', line 23 def base_url @base_url end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/redpomo/tracker.rb', line 23 def name @name end |
Class Method Details
Instance Method Details
#close_issue!(id, message = nil) ⇒ Object
85 86 87 88 89 |
# File 'lib/redpomo/tracker.rb', line 85 def close_issue!(id, = nil) issue = { status_id: @closed_status_id } issue[:notes] = if .present? put("/issues/#{id}", issue: issue) end |
#create_issue!(issue) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/redpomo/tracker.rb', line 59 def create_issue!(issue) data = { subject: issue.subject, description: issue.description, due_date: issue.due_date, project_id: issue.project_id || @default_project_id, priority_id: issue.priority_id || @default_priority_id, assigned_to_id: current_user_id } post("/issues", issue: data) end |
#issue_priority_id(priority_val) ⇒ Object
45 46 47 48 49 |
# File 'lib/redpomo/tracker.rb', line 45 def issue_priority_id(priority_val) if index = ('A' .. 'Z').to_a.index(priority_val) @priorities[index] end end |
#issues ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/redpomo/tracker.rb', line 51 def issues data = get("/issues", assigned_to_id: current_user_id, status_id: "open", limit: 100) data["issues"].map do |issue| issue["project_id"] = project_identifier_for(issue["project"]["id"]) Issue.new(self, issue) end end |
#push_entry!(entry) ⇒ Object
81 82 83 |
# File 'lib/redpomo/tracker.rb', line 81 def push_entry!(entry) post("/time_entries", time_entry: entry_data(entry)) end |
#pushable_entry?(entry) ⇒ Boolean
72 73 74 75 76 77 78 79 |
# File 'lib/redpomo/tracker.rb', line 72 def pushable_entry?(entry) data = entry_data(entry) if data[:project_id] project_exists?(data[:project_id]) else issue_exists?(data[:issue_id]) end end |
#todo_priority(priority_name) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/redpomo/tracker.rb', line 37 def todo_priority(priority_name) return nil if @priorities.nil? alphabet = ('A' .. 'Z').to_a.join if index = @priorities.index(priority_name) "(#{alphabet[index]})" end end |