lib/provider/comment.rb in ticketmaster-github-0.8.1 vs lib/provider/comment.rb in ticketmaster-github-0.9.0

- old
+ new

@@ -20,63 +20,72 @@ hash = object end super hash end end - + def author self.user.login end def created_at @created_at ||= begin - Time.parse(self[:created_at]) - rescue - self[:created_at] - end + Time.parse(self[:created_at]) + rescue + self[:created_at] + end end - def updated_at + def updated_at @updated_at ||= begin - Time.parse(self[:updated_at]) - rescue - self[:updated_at] - end + Time.parse(self[:updated_at]) + rescue + self[:updated_at] + end end - + # declare needed overloaded methods here - - def self.find_by_attributes(project_id, ticket_id, attributes = {}) - search_by_attribute(self.find_all(project_id, ticket_id), attributes) - 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.find_by_attributes(project_id, ticket_id, attributes = {}) + search_by_attribute(self.find_all(project_id, ticket_id), attributes) + 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 - + 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 + #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 + + def save + update_comment(project_id, id, body) + end + + private + def update_comment(repo, number, comment, options = {}) + TicketMaster::Provider::Github.api.update_comment repo, number, comment, options + true + end + end end end