This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BAD: | |
foo.bar = 25 | |
foo.biz = 'Hello World' | |
foo.bazzle = 42 | |
# GOOD: | |
foo.bar = 25 | |
foo.biz = 'Hello World' | |
foo.bazzle = 42 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |