Sha256: 2e106490118e0f212f8db1b917da10cf94186f49b6c4852133c650323eeed616

Contents?: true

Size: 1.01 KB

Versions: 31

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require_relative 'abstract_issue'
require_relative '../github/gist'

module Geet
  module Github
    class Gist
      def self.create(filename, content, api_interface, description: nil, publik: false)
        api_path = '/gists'

        request_data = prepare_request_data(filename, content, description, publik)

        response = api_interface.send_request(api_path, data: request_data)

        id = response.fetch('id')

        new(id)
      end

      def initialize(id)
        @id = id
      end

      def link
        "https://gist.github.com/#{@id}"
      end

      class << self
        private

        def prepare_request_data(filename, content, description, publik)
          request_data = {
            'public' => publik,
            'files' => {
              filename => {
                'content' => content
              }
            }
          }

          request_data['description'] = description if description

          request_data
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
geet-0.12.0 lib/geet/github/gist.rb
geet-0.11.0 lib/geet/github/gist.rb
geet-0.10.0 lib/geet/github/gist.rb
geet-0.9.0 lib/geet/github/gist.rb
geet-0.8.0 lib/geet/github/gist.rb
geet-0.7.0 lib/geet/github/gist.rb
geet-0.6.0 lib/geet/github/gist.rb
geet-0.5.0 lib/geet/github/gist.rb
geet-0.4.4 lib/geet/github/gist.rb
geet-0.4.3 lib/geet/github/gist.rb
geet-0.4.2 lib/geet/github/gist.rb
geet-0.4.1 lib/geet/github/gist.rb
geet-0.4.0 lib/geet/github/gist.rb
geet-0.3.18 lib/geet/github/gist.rb
geet-0.3.17 lib/geet/github/gist.rb
geet-0.3.16 lib/geet/github/gist.rb
geet-0.3.15 lib/geet/github/gist.rb
geet-0.3.14 lib/geet/github/gist.rb
geet-0.3.13 lib/geet/github/gist.rb
geet-0.3.12 lib/geet/github/gist.rb