Addressabler extends the Addressable::URI class to provide information about, and manipulation of, URI strings.
Switch branches/tags
Nothing to show
Pull request Compare This branch is 23 commits behind flipsasser:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
autotest
lib
spec
.gitignore
LICENSE
README.markdown
Rakefile
VERSION

README.markdown

Addressabler

Addressabler extends the Addressable::URI class by adding TLD parsing, domain and subdomain parsing, and query modification.

Install

Install using Rubygems:

gem install addressabler

Then:

require 'rubygems'
require 'addressabler'

Addressabler will automatically require addressable/uri.

Usage

Use Addressable::URI like you normally would:

@uri = Addressable::URI.parse("http://www.google.com/")
@uri.host #=> "www.google.com"

Addressabler will add the following properties:

@uri.tld #=> "com"
@uri.domain #=> "google"
@uri.subdomain #=> "www"

You can set these values, as well:

@uri.tld = "org"
@uri.host #=> "www.google.org"
@uri.domain = "amazon"
@uri.host #=> "www.amazon.org"
@uri.subdomain = "developers"
@uri.host #=> "developers.amazon.org"

Addressabler copies some of Paul Dix's Domaintrix TLD code to support fancy TLDs, as well:

@uri.host = "www.google.co.uk"
@uri.tld #=> "co.uk"

Addressabler also makes editing queries a little bit easier:

@uri.query_hash[:foo] = :bar
@uri.to_s #=> "http://www.google.co.uk/?foo=bar"

That's it. Enjoy.