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.1 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.8.0 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.9 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.8 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.7 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.6 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.5 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.4 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.3 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.2 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.1 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.7.0 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.6.9 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.6.8 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.6.7 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.6.6 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.6.5 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.6.4 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.6.3 lib/onebox/engine/github_pullrequest_onebox.rb
onebox-1.6.2 lib/onebox/engine/github_pullrequest_onebox.rb