Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Implements the URITemplate draft v7
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
LICENSE
README.mkd
Rakefile
uri_template.gemspec

README.mkd

UriTemplate

Implements the URI Template draft spec, v7 http://tools.ietf.org/html/draft-gregorio-uritemplate-07

Installation

Add this line to your application's Gemfile:

gem 'ruby_uri_template'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruby_uri_template

Usage

  1. UriTemplate.new with a UriTemplate.
  2. #expand the template with a hash of params to be used. Both Strings and Symbols are valid as keys.

Example:

tmpl = UriTemplate.new("http://example.com/search{?q,lang}")
tmpl.expand(:q => ["dogs", "cats"], "lang" => "en_US")
# => "http://example.com/search?q=dogs,cats&lang=en_US"

See the spec for other examples.

Note: Sometimes the spec fails on 1.8 because of hash-ordering. Use 1.9 or an ordered hash library if the order is important to you.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.