Parent

GeminaboxClient

Attributes

http_client[R]
url[R]

Public Class Methods

new(url) click to toggle source
# File lib/geminabox_client.rb, line 7
def initialize(url)
  extract_username_and_password_from_url!(url)
  @http_client = HTTPClient.new
  @http_client.set_auth(url_for(:upload), @username, @password) if @username or @password
  @http_client.www_auth.basic_auth.challenge(url_for(:upload)) # Workaround: https://github.com/nahi/httpclient/issues/63
  @http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
  @http_client.send_timeout = 0
  @http_client.receive_timeout = 0
end

Public Instance Methods

extract_username_and_password_from_url!(url) click to toggle source
# File lib/geminabox_client.rb, line 17
def extract_username_and_password_from_url!(url)
  uri = URI.parse(url.to_s)
  @username, @password = uri.user, uri.password
  uri.user = uri.password = nil
  uri.path = uri.path + "/" unless uri.path.end_with?("/")
  @url = uri.to_s
end
push(gemfile, options = {}) click to toggle source
# File lib/geminabox_client.rb, line 29
def push(gemfile, options = {})
  response = http_client.post(url_for(:upload), { 'file' => File.open(gemfile, "rb"), 'overwrite' => !!options[:overwrite] }, { 'Accept' => 'text/plain' })

  if response.status < 300
    response.body
  else
    raise GeminaboxClient::Error, "Error (#{response.code} received)\n\n#{response.body}"
  end
end
url_for(path) click to toggle source
# File lib/geminabox_client.rb, line 25
def url_for(path)
  url + path.to_s
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.