Sha256: 8c52931f549c34986581d1c39b6a6be86f81e5c1749f2e6c567f048346ed896b

Contents?: true

Size: 922 Bytes

Versions: 7

Compression:

Stored size: 922 Bytes

Contents

module Onebox
  module Engine
    class GithubPullRequestOnebox
      include Engine
      include LayoutSupport
      include JSON

      matches_regexp Regexp.new("^http(?:s)?://(?:www\\.)?(?:(?:\\w)+\\.)?(github)\\.com(?:/)?(?:.)*/pull/")

      def url
        "https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/pulls/#{match[:number]}"
      end

      private

      def match
        @match ||= @url.match(%r{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<number>[^/]+)})
      end

      def data
        result = raw.clone
        result['link'] = link
        result['created_at'] = Time.parse(result['created_at']).strftime("%I:%M%p - %d %b %y")
        result['repository_path'] = "#{URI(link).host}/#{URI(link).path.split('/')[1]}/#{URI(link).path.split('/')[2]}"
        result['repository_url'] = "https://#{result['repository_path']}"
        result
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
onebox-1.5.21 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.5.20 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.5.19 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.5.18 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.5.17 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.5.16 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.5.14 lib/onebox/engine/github_pullrequest_onebox.rb