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.63 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.62 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.61 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.60 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.59 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.58 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.57 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.55 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.54 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.53 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.52 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.51 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.50 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.49 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.48 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.47 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.46 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.45 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.44 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.43 lib/onebox/engine/github_pullrequest_onebox.rb