Class: Redpomo::Task
- Inherits:
-
Object
- Object
- Redpomo::Task
- Defined in:
- lib/redpomo/task.rb
Constant Summary collapse
- ISSUES_REGEXP =
/(?:\s+|^)#[0-9]+/
Instance Method Summary collapse
- #add! ⇒ Object
- #close_issue!(message = nil) ⇒ Object
- #context ⇒ Object
- #done! ⇒ Object
-
#initialize(list, text) ⇒ Task
constructor
A new instance of Task.
- #issue ⇒ Object
- #open_in_browser! ⇒ Object
- #project ⇒ Object
- #start_pomodoro! ⇒ Object
- #text ⇒ Object
- #to_issue ⇒ Object
- #tracker ⇒ Object
- #url ⇒ Object
Constructor Details
Instance Method Details
#close_issue!(message = nil) ⇒ Object
51 52 53 |
# File 'lib/redpomo/task.rb', line 51 def close_issue!( = nil) tracker.close_issue!(issue, ) end |
#context ⇒ Object
29 30 31 32 33 |
# File 'lib/redpomo/task.rb', line 29 def context @task.contexts.map do |context| context.gsub /^@/, '' end.first end |
#done! ⇒ Object
55 56 57 |
# File 'lib/redpomo/task.rb', line 55 def done! @list.remove!(self) end |
#issue ⇒ Object
41 42 43 44 45 |
# File 'lib/redpomo/task.rb', line 41 def issue orig.scan(ISSUES_REGEXP).map(&:strip).map do |issue| issue.gsub(/^#/, '').to_i end.first end |
#open_in_browser! ⇒ Object
63 64 65 66 |
# File 'lib/redpomo/task.rb', line 63 def open_in_browser! require 'launchy' Launchy.open(url) end |
#project ⇒ Object
35 36 37 38 39 |
# File 'lib/redpomo/task.rb', line 35 def project @task.projects.map do |context| context.gsub /^\+/, '' end.first end |
#start_pomodoro! ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/redpomo/task.rb', line 68 def start_pomodoro! require 'applescript' command = 'tell application "Pomodoro" to start "' command << orig command << '"' AppleScript.execute(command) end |
#text ⇒ Object
47 48 49 |
# File 'lib/redpomo/task.rb', line 47 def text @task.text.gsub(ISSUES_REGEXP, '').strip end |
#to_issue ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/redpomo/task.rb', line 91 def to_issue issue = Issue.new(tracker) issue.subject = text issue.project_id = project issue.due_date = date issue.priority_id = tracker.issue_priority_id(priority) if tracker.present? issue end |
#tracker ⇒ Object
87 88 89 |
# File 'lib/redpomo/task.rb', line 87 def tracker Tracker.find(context) if context.present? end |
#url ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/redpomo/task.rb', line 76 def url return nil unless tracker.present? if issue.present? "#{tracker.base_url}/issues/#{issue}" elsif project.present? "#{tracker.base_url}/projects/#{project}" else "#{tracker.base_url}/projects/#{tracker.default_project}" end end |