Skip to content

Instantly share code, notes, and snippets.

View sporkmonger's full-sized avatar

Bob Aman sporkmonger

View GitHub Profile
# Author: Cyril Rohr
# This has been gemified into the cacheability gem (http://github.com/cryx/cacheability/tree/master)
require 'rubygems'
require 'rest_client' # sudo gem install rest-client
require 'rack/cache' # sudo gem install rack-cache
require 'addressable/uri' # sudo gem install addressable
module RestClient
# this is a quick hack to show how you can use rack-cache as a powerful client cache.
# BAD:
foo.bar = 25
foo.biz = 'Hello World'
foo.bazzle = 42
# GOOD:
foo.bar = 25
foo.biz = 'Hello World'
foo.bazzle = 42
# Percent encodes a URI or component.
#
# @param [String, #to_str] uri The URI or component to encode.
#
# @option [String, Regexp] character_class
# The characters which are not percent encoded. If a <tt>String</tt>
# is passed, the <tt>String</tt> must be formatted as a regular
# expression character class. (Do not include the surrounding square
# brackets.) For example, <tt>"b-zB-Z0-9"</tt> would cause everything
# but the letters 'b' through 'z' and the numbers '0' through '9' to be