lib/provider/comment.rb in ticketmaster-github-0.8.0 vs lib/provider/comment.rb in ticketmaster-github-0.8.1
- old
+ new
@@ -14,18 +14,17 @@
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
-
+
def author
self.user.login
end
def created_at
@@ -51,18 +50,33 @@
end
def self.find_all(project_id, ticket_id)
TicketMaster::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
def self.create(project_id, ticket_id, comment)
github_comment = TicketMaster::Provider::Github.api.add_comment(project_id, ticket_id, comment)
github_comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
+ flat_body github_comment
self.new github_comment
end
+
+ private
+
+ #See https://www.kanbanpad.com/projects/31edb8d134e7967c1f0d#!xt-4f994d17014289000707433f
+ def self.flat_body(comment_hashie)
+ comment_hashie.body = comment_hashie.body.body
+ comment_hashie
+ end
+
+ # See https://www.kanbanpad.com/projects/31edb8d134e7967c1f0d#!xt-4f994f2101428900070759fd
+ def self.clean_body!(comment)
+ comment.body = comment.body.sub(/\A---\s\sbody:\s/, '').gsub(/\s\z/, '')
+ end
end
end
end