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
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_all(*options) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/provider/project.rb', line 67 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 unless TicketMaster::Provider::Github.user_token.nil? 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
58 59 60 |
# File 'lib/provider/project.rb', line 58 def self.find_by_attributes(attributes = {}) search_by_attribute(find_all, attributes).collect { |project| self.new project } end |
.find_by_id(id) ⇒ Object
62 63 64 65 |
# File 'lib/provider/project.rb', line 62 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[:name] end |
#ticket(*options) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/provider/project.rb', line 84 def ticket(*) unless .empty? TicketMaster::Provider::Github::Ticket.find_by_id(self.id, .first) else TicketMaster::Provider::Github::Ticket end end |
#ticket!(*options) ⇒ Object
92 93 94 |
# File 'lib/provider/project.rb', line 92 def ticket!(*) TicketMaster::Provider::Github::Ticket.open(self.id, .first) end |
#tickets(*options) ⇒ Object
80 81 82 |
# File 'lib/provider/project.rb', line 80 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 |