Class: TaskMapper::Provider::Rally::Comment
- Inherits:
-
Base::Comment
- Object
- Base::Comment
- TaskMapper::Provider::Rally::Comment
- Defined in:
- lib/provider/comment.rb
Overview
The comment class for taskmapper-rally
Remaps
id => oid author => user_name body => text created_at => creation_date updated_at => creation_date
Class Method Summary collapse
- .create(*options) ⇒ Object
-
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
Accepts a project id, ticket id and attributes hash and returns all comments matching the project, ticket and those attributes in an array Should return all ticket comments if the attributes hash is empty.
- .find_by_id(project_id, ticket_id, id) ⇒ Object
-
.search(project_id, ticket_id, options = {}, limit = 1000) ⇒ Object
This is a helper method to find.
Instance Method Summary collapse
- #created_at ⇒ Object
-
#id ⇒ Object
Rally REST API aliases String and Fixnum :to_q :to_s However, it does not alias Bignum If a ID is a Bignum, the API will throw undefined method Because of this, we pass all IDs to API as strings taskmapper specs set IDs as integers, so coerce type on get.
- #id=(id) ⇒ Object
-
#initialize(*object) ⇒ Comment
constructor
A new instance of Comment.
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Comment
Returns a new instance of Comment.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/provider/comment.rb', line 14 def initialize(*object) if object.first args = object comment = args.shift project_id = args.shift ticket_id = args.shift @system_data = {:client => comment} hash = { :oid => comment.oid, :project_id => project_id, :ticket_id => ticket_id, :author => comment.user_name, :body => comment.text, :created_at => comment.creation_date, :updated_at => comment.creation_date, :post_number => comment.post_number, } super(hash) end end |
Class Method Details
.create(*options) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/provider/comment.rb', line 82 def self.create(*) = .shift project = provider_parent(self)::Project.find_by_id([:project_id]) ticket = provider_parent(self)::Ticket.find_by_id([:project_id], [:ticket_id]) comment = { :project => project.system_data[:client], :artifact => ticket.system_data[:client], :text => [:body] } new_comment = TaskMapper::Provider::Rally.rally.create(:conversation_post, comment) self.new new_comment end |
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
Accepts a project id, ticket id and attributes hash and returns all comments matching the project, ticket and those attributes in an array Should return all ticket comments if the attributes hash is empty
67 68 69 |
# File 'lib/provider/comment.rb', line 67 def self.find_by_attributes(project_id, ticket_id, attributes = {}) self.search(project_id, ticket_id, attributes) end |
.find_by_id(project_id, ticket_id, id) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/provider/comment.rb', line 56 def self.find_by_id(project_id, ticket_id, id) project = self.rally_project(project_id) # Rally Ruby REST API expects IDs as strings # For id.to_s see note on Project::id query_result = TaskMapper::Provider::Rally.rally.find(:conversation_post, :fetch => false, :project => project) { equal :object_i_d, id.to_s } self.new query_result.first, project_id end |
.search(project_id, ticket_id, options = {}, limit = 1000) ⇒ Object
This is a helper method to find
72 73 74 75 76 77 78 79 80 |
# File 'lib/provider/comment.rb', line 72 def self.search(project_id, ticket_id, = {}, limit = 1000) project = self.rally_project(project_id) artifact = project.ticket(:id => ticket_id.to_s) query_result = TaskMapper::Provider::Rally.rally.find_all(:conversation_post, :project => project) { equal :artifact, artifact } comments = query_result.collect do |comment| self.new comment, project_id, ticket_id end search_by_attribute(comments, , limit) end |
Instance Method Details
#created_at ⇒ Object
35 36 37 |
# File 'lib/provider/comment.rb', line 35 def created_at Time.parse(self[:created_at]) end |
#id ⇒ Object
Rally REST API aliases String and Fixnum :to_q :to_s However, it does not alias Bignum If a ID is a Bignum, the API will throw undefined method Because of this, we pass all IDs to API as strings taskmapper specs set IDs as integers, so coerce type on get
48 49 50 |
# File 'lib/provider/comment.rb', line 48 def id self[:oid].to_i end |
#id=(id) ⇒ Object
52 53 54 |
# File 'lib/provider/comment.rb', line 52 def id=(id) self[:oid] = id.to_s end |
#updated_at ⇒ Object
39 40 41 |
# File 'lib/provider/comment.rb', line 39 def updated_at Time.parse(self[:updated_at]) end |