Module: Spectre::Curl
- Defined in:
- lib/spectre/curl.rb
Defined Under Namespace
Classes: SpectreHttpHeader, SpectreHttpRequest, SpectreHttpResponse
Constant Summary
collapse
- @@http_cfg =
{}
- @@response =
nil
- @@request =
nil
- @@modules =
[]
Class Method Summary
collapse
Class Method Details
.curl(name, secure: false, &block) ⇒ Object
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/spectre/curl.rb', line 159
def curl name, secure: false, &block
req = {
'use_ssl' => secure,
}
if @@http_cfg.key? name
req.merge! @@http_cfg[name]
raise "No `base_url' set for HTTP client '#{name}'. Check your HTTP config in your environment." unless req['base_url']
else
req['base_url'] = name
end
SpectreHttpRequest.new(req)._evaluate(&block) if block_given?
invoke(req)
end
|
.curl_request ⇒ Object
176
177
178
179
180
|
# File 'lib/spectre/curl.rb', line 176
def curl_request
raise 'No request has been invoked yet' unless @@request
@@request
end
|
.curl_response ⇒ Object
182
183
184
185
186
|
# File 'lib/spectre/curl.rb', line 182
def curl_response
raise 'There is no response. No request has been invoked yet.' unless @@response
@@response
end
|
.register(mod) ⇒ Object
188
189
190
191
192
|
# File 'lib/spectre/curl.rb', line 188
def register mod
raise 'Module must not be nil' unless mod
@@modules << mod
end
|