README.textile
h1. Domainatrix
!https://badge.fury.io/rb/shadowbq-domainatrix.png!:http://badge.fury.io/rb/shadowbq-domainatrix
h2. Summary
A cruel mistress that uses the public suffix domain list to dominate URLs by canonicalizing, finding public suffixes, and breaking them into their domain parts. This simple library can parse a URL into its canonical form. It uses the list of domains from "http://publicsuffix.org":http://publicsuffix.org to break the domain into its public suffix, domain, and subdomain.
h2. Installation
Install Default domainatrix
<pre>
gem install shadowbq-domainatrix
</pre>
Using Github Custom version in a GemFile
Installing a gem directly from a git repository is a feature of Bundler, not a feature of RubyGems. Gems installed this way will not show up when you run gem list.
<pre>
gem 'domainatrix', :git => 'git://github.com/shadowbq/domainatrix.git'
</pre>
h2. Code Status
"!https://codeclimate.com/github/shadowbq/domainatrix.png!":https://codeclimate.com/github/shadowbq/domainatrix "!https://secure.travis-ci.org/shadowbq/domainatrix.png?branch=master!":http://travis-ci.org/shadowbq/domainatrix !https://coveralls.io/repos/shadowbq/domainatrix/badge.png?branch=master(Coverage Status)!:https://coveralls.io/r/shadowbq/domainatrix
!https://gemnasium.com/shadowbq/domainatrix.png(Dependency Status)!:https://gemnasium.com/shadowbq/domainatrix
Fork of: _PaulDix's Original Domainatrix Repo_
"http://github.com/pauldix/domainatrix":http://github.com/pauldix/domainatrix
h2. Use
<pre>
require 'rubygems'
require 'domainatrix'
# Common Usage
url = Domainatrix.parse("http://www.pauldix.net")
url.url # => "http://www.pauldix.net/" (the original url)
url.host # => "www.pauldix.net"
url.public_suffix # => "net"
url.domain # => "pauldix"
url.canonical # => "net.pauldix"
# Looking at scheme and paths
url = Domainatrix.parse("http://foo.bar.pauldix.co.uk/asdf.html?q=arg")
url.public_suffix # => "co.uk"
url.domain # => "pauldix"
url.subdomain # => "foo.bar"
url.path # => "/asdf.html?q=arg"
url.canonical # => "uk.co.pauldix.bar.foo/asdf.html?q=arg"
url.scheme #=> "http"
# ICANN section only suffix search using DynDNS'
url = Domainatrix.icann_parse('www.foo.dyndns.org')
url.host #=> 'www.foo.dyndns.org' }
url.url #=> 'http://www.foo.dyndns.org/' }
url.public_suffix #=>'org' }
url.domain #=>'dyndns' }
url.subdomain #=> 'www.foo' }
url.domain_with_tld #=> 'dyndns.org' }
# Scanning text line
urls = Domainatrix.scan("wikipedia (http://en.wikipedia.org/wiki/Popular_culture): lol") do |match|
match.url # Given a block, works like 'map'
end
urls # => ["http://en.wikipedia.org/wiki/Popular_culture"]
</pre>
h2. Alternatives
The _publicsuffix-ruby_ gem is well supported, and also contains the publicsuffix.org dat file.
"https://github.com/weppos/publicsuffix-ruby":https://github.com/weppos/publicsuffix-ruby
h2. License
(The MIT License)
Copyright (c) 2009:
"Paul Dix":http://pauldix.net
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.