Sha256: d61803a7fb41113063afc7b956fe9803c2404144663ff839c0aa7f70bb4b0dfd
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require 'cgi' require 'uri' module Riak class << self # @see #escaper= attr_reader :escaper # Sets the class used for escaping URLs (buckets and keys) sent to # Riak. Currently only supports URI and CGI, and defaults to URI. # @param [Symbol,String,Class] esc A representation of which # escaping class to use, either the Class itself or a String or # Symbol name # @see Riak::Util::Escape def escaper=(esc) case esc when Symbol, String @escaper = ::Object.const_get(esc.to_s.upcase.intern) if esc.to_s =~ /uri|cgi/i when Class, Module @escaper = esc end end end self.escaper = URI module Util # Methods for escaping URL segments. module Escape # CGI-escapes bucket or key names that may contain slashes for use in URLs. # @param [String] bucket_or_key the bucket or key name # @return [String] the escaped path segment def escape(bucket_or_key) Riak.escaper.escape(bucket_or_key.to_s).gsub("+", "%20").gsub('/', "%2F") end # CGI-unescapes bucket or key names # @param [String] bucket_or_key the bucket or key name # @return [String] the unescaped name def unescape(bucket_or_key) Riak.escaper.unescape(bucket_or_key.to_s) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
seomoz-riak-client-1.0.0.pre | lib/riak/util/escape.rb |