Module: HTTPAccess2::Util
- Included in:
- Client
- Defined in:
- lib/rss-client/http-access2.rb
Class Method Summary collapse
- .hash_find_value(hash) ⇒ Object
- .parse_challenge_param(param_str) ⇒ Object
- .uri_dirname(uri) ⇒ Object
- .uri_part_of(uri, part) ⇒ Object
Instance Method Summary collapse
Class Method Details
.hash_find_value(hash) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/rss-client/http-access2.rb', line 72 def hash_find_value(hash) hash.each do |k, v| return v if yield(k, v) end nil end |
.parse_challenge_param(param_str) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rss-client/http-access2.rb', line 80 def parse_challenge_param(param_str) param = {} param_str.scan(/\s*([^\,]+(?:\\.[^\,]*)*)/).each do |str| key, value = str[0].scan(/\A([^=]+)=(.*)\z/)[0] if /\A"(.*)"\z/ =~ value value = $1.gsub(/\\(.)/, '\1') end param[key] = value end param end |
.uri_dirname(uri) ⇒ Object
65 66 67 68 69 |
# File 'lib/rss-client/http-access2.rb', line 65 def uri_dirname(uri) uri = uri.clone uri.path = uri.path.sub(/\/[^\/]*\z/, '/') uri end |
.uri_part_of(uri, part) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/rss-client/http-access2.rb', line 57 def uri_part_of(uri, part) ((uri.scheme == part.scheme) and (uri.host == part.host) and (uri.port == part.port) and uri.path.upcase.index(part.path.upcase) == 0) end |
Instance Method Details
#urify(uri) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/rss-client/http-access2.rb', line 49 def urify(uri) if uri.is_a?(URI) uri else URI.parse(uri.to_s) end end |