class Onebox::Engine::GithubPullRequestOnebox

Constants

GITHUB_COMMENT_REGEX

Public Instance Methods

url() click to toggle source
# File lib/onebox/engine/github_pullrequest_onebox.rb, line 18
def url
  "https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/pulls/#{match[:number]}"
end

Private Instance Methods

data() click to toggle source
# File lib/onebox/engine/github_pullrequest_onebox.rb, line 28
def data
  result = raw.clone
  result['link'] = link

  created_at = Time.parse(result['created_at'])
  result['created_at'] = created_at.strftime("%I:%M%p - %d %b %y %Z")
  result['created_at_date'] = created_at.strftime("%F")
  result['created_at_time'] = created_at.strftime("%T")

  ulink = URI(link)
  result['domain'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"

  result['body'], result['excerpt'] = compute_body(result['body'])

  result
end
match() click to toggle source
# File lib/onebox/engine/github_pullrequest_onebox.rb, line 24
def match
  @match ||= @url.match(%r{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<number>[^/]+)})
end