Module: Dagger

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

Defined Under Namespace

Modules: Response, Utils Classes: Client

Constant Summary collapse

REDIRECT_CODES =
[301, 302, 303].freeze
DEFAULT_HEADERS =
{
  'Accept'     => '*/*',
  'User-Agent' => "Dagger/#{VERSION} (Ruby Net::HTTP Wrapper, like curl)"
}
MAJOR =
0
MINOR =
6
PATCH =
0
VERSION =
[MAJOR, MINOR, PATCH].join('.')

Class Method Summary collapse

Class Method Details

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



156
157
158
# File 'lib/dagger.rb', line 156

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

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



140
141
142
# File 'lib/dagger.rb', line 140

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

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



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/dagger.rb', line 128

def open(uri, opts = {}, &block)
  uri = Utils.parse_uri(uri)
  opts.merge!(use_ssl: uri.scheme == 'https')
  opts.merge!(verify_mode: OpenSSL::SSL::VERIFY_NONE) if opts[:verify_ssl] === false

  Net::HTTP.start(uri.host, uri.port, opts) do |http|
    client = Client.new(http)
    # yield(client)
    client.instance_eval(&block)
  end
end

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



152
153
154
# File 'lib/dagger.rb', line 152

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

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



144
145
146
# File 'lib/dagger.rb', line 144

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

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



148
149
150
# File 'lib/dagger.rb', line 148

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

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



160
161
162
# File 'lib/dagger.rb', line 160

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