Sha256: f077188ba8c9cdd030eb1030093df5c3731bf9299653fbd4bc3bbc9a9b84215e

Contents?: true

Size: 868 Bytes

Versions: 88

Compression:

Stored size: 868 Bytes

Contents

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

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

      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")
        ulink = URI(link)
        result['domain'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"
        result
      end
    end
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
onebox-1.8.21 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.20 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.19 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.18 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.17 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.16 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.15 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.14 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.13 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.12 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.11 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.10 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.9 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.8 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.7 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.6 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.5 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.4 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.3 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.2 lib/onebox/engine/github_pullrequest_onebox.rb