Class: TicketMaster::Provider::Github::Project
- Inherits:
-
Base::Project
- Object
- Base::Project
- TicketMaster::Provider::Github::Project
- Defined in:
- lib/provider/project.rb
Overview
Project class for ticketmaster-github
Class Method Summary collapse
- .find(*options) ⇒ Object
- .find_all ⇒ Object
- .find_by_attributes(attributes = {}) ⇒ Object
- .find_by_id(id) ⇒ Object
Instance Method Summary collapse
-
#copy(project) ⇒ Object
copy from this.copy(that) copies that into this.
- #created_at ⇒ Object
- #id ⇒ Object
-
#initialize(*object) ⇒ Project
constructor
declare needed overloaded methods here.
- #ticket(*options) ⇒ Object
- #ticket!(*options) ⇒ Object
- #tickets(*options) ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Project
declare needed overloaded methods here
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/provider/project.rb', line 9 def initialize(*object) if object.first object = object.first @system_data = {:client => object} unless object.is_a? Hash hash = {:description => object.description, :created_at => object.created_at, :updated_at => object.created_at, :name => object.name, :id => object.name, :owner => object.owner} else hash = object end super hash end end |
Class Method Details
.find(*options) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/provider/project.rb', line 58 def self.find(*) if [0].empty? projects = self.find_all elsif [0].first.is_a? Array [0].first.collect { |name| self.find_by_id(name) } elsif [0].first.is_a? String self.find_by_id([0].first) elsif [0].first.is_a? Hash self.find_by_attributes([0].first) end end |
.find_all ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/provider/project.rb', line 79 def self.find_all repos = [] user_repos = TicketMaster::Provider::Github.api.repositories(TicketMaster::Provider::Github.login).collect { |repository| self.new repository } repos = repos + user_repos if TicketMaster::Provider::Github.valid_user org_repos = TicketMaster::Provider::Github.api.organization_repositories.collect { |repository| self.new repository } repos = repos + org_repos end repos end |
.find_by_attributes(attributes = {}) ⇒ Object
70 71 72 |
# File 'lib/provider/project.rb', line 70 def self.find_by_attributes(attributes = {}) search_by_attribute(self.find_all, attributes) end |
.find_by_id(id) ⇒ Object
74 75 76 77 |
# File 'lib/provider/project.rb', line 74 def self.find_by_id(id) id = "#{TicketMaster::Provider::Github.login}/#{id}" unless id.include?("/") self.new TicketMaster::Provider::Github.api.repository(id) end |
Instance Method Details
#copy(project) ⇒ Object
copy from this.copy(that) copies that into this
48 49 50 51 52 53 54 55 56 |
# File 'lib/provider/project.rb', line 48 def copy(project) project.tickets.each do |ticket| copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description) ticket.comments.each do |comment| copy_ticket.comment!(:body => comment.body) sleep 1 end end end |
#created_at ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/provider/project.rb', line 27 def created_at begin Time.parse(self[:created_at]) rescue self[:created_at] end end |
#id ⇒ Object
43 44 45 |
# File 'lib/provider/project.rb', line 43 def id "#{self.owner.login}/#{self[:name]}" end |
#ticket(*options) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/provider/project.rb', line 96 def ticket(*) unless .empty? TicketMaster::Provider::Github::Ticket.find_by_id(self.id, .first) else TicketMaster::Provider::Github::Ticket end end |
#ticket!(*options) ⇒ Object
104 105 106 |
# File 'lib/provider/project.rb', line 104 def ticket!(*) TicketMaster::Provider::Github::Ticket.open(self.id, .first) end |
#tickets(*options) ⇒ Object
92 93 94 |
# File 'lib/provider/project.rb', line 92 def tickets(*) TicketMaster::Provider::Github::Ticket.find(self.id, ) end |
#updated_at ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/provider/project.rb', line 35 def updated_at begin Time.parse(self[:created_at]) rescue self[:created_at] end end |