Module: Dagger

Defined in:
lib/dagger/version.rb,
lib/dagger/response.rb,
lib/dagger.rb

Defined Under Namespace

Modules: Response, Utils Classes: Client

Constant Summary collapse

MAJOR =
1
MINOR =
7
PATCH =
1
VERSION =
[MAJOR, MINOR, PATCH].join('.')
DAGGER_NAME =
"Dagger/#{VERSION}"
REDIRECT_CODES =
[301, 302, 303].freeze
DEFAULT_RETRY_WAIT =

seconds

5.freeze
DEFAULT_HEADERS =
{
  'Accept'     => '*/*',
  'User-Agent' => "#{DAGGER_NAME} (Ruby Net::HTTP Wrapper, like curl)"
}

Class Method Summary collapse

Class Method Details

.delete(uri, data, options = {}) ⇒ Object



269
270
271
# File 'lib/dagger.rb', line 269

def delete(uri, data, options = {})
  request(:delete, uri, data, options)
end

.get(uri, options = {}) ⇒ Object



253
254
255
# File 'lib/dagger.rb', line 253

def get(uri, options = {})
  request(:get, uri, nil, options)
end

.open(uri, opts = {}, &block) ⇒ Object



244
245
246
247
248
249
250
251
# File 'lib/dagger.rb', line 244

def open(uri, opts = {}, &block)
  client = Client.init(uri, opts.merge(persistent: true))
  if block_given?
    client.open(&block)
    client.close
  end
  client
end

.patch(uri, data, options = {}) ⇒ Object



265
266
267
# File 'lib/dagger.rb', line 265

def patch(uri, data, options = {})
  request(:patch, uri, data, options)
end

.post(uri, data, options = {}) ⇒ Object



257
258
259
# File 'lib/dagger.rb', line 257

def post(uri, data, options = {})
  request(:post, uri, data, options)
end

.put(uri, data, options = {}) ⇒ Object



261
262
263
# File 'lib/dagger.rb', line 261

def put(uri, data, options = {})
  request(:put, uri, data, options)
end

.request(method, url, data = {}, options = {}) ⇒ Object



273
274
275
# File 'lib/dagger.rb', line 273

def request(method, url, data = {}, options = {})
  Client.init(url, options).request(method, url, data, options)
end