lib/onebox/engine/github_pullrequest_onebox.rb in onebox-1.1.0 vs lib/onebox/engine/github_pullrequest_onebox.rb in onebox-1.2.0

- old
+ new

@@ -1,9 +1,10 @@ module Onebox module Engine class GithubPullRequestOnebox include Engine + include LayoutSupport include JSON matches do http maybe("www.") @@ -12,32 +13,23 @@ anything with("/pull/") end def url - "https://api.github.com/repos/#{match[:owner]}/#{match[:repo]}/pulls/#{match[:number]}" + "https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/pulls/#{match[:number]}" end private def match - @url.match(/github\.com\/(?<owner>[^\/]+)\/(?<repo>[^\/]+)\/pull\/(?<number>[^\/]+)/) + @match ||= @url.match(%r{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<number>[^/]+)}) end def data - { - url: @url, - author: raw["user"]["login"], - gravatar: raw["user"]["avatar_url"], - title: raw["title"], - repo: raw["base"]["repo"]["full_name"], - time_date: raw["created_at"], - commits: raw["commits"], - additions: raw["additions"], - deletions: raw["deletions"], - changed_files: raw["changed_files"], - description: raw["body"] - } + result = raw.clone + result['link'] = link + result['created_at'] = Time.parse(result['created_at']).strftime("%I:%M%p - %d %b %y") + result end end end end