Class: TaskMapper::Provider::Github::Ticket
- Inherits:
-
Base::Ticket
- Object
- Base::Ticket
- TaskMapper::Provider::Github::Ticket
- Defined in:
- lib/provider/ticket.rb
Overview
Ticket class for taskmapper-github
Class Method Summary collapse
- .find_all(project_id) ⇒ Object
- .find_by_attributes(project_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, number) ⇒ Object
- .open(project_id, *options) ⇒ Object
Instance Method Summary collapse
- #assignee ⇒ Object
- #author ⇒ Object
- #close ⇒ Object
- #comment!(attributes) ⇒ Object
- #created_at ⇒ Object
- #description ⇒ Object
- #description=(val) ⇒ Object
- #id ⇒ Object
-
#initialize(*object) ⇒ Ticket
constructor
declare needed overloaded methods here.
- #reopen ⇒ Object
- #requestor ⇒ Object
- #save ⇒ Object
- #status ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Ticket
declare needed overloaded methods here
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/provider/ticket.rb', line 9 def initialize(*object) if object.first object = object.first unless object.is_a? Hash hash = {:id => object.number, :status => object.state, :description => object.body, :user => object.user, :project_id => object.project_id} else hash = object end super hash end end |
Class Method Details
.find_all(project_id) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/provider/ticket.rb', line 64 def self.find_all(project_id) issues = [] issues = Array(TaskMapper::Provider::Github.api.issues(project_id)) issues += TaskMapper::Provider::Github.api.issues(project_id, {:state => "closed"}) unless issues.empty? issues.collect do |issue| issue.merge!(:project_id => project_id) Ticket.new issue end end |
.find_by_attributes(project_id, attributes = {}) ⇒ Object
59 60 61 62 |
# File 'lib/provider/ticket.rb', line 59 def self.find_by_attributes(project_id, attributes = {}) issues = self.find_all(project_id) search_by_attribute(issues, attributes) end |
.find_by_id(project_id, number) ⇒ Object
53 54 55 56 57 |
# File 'lib/provider/ticket.rb', line 53 def self.find_by_id(project_id, number) issue = TaskMapper::Provider::Github.api.issue(project_id, number) issue.merge!(:project_id => project_id) self.new issue end |
.open(project_id, *options) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/provider/ticket.rb', line 74 def self.open(project_id, *) ticket_hash = .first body = ticket_hash.delete(:description) title = ticket_hash.delete(:title) new_issue = TaskMapper::Provider::Github.api.create_issue(project_id, title, body, .first) new_issue.merge!(:project_id => project_id) self.new new_issue end |
Instance Method Details
#assignee ⇒ Object
49 50 51 |
# File 'lib/provider/ticket.rb', line 49 def assignee github_user end |
#author ⇒ Object
41 42 43 |
# File 'lib/provider/ticket.rb', line 41 def github_user end |
#close ⇒ Object
108 109 110 |
# File 'lib/provider/ticket.rb', line 108 def close Ticket.new(project_id, TaskMapper::Provider::Github.api.close_issue(project_id, number)) end |
#comment!(attributes) ⇒ Object
112 113 114 |
# File 'lib/provider/ticket.rb', line 112 def comment!(attributes) Comment.create(project_id, number, attributes) end |
#created_at ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/provider/ticket.rb', line 83 def created_at begin Time.parse(self[:created_at]) rescue self[:created_at] end end |
#description ⇒ Object
33 34 35 |
# File 'lib/provider/ticket.rb', line 33 def description self.body end |
#description=(val) ⇒ Object
37 38 39 |
# File 'lib/provider/ticket.rb', line 37 def description=(val) self.body = val end |
#id ⇒ Object
25 26 27 |
# File 'lib/provider/ticket.rb', line 25 def id self.number end |
#reopen ⇒ Object
104 105 106 |
# File 'lib/provider/ticket.rb', line 104 def reopen Ticket.new(project_id, TaskMapper::Provider::Github.api.reopen_issue(project_id, number)) end |
#requestor ⇒ Object
45 46 47 |
# File 'lib/provider/ticket.rb', line 45 def requestor github_user end |
#save ⇒ Object
99 100 101 102 |
# File 'lib/provider/ticket.rb', line 99 def save TaskMapper::Provider::Github.api.update_issue(project_id, number, title, description) true end |
#status ⇒ Object
29 30 31 |
# File 'lib/provider/ticket.rb', line 29 def status self.state end |
#updated_at ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/provider/ticket.rb', line 91 def updated_at begin Time.parse(self[:updated_at]) rescue self[:updated_at] end end |