Class: TicketMaster::Provider::Github::Ticket
- Inherits:
-
Base::Ticket
- Object
- Base::Ticket
- TicketMaster::Provider::Github::Ticket
- Defined in:
- lib/provider/ticket.rb
Overview
Ticket class for ticketmaster-github
Constant Summary collapse
- @@allowed_states =
%w{open close}
Instance Attribute Summary collapse
-
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
Class Method Summary collapse
- .find(project_id, *options) ⇒ Object
- .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
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/provider/ticket.rb', line 11 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 |
Instance Attribute Details
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
8 9 10 |
# File 'lib/provider/ticket.rb', line 8 def @prefix_options end |
Class Method Details
.find(project_id, *options) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/provider/ticket.rb', line 61 def self.find(project_id, *) if [0].empty? self.find_all(project_id) elsif [0].first.is_a? Array [0].first.collect { |number| self.find_by_id(project_id, number) } elsif [0].first.is_a? Hash self.find_by_attributes(project_id, [0].first) end end |
.find_all(project_id) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/provider/ticket.rb', line 76 def self.find_all(project_id) issues = [] issues += TicketMaster::Provider::Github.api.issues(project_id) issues += TicketMaster::Provider::Github.api.issues(project_id, {:state => "closed"}) issues.collect do |issue| issue.merge!(:project_id => project_id) Ticket.new issue end end |
.find_by_attributes(project_id, attributes = {}) ⇒ Object
71 72 73 74 |
# File 'lib/provider/ticket.rb', line 71 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
55 56 57 58 59 |
# File 'lib/provider/ticket.rb', line 55 def self.find_by_id(project_id, number) issue = TicketMaster::Provider::Github.api.issue(project_id, number) issue.merge!(:project_id => project_id) self.new issue end |
.open(project_id, *options) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/provider/ticket.rb', line 86 def self.open(project_id, *) ticket_hash = .first body = ticket_hash.delete(:description) title = ticket_hash.delete(:title) new_issue = TicketMaster::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
51 52 53 |
# File 'lib/provider/ticket.rb', line 51 def assignee self.user.respond_to?('login') ? self.user.login : self.user end |
#author ⇒ Object
43 44 45 |
# File 'lib/provider/ticket.rb', line 43 def self.user.respond_to?('login') ? self.user.login : self.user end |
#close ⇒ Object
120 121 122 |
# File 'lib/provider/ticket.rb', line 120 def close Ticket.new(project_id, TicketMaster::Provider::Github.api.close_issue(project_id, number)) end |
#comment!(attributes) ⇒ Object
124 125 126 |
# File 'lib/provider/ticket.rb', line 124 def comment!(attributes) Comment.create(project_id, number, attributes) end |
#created_at ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/provider/ticket.rb', line 95 def created_at begin Time.parse(self[:created_at]) rescue self[:created_at] end end |
#description ⇒ Object
35 36 37 |
# File 'lib/provider/ticket.rb', line 35 def description self.body end |
#description=(val) ⇒ Object
39 40 41 |
# File 'lib/provider/ticket.rb', line 39 def description=(val) self.body = val end |
#id ⇒ Object
27 28 29 |
# File 'lib/provider/ticket.rb', line 27 def id self.number end |
#reopen ⇒ Object
116 117 118 |
# File 'lib/provider/ticket.rb', line 116 def reopen Ticket.new(project_id, TicketMaster::Provider::Github.api.reopen_issue(project_id, number)) end |
#requestor ⇒ Object
47 48 49 |
# File 'lib/provider/ticket.rb', line 47 def requestor self.user.respond_to?('login') ? self.user.login : self.user end |
#save ⇒ Object
111 112 113 114 |
# File 'lib/provider/ticket.rb', line 111 def save TicketMaster::Provider::Github.api.update_issue(project_id, number, title, description) true end |
#status ⇒ Object
31 32 33 |
# File 'lib/provider/ticket.rb', line 31 def status self.state end |
#updated_at ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/provider/ticket.rb', line 103 def updated_at begin Time.parse(self[:updated_at]) rescue self[:updated_at] end end |