Class: TicketMaster::Provider::Fogbugz::Project
- Inherits:
-
Base::Project
- Object
- Base::Project
- TicketMaster::Provider::Fogbugz::Project
- Defined in:
- lib/provider/project.rb
Overview
Project class for ticketmaster-fogbugz
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.
- #description ⇒ Object
- #id ⇒ Object
-
#initialize(*object) ⇒ Project
constructor
API = Fogbugz::Project # The class to access the api’s projects declare needed overloaded methods here.
- #name ⇒ Object
- #ticket(*options) ⇒ Object
- #ticket!(attributes_hash) ⇒ Object
- #tickets(*options) ⇒ Object
Constructor Details
#initialize(*object) ⇒ Project
API = Fogbugz::Project # The class to access the api’s projects declare needed overloaded methods here
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/provider/project.rb', line 10 def initialize(*object) if object.first object = object.first unless object.is_a? Hash @system_data = {:client => object} hash = {:id => object['ixProject'].to_i, :name => object['sProject'], :description => object['sProject'], :created_at => nil, :updated_at => nil} else hash = object end super(hash) end end |
Class Method Details
.find(*options) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/provider/project.rb', line 66 def self.find(*) if [0].first.is_a? Array [0].first.collect { |project_id| self.find_by_id(project_id) } elsif [0].first.is_a? Hash self.find_by_attributes([0].first) else self.find_all end end |
.find_all ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/provider/project.rb', line 84 def self.find_all projects = [] TicketMaster::Provider::Fogbugz.api.command(:listProjects).each do |project| projects << project[1]['project'].map { |xpro| self.new xpro } end projects.flatten end |
.find_by_attributes(attributes = {}) ⇒ Object
76 77 78 |
# File 'lib/provider/project.rb', line 76 def self.find_by_attributes(attributes = {}) search_by_attribute(self.find_all, attributes) end |
.find_by_id(id) ⇒ Object
80 81 82 |
# File 'lib/provider/project.rb', line 80 def self.find_by_id(id) self.find_all.select { |project| project.id == id }.first end |
Instance Method Details
#copy(project) ⇒ Object
copy from this.copy(that) copies that into this
40 41 42 43 44 45 46 47 48 |
# File 'lib/provider/project.rb', line 40 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 |
#description ⇒ Object
35 36 37 |
# File 'lib/provider/project.rb', line 35 def description sProject end |
#id ⇒ Object
27 28 29 |
# File 'lib/provider/project.rb', line 27 def id ixProject.to_i end |
#name ⇒ Object
31 32 33 |
# File 'lib/provider/project.rb', line 31 def name sProject end |
#ticket(*options) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/provider/project.rb', line 54 def ticket(*) if .first.is_a? Fixnum Ticket.find_by_id(self.id, .first) else raise "You can only search for a single ticket based on id" end end |
#ticket!(attributes_hash) ⇒ Object
62 63 64 |
# File 'lib/provider/project.rb', line 62 def ticket!(attributes_hash) provider_parent(self.class)::Ticket.create(attributes_hash.merge :project_id => id) end |