Sha256: 71b16dad42a81dd535055fa5b45ca22d1b4b2a7daed09e88140a477d9ae95a68

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

module Onebox
  module Engine
    class GithubPullRequestOnebox
      include Engine
      include JSON

      matches do
        http
        maybe("www.")
        domain("github")
        tld("com")
        anything
        with("/pull/")
      end

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

      private

      def match
        @url.match(/github\.com\/(?<owner>[^\/]+)\/(?<repo>[^\/]+)\/pull\/(?<number>[^\/]+)/)
      end

      def data
        {
          url: @url,
          author: raw["user"]["login"],
          gravatar: raw["user"]["avatar_url"],
          title: raw["title"],
          repo: raw["base"]["repo"]["full_name"],
          time_date: raw["created_at"],
          commits: raw["commits"],
          additions: raw["additions"],
          deletions: raw["deletions"],
          changed_files: raw["changed_files"],
          description: raw["body"]
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onebox-1.1.0 lib/onebox/engine/github_pullrequest_onebox.rb