class Gemshack::Client

Public Class Methods

api_key() click to toggle source
# File lib/gemshack/client.rb, line 16
def api_key
  config["api_key"] || "test"
end
client() click to toggle source
# File lib/gemshack/client.rb, line 28
def client
  @client ||= Faraday.new(host) do |f|
    f.request :multipart
    f.request :url_encoded
    f.adapter :net_http
  end
end
config() click to toggle source
# File lib/gemshack/client.rb, line 36
def config
  @config ||= YAML.load_file(File.expand_path("~/.gemshack"))
end
host() click to toggle source
# File lib/gemshack/client.rb, line 8
def host
  ENV["GEMSHACK_URL"] || config["host"] || "http://gems.rubykick.com"
end
path() click to toggle source
# File lib/gemshack/client.rb, line 12
def path
  "/#{api_key}/upload"
end
push(file) click to toggle source
# File lib/gemshack/client.rb, line 20
def push(file)
  client.post(path, {file: upload_io(file)})
end
upload_io(file) click to toggle source
# File lib/gemshack/client.rb, line 24
def upload_io(file)
  Faraday::UploadIO.new(file, 'application/gzip')
end