Sha256: 3172a613d53eb9b34b770435039239995f8384f4a01e026a002ed26012157afe

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 Bytes

Contents

module Onebox
  module Engine
    class GithubGistOnebox
      include Engine
      include JSON

      matches do
        http
        with("gist.")
        domain("github")
        tld("com")
      end

      def url
        "https://api.github.com/gists/#{match[:number]}"
      end

      private

      def match
        @url.match(/gist\.github\.com\/([^\/]+\/)?(?<number>[0-9a-f]+)/)
      end

      def data
        {
          url: @url,
          content: raw["files"].first[1]["content"],
          author: raw["user"]["login"]
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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