class Ruboty::Ss::Storage::Gist

Public Class Methods

new() click to toggle source
# File lib/ruboty/ss/storage/gist.rb, line 11
def initialize
  raise "Ruboty::Ss::Storage::Gist doesn't work"
end

Public Instance Methods

upload(image_file, path) click to toggle source
# File lib/ruboty/ss/storage/gist.rb, line 15
def upload(image_file, path)
  files =
    {
      path => {
        content: Faraday::UploadIO.new(image_file.path, 'image/png')
      }
    }
  gist_client.create_gist(files: files)
end

Private Instance Methods

gist_client() click to toggle source
# File lib/ruboty/ss/storage/gist.rb, line 27
def gist_client
  client = Jsonism::Client.new(schema: gist_schema)

  def client.connection
    Faraday.new(url: base_url) do |connection|
      connection.request :multipart
      connection.request :url_encoded
      connection.response :json
      connection.adapter :net_http
    end
  end

  client
end
gist_schema() click to toggle source
# File lib/ruboty/ss/storage/gist.rb, line 43
def gist_schema
  schema_path = File.expand_path('../../../../vendor/r7kamura/json-collection/github/schema.yml', __dir__)
  YAML.load_file(schema_path)
end