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
- API =
Octopi::Issue
- @@allowed_states =
%w{open close}
Instance Attribute Summary collapse
-
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
Class Method Summary collapse
- .build_attributes(repo, options) ⇒ Object
- .find_by_attributes(project_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, ticket_id) ⇒ Object
- .open(project_id, *options) ⇒ Object
Instance Method Summary collapse
- #close ⇒ Object
- #comment!(comment) ⇒ Object
- #comments ⇒ Object
-
#initialize(*object) ⇒ Ticket
constructor
declare needed overloaded methods here.
- #reopen ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(*object) ⇒ Ticket
declare needed overloaded methods here
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/provider/ticket.rb', line 12 def initialize(*object) if object.first object = object.first unless object.is_a? Hash hash = {:repository => object.repository.name, :user => object.user, :updated_at => object.updated_at, :votes => object.votes, :number => object.number, :title => object.title, :body => object.body, :closed_at => object.closed_at, :labels => object.labels, :state => object.state, :created_at => object.created_at } 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
.build_attributes(repo, options) ⇒ Object
46 47 48 49 |
# File 'lib/provider/ticket.rb', line 46 def self.build_attributes(repo, ) hash = {:repo => repo, :user => Octopi::Api.api.login} hash.merge!() end |
.find_by_attributes(project_id, attributes = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/provider/ticket.rb', line 40 def self.find_by_attributes(project_id, attributes = {}) attributes ||= {} attributes[:state] ||= 'open' self::API.find_all(build_attributes(project_id, attributes)).collect{|issue| self.new issue} end |
.find_by_id(project_id, ticket_id) ⇒ Object
36 37 38 |
# File 'lib/provider/ticket.rb', line 36 def self.find_by_id(project_id, ticket_id) self.new self::API.find(build_attributes(project_id, {:number => ticket_id})) end |
.open(project_id, *options) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/provider/ticket.rb', line 51 def self.open(project_id, *) begin self.new self::API.open(build_attributes(project_id, .first)) rescue self.find(project_id, :all).last end end |
Instance Method Details
#close ⇒ Object
59 60 61 |
# File 'lib/provider/ticket.rb', line 59 def close Ticket.new API.find(Ticket.build_attributes(repository, {:number => number})).close! end |
#comment!(comment) ⇒ Object
83 84 85 |
# File 'lib/provider/ticket.rb', line 83 def comment!(comment) Comment.create(repository, number, comment) end |
#comments ⇒ Object
79 80 81 |
# File 'lib/provider/ticket.rb', line 79 def comments Comment.find(repository, number, :all) end |
#reopen ⇒ Object
63 64 65 |
# File 'lib/provider/ticket.rb', line 63 def reopen Ticket.new API.find(Ticket.build_attributes(repository, {:number => number})).reopen! end |
#save ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/provider/ticket.rb', line 67 def save t = API.find(Ticket.build_attributes(repository, {:number => number})) return false if t.title == title and t.body == body t.title = title t.body = body t.save true end |