Class: TaskMapper::Provider::Github::Comment
- Inherits:
-
Base::Comment
- Object
- Base::Comment
- TaskMapper::Provider::Github::Comment
- Defined in:
- lib/provider/comment.rb
Overview
The comment class for taskmapper-github
Do any mapping between TaskMapper and your system’s comment model here versions of the ticket.
Class Method Summary collapse
- .clean_body!(comment) ⇒ Object
- .create(project_id, ticket_id, comment) ⇒ Object
- .find_all(project_id, ticket_id) ⇒ Object
-
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
declare needed overloaded methods here.
- .github_comment(project_id, number, body) ⇒ Object
Instance Method Summary collapse
- #author ⇒ Object
- #created_at ⇒ Object
-
#initialize(*object) ⇒ Comment
constructor
A new instance of Comment.
- #save ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Comment
Returns a new instance of Comment.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/provider/comment.rb', line 10 def initialize(*object) if object.first object = object.first unless object.is_a? Hash hash = {:id => object.id, :body => object.body, :created_at => object.created_at, :author => object.user.login} else hash = object end super hash end end |
Class Method Details
.clean_body!(comment) ⇒ Object
64 65 66 |
# File 'lib/provider/comment.rb', line 64 def self.clean_body!(comment) comment.body = comment.body.sub(/\A---\s\sbody:\s/, '').gsub(/\s\z/, '') end |
.create(project_id, ticket_id, comment) ⇒ Object
55 56 57 |
# File 'lib/provider/comment.rb', line 55 def self.create(project_id, ticket_id, comment) self.new github_comment(project_id, ticket_id, comment[:body]).merge!(:project_id => project_id, :ticket_id => ticket_id) end |
.find_all(project_id, ticket_id) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/provider/comment.rb', line 47 def self.find_all(project_id, ticket_id) Array(TaskMapper::Provider::Github.api.issue_comments(project_id, ticket_id)).collect do |comment| comment.merge!(:project_id => project_id, :ticket_id => ticket_id) clean_body! comment self.new comment end end |
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
declare needed overloaded methods here
43 44 45 |
# File 'lib/provider/comment.rb', line 43 def self.find_by_attributes(project_id, ticket_id, attributes = {}) search_by_attribute(self.find_all(project_id, ticket_id), attributes) end |
.github_comment(project_id, number, body) ⇒ Object
59 60 61 |
# File 'lib/provider/comment.rb', line 59 def self.github_comment(project_id, number, body) TaskMapper::Provider::Github.api.add_comment(project_id, number, body) end |
Instance Method Details
#author ⇒ Object
25 26 27 |
# File 'lib/provider/comment.rb', line 25 def self.user.login end |
#created_at ⇒ Object
29 30 31 32 33 |
# File 'lib/provider/comment.rb', line 29 def created_at Time.parse(self[:created_at]) rescue self[:created_at] end |
#save ⇒ Object
68 69 70 |
# File 'lib/provider/comment.rb', line 68 def save update_comment(project_id, id, body) end |
#updated_at ⇒ Object
35 36 37 38 39 |
# File 'lib/provider/comment.rb', line 35 def updated_at Time.parse(self[:updated_at]) rescue self[:updated_at] end |