Module: Micky
- Defined in:
- lib/micky.rb,
lib/micky/uri.rb,
lib/micky/errors.rb,
lib/micky/request.rb,
lib/micky/version.rb,
lib/micky/response.rb
Defined Under Namespace
Modules: URI Classes: ClientError, Error, HTTPClientError, HTTPServerError, HostError, InvalidURIError, NoRedirectLocation, Request, Response, ServerError, TooManyRedirects
Constant Summary collapse
- HTTP_URI_REGEX =
%r{\Ahttps?:/+}- VERSION =
'0.6.5'
Class Attribute Summary collapse
-
.headers ⇒ Object
Returns the value of attribute headers.
-
.max_redirects ⇒ Object
Returns the value of attribute max_redirects.
-
.oauth ⇒ Object
Returns the value of attribute oauth.
-
.parsers ⇒ Object
Returns the value of attribute parsers.
-
.query ⇒ Object
Returns the value of attribute query.
-
.raise_errors ⇒ Object
Returns the value of attribute raise_errors.
-
.resolve_timeout ⇒ Object
Returns the value of attribute resolve_timeout.
-
.skip_resolve ⇒ Object
Returns the value of attribute skip_resolve.
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Class Attribute Details
.headers ⇒ Object
Returns the value of attribute headers.
17 18 19 |
# File 'lib/micky.rb', line 17 def headers @headers end |
.max_redirects ⇒ Object
Returns the value of attribute max_redirects.
11 12 13 |
# File 'lib/micky.rb', line 11 def max_redirects @max_redirects end |
.oauth ⇒ Object
Returns the value of attribute oauth.
15 16 17 |
# File 'lib/micky.rb', line 15 def oauth @oauth end |
.parsers ⇒ Object
Returns the value of attribute parsers.
18 19 20 |
# File 'lib/micky.rb', line 18 def parsers @parsers end |
.query ⇒ Object
Returns the value of attribute query.
16 17 18 |
# File 'lib/micky.rb', line 16 def query @query end |
.raise_errors ⇒ Object
Returns the value of attribute raise_errors.
10 11 12 |
# File 'lib/micky.rb', line 10 def raise_errors @raise_errors end |
.resolve_timeout ⇒ Object
Returns the value of attribute resolve_timeout.
14 15 16 |
# File 'lib/micky.rb', line 14 def resolve_timeout @resolve_timeout end |
.skip_resolve ⇒ Object
Returns the value of attribute skip_resolve.
13 14 15 |
# File 'lib/micky.rb', line 13 def skip_resolve @skip_resolve end |
.timeout ⇒ Object
Returns the value of attribute timeout.
12 13 14 |
# File 'lib/micky.rb', line 12 def timeout @timeout end |
Class Method Details
.get(uri, opts = {}) ⇒ Object
37 38 39 |
# File 'lib/micky.rb', line 37 def self.get(uri, opts = {}) Request.new(opts).get(uri) end |
.head(uri, opts = {}) ⇒ Object
41 42 43 |
# File 'lib/micky.rb', line 41 def self.head(uri, opts = {}) Request.new(opts).head(uri) end |
.URI(uri) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/micky/uri.rb', line 6 def self.URI(uri) uri = uri.to_s.strip if uri =~ HTTP_URI_REGEX # Replace any number of slashes (1, 3 or 4579) by two slashes uri.sub! %r{/+}, '//'.freeze else uri = "http://#{uri}" end begin ::URI.parse(uri) rescue ::URI::InvalidURIError begin ::URI.parse(::URI.encode(uri)) rescue ::URI::InvalidURIError end end end |