lib/redpomo/issue.rb in redpomo-0.0.5 vs lib/redpomo/issue.rb in redpomo-0.0.6
- old
+ new
@@ -1,31 +1,38 @@
module Redpomo
class Issue
- attr_reader :title, :issue_id, :project, :tracker, :due_date
+ attr_accessor :subject, :description
+ attr_accessor :issue_id, :project_id, :tracker
+ attr_accessor :due_date, :priority_id
- def initialize(tracker, data)
- @title = data["subject"]
+ def initialize(tracker, data = {})
+ @subject = data["subject"]
@issue_id = data["id"]
- @project = data["project"]
- @priority = data["priority"]["name"]
+ @project_id = data["project_id"]
+ @priority_id = data["priority"]["id"] if data["priority"].present?
@due_date = Date.parse(data["due_date"]) if data["due_date"].present?
@tracker = tracker
end
def to_task
label = []
- if @priority.present?
- if priority = @tracker.todo_priority(@priority)
+ if @priority_id.present?
+ if priority = @tracker.todo_priority(@priority_id)
label << priority
end
end
- label << @title
label << @due_date.strftime("%Y-%m-%d") if @due_date.present?
+ label << @subject
label << "##{issue_id}"
- label << "+#{project}"
+ label << "+#{project_id}"
label << "@#{tracker.name}"
- Todo::Task.new(label.join(" "))
+ Task.new(nil, label.join(" "))
+ end
+
+ def create!
+ data = tracker.create_issue!(self)
+ @issue_id = data["issue"]["id"]
end
end
end