Module: Rufus::Jig
- Defined in:
- lib/rufus/jig.rb,
lib/rufus/jig/http.rb,
lib/rufus/jig/path.rb,
lib/rufus/jig/couch.rb,
lib/rufus/jig/version.rb
Defined Under Namespace
Modules: Path Classes: Couch, Http, HttpCore, HttpError, HttpResponse, TimeoutError, Uri
Constant Summary collapse
- URI_REGEX =
/(https?):\/\/([^@]+:[^@]+@)?([^\/]+)(.*)?$/- PATH_REGEX =
/([^\?#]*)(\?[^#]+)?(#[^#]+)?$/- VERSION =
'1.0.0'
Class Method Summary collapse
-
.marshal_copy(o) ⇒ Object
The classical helper method, does a full copy of the given object.
-
.parse_host(s) ⇒ Object
The current URI lib is not UTF-8 friendly, so this is a workaround.
-
.parse_uri(s) ⇒ Object
The current URI lib is not UTF-8 friendly, so this is a workaround.
Class Method Details
.marshal_copy(o) ⇒ Object
The classical helper method, does a full copy of the given object. Thanks Marshal.
36 37 38 39 |
# File 'lib/rufus/jig/http.rb', line 36 def self.marshal_copy(o) Marshal.load(Marshal.dump(o)) end |
.parse_host(s) ⇒ Object
The current URI lib is not UTF-8 friendly, so this is a workaround. Temporary hopefully.
180 181 182 183 184 185 |
# File 'lib/rufus/jig/http.rb', line 180 def self.parse_host(s) u = parse_uri(s) u ? u.host : nil end |
.parse_uri(s) ⇒ Object
The current URI lib is not UTF-8 friendly, so this is a workaround. Temporary hopefully.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/rufus/jig/http.rb', line 148 def self.parse_uri(s) m = URI_REGEX.match(s) scheme, uname, pass, host, port, tail = if m ho, po = m[3].split(':') po = (po || 80).to_i un, pa = m[2] ? m[2][0..-2].split(':') : [ nil, nil ] [ m[1], un, pa, ho, po, m[4] ] else [ nil, nil, nil, nil, nil, s ] end m = PATH_REGEX.match(tail) path, query, fragment = [ m[1], m[2], m[3] ] port = 443 if scheme == 'https' && port == 80 query = query[1..-1] if query fragment = fragment[1..-1] if fragment Uri.new(scheme, uname, pass, host, port, path, query, fragment) end |