Module: RestMan
- Defined in:
- lib/restman.rb,
lib/restman/utils.rb,
lib/restman/payload.rb,
lib/restman/request.rb,
lib/restman/version.rb,
lib/restman/platform.rb,
lib/restman/resource.rb,
lib/restman/response.rb,
lib/restman/statuses.rb,
lib/restman/exception.rb,
lib/restman/params_array.rb,
lib/restman/payload/base.rb,
lib/restman/raw_response.rb,
lib/restman/request/init.rb,
lib/restman/payload/streamed.rb,
lib/restman/request/init/url.rb,
lib/restman/request/transmit.rb,
lib/restman/abstract_response.rb,
lib/restman/payload/multipart.rb,
lib/restman/request/proxy_uri.rb,
lib/restman/exceptions/timeout.rb,
lib/restman/payload/url_encoded.rb,
lib/restman/request/log_request.rb,
lib/restman/request/make_headers.rb,
lib/restman/request/init/ssl_opts.rb,
lib/restman/request/process_result.rb,
lib/restman/statuses_compatibility.rb,
lib/restman/request/init/cookie_jar.rb,
lib/restman/request/net_http_object.rb,
lib/restman/exceptions/exceptions_map.rb,
lib/restman/exceptions/request_failed.rb,
lib/restman/params_array/process_pair.rb,
lib/restman/request/stringify_headers.rb,
lib/restman/request/make_cookie_header.rb,
lib/restman/request/default_ssl_cert_store.rb,
lib/restman/request/fetch_body_to_tempfile.rb,
lib/restman/request/init/url/normalize_url.rb,
lib/restman/request/maybe_convert_extension.rb,
lib/restman/exceptions/exception_with_response.rb,
lib/restman/exceptions/server_broke_connection.rb,
lib/restman/request/init/url/add_query_from_headers.rb,
lib/restman/payload/multipart/write_content_disposition.rb
Overview
:include: _doc/lib/restman.rdoc
Defined Under Namespace
Modules: AbstractResponse, Exceptions, Payload, Platform, Utils Classes: Exception, ExceptionWithResponse, ParamsArray, RawResponse, Request, RequestFailed, Resource, Response, ServerBrokeConnection
Constant Summary collapse
- VERSION_INFO =
[1, 1, 0].freeze
- VERSION =
VERSION_INFO.map(&:to_s).join('.').freeze
- STATUSES =
:include: _doc/lib/restman/statuses.rdoc
{ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', #WebDAV 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', # http/1.1 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', #WebDAV 208 => 'Already Reported', # RFC5842 226 => 'IM Used', # RFC3229 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', # http/1.1 304 => 'Not Modified', 305 => 'Use Proxy', # http/1.1 306 => 'Switch Proxy', # no longer used 307 => 'Temporary Redirect', # http/1.1 308 => 'Permanent Redirect', # RFC7538 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Payload Too Large', # RFC7231 (renamed, see below) 414 => 'URI Too Long', # RFC7231 (renamed, see below) 415 => 'Unsupported Media Type', 416 => 'Range Not Satisfiable', # RFC7233 (renamed, see below) 417 => 'Expectation Failed', 418 => 'I\'m A Teapot', #RFC2324 421 => 'Too Many Connections From This IP', 422 => 'Unprocessable Entity', #WebDAV 423 => 'Locked', #WebDAV 424 => 'Failed Dependency', #WebDAV 425 => 'Unordered Collection', #WebDAV 426 => 'Upgrade Required', 428 => 'Precondition Required', #RFC6585 429 => 'Too Many Requests', #RFC6585 431 => 'Request Header Fields Too Large', #RFC6585 449 => 'Retry With', #Microsoft 450 => 'Blocked By Windows Parental Controls', #Microsoft 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', #WebDAV 508 => 'Loop Detected', # RFC5842 509 => 'Bandwidth Limit Exceeded', #Apache 510 => 'Not Extended', 511 => 'Network Authentication Required', # RFC6585 }
- STATUSES_COMPATIBILITY =
{ # The RFCs all specify "Not Found", but "Resource Not Found" was used in # earlier RestMan releases. 404 => ['ResourceNotFound'], # HTTP 413 was renamed to "Payload Too Large" in RFC7231. 413 => ['RequestEntityTooLarge'], # HTTP 414 was renamed to "URI Too Long" in RFC7231. 414 => ['RequestURITooLong'], # HTTP 416 was renamed to "Range Not Satisfiable" in RFC7233. 416 => ['RequestedRangeNotSatisfiable'], }
- @@env_log =
create_log ENV['RESTCLIENT_LOG']
- @@log =
nil
- @@before_execution_procs =
[]
Class Method Summary collapse
-
.add_before_execution_proc(&proc) ⇒ Object
:include: _doc/lib/restman/add_before_execution_proc.rdoc.
-
.before_execution_procs ⇒ Object
:nodoc:.
-
.create_log(param) ⇒ Object
:include: _doc/lib/restman/create_log.rdoc.
- .delete(url, headers = {}, &block) ⇒ Object
- .get(url, headers = {}, &block) ⇒ Object
- .head(url, headers = {}, &block) ⇒ Object
-
.log ⇒ Object
:nodoc:.
-
.log=(log) ⇒ Object
:include: _doc/lib/restman/log=.rdoc.
- .options(url, headers = {}, &block) ⇒ Object
- .patch(url, payload, headers = {}, &block) ⇒ Object
- .post(url, payload, headers = {}, &block) ⇒ Object
-
.proxy ⇒ Object
:include: _doc/lib/restman/proxy.rdoc.
- .proxy=(value) ⇒ Object
-
.proxy_set? ⇒ Boolean
:include: _doc/lib/restman/proxy_set?.rdoc.
- .put(url, payload, headers = {}, &block) ⇒ Object
-
.reset_before_execution_procs ⇒ Object
:include: _doc/lib/restman/reset_before_execution_procs.rdoc.
- .version ⇒ Object
Class Method Details
.add_before_execution_proc(&proc) ⇒ Object
:include: _doc/lib/restman/add_before_execution_proc.rdoc
131 132 133 134 |
# File 'lib/restman.rb', line 131 def self.add_before_execution_proc &proc raise ArgumentError.new('block is required') unless proc @@before_execution_procs << proc end |
.before_execution_procs ⇒ Object
:nodoc:
141 142 143 |
# File 'lib/restman.rb', line 141 def self.before_execution_procs # :nodoc: @@before_execution_procs end |
.create_log(param) ⇒ Object
:include: _doc/lib/restman/create_log.rdoc
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/restman.rb', line 85 def self.create_log param if param if param.is_a? String if param == 'stdout' stdout_logger = Class.new do def << obj STDOUT.puts obj end end stdout_logger.new elsif param == 'stderr' stderr_logger = Class.new do def << obj STDERR.puts obj end end stderr_logger.new else file_logger = Class.new do attr_writer :target_file def << obj File.open(@target_file, 'a') { |f| f.puts obj } end end logger = file_logger.new logger.target_file = param logger end else param end end end |
.delete(url, headers = {}, &block) ⇒ Object
52 53 54 |
# File 'lib/restman.rb', line 52 def self.delete(url, headers={}, &block) Request.execute(:method => :delete, :url => url, :headers => headers, &block) end |
.get(url, headers = {}, &block) ⇒ Object
36 37 38 |
# File 'lib/restman.rb', line 36 def self.get(url, headers={}, &block) Request.execute(:method => :get, :url => url, :headers => headers, &block) end |
.head(url, headers = {}, &block) ⇒ Object
56 57 58 |
# File 'lib/restman.rb', line 56 def self.head(url, headers={}, &block) Request.execute(:method => :head, :url => url, :headers => headers, &block) end |
.log ⇒ Object
:nodoc:
124 125 126 |
# File 'lib/restman.rb', line 124 def self.log # :nodoc: @@env_log || @@log end |
.log=(log) ⇒ Object
:include: _doc/lib/restman/log=.rdoc
80 81 82 |
# File 'lib/restman.rb', line 80 def self.log= log @@log = create_log log end |
.options(url, headers = {}, &block) ⇒ Object
60 61 62 |
# File 'lib/restman.rb', line 60 def self.(url, headers={}, &block) Request.execute(:method => :options, :url => url, :headers => headers, &block) end |
.patch(url, payload, headers = {}, &block) ⇒ Object
44 45 46 |
# File 'lib/restman.rb', line 44 def self.patch(url, payload, headers={}, &block) Request.execute(:method => :patch, :url => url, :payload => payload, :headers => headers, &block) end |
.post(url, payload, headers = {}, &block) ⇒ Object
40 41 42 |
# File 'lib/restman.rb', line 40 def self.post(url, payload, headers={}, &block) Request.execute(:method => :post, :url => url, :payload => payload, :headers => headers, &block) end |
.proxy ⇒ Object
:include: _doc/lib/restman/proxy.rdoc
65 66 67 |
# File 'lib/restman.rb', line 65 def self.proxy @proxy ||= nil end |
.proxy=(value) ⇒ Object
69 70 71 72 |
# File 'lib/restman.rb', line 69 def self.proxy=(value) @proxy = value @proxy_set = true end |
.proxy_set? ⇒ Boolean
:include: _doc/lib/restman/proxy_set?.rdoc
75 76 77 |
# File 'lib/restman.rb', line 75 def self.proxy_set? @proxy_set ||= false end |
.put(url, payload, headers = {}, &block) ⇒ Object
48 49 50 |
# File 'lib/restman.rb', line 48 def self.put(url, payload, headers={}, &block) Request.execute(:method => :put, :url => url, :payload => payload, :headers => headers, &block) end |
.reset_before_execution_procs ⇒ Object
:include: _doc/lib/restman/reset_before_execution_procs.rdoc
137 138 139 |
# File 'lib/restman.rb', line 137 def self.reset_before_execution_procs @@before_execution_procs = [] end |
.version ⇒ Object
5 6 7 |
# File 'lib/restman/version.rb', line 5 def self.version VERSION end |