Permalink
Browse files

Version patch bump, added addressable and a few more attributes

  • Loading branch information...
Sander Hartlage
Sander Hartlage committed Jan 19, 2010
1 parent fe54d7b commit 1416b8b04639e03cff17b1e3e43c275571c215d1
View
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{domainatrix}
- s.version = "0.0.6"
+ s.version = "0.0.7"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Paul Dix"]
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.5}
s.summary = %q{A cruel mistress that uses the public suffix domain list to dominate URLs by canonicalizing, finding the public suffix, and breaking them into their domain parts.}
+ s.add_dependency("addressable")
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
View
@@ -1,11 +1,11 @@
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))
-require 'uri'
+require 'addressable/uri'
require 'domainatrix/domain_parser.rb'
require 'domainatrix/url.rb'
module Domainatrix
- VERSION = "0.0.6"
+ VERSION = "0.0.7"
def self.parse(url)
@domain_parser ||= DomainParser.new("#{File.dirname(__FILE__)}/effective_tld_names.dat")
@@ -1,5 +1,7 @@
module Domainatrix
class DomainParser
+ include Addressable
+
attr_reader :public_suffixes
def initialize(file_name)
@@ -28,7 +30,12 @@ def parse(url)
else
path = uri.path
end
- parse_domains_from_host(uri.host).merge({:path => path, :url => url})
+ parse_domains_from_host(uri.host).merge({
+ :scheme => uri.scheme,
+ :host => uri.host,
+ :path => path,
+ :url => url
+ })
end
def parse_domains_from_host(host)
View
@@ -1,8 +1,10 @@
module Domainatrix
class Url
- attr_reader :public_suffix, :domain, :subdomain, :path, :url
+ attr_reader :public_suffix, :domain, :subdomain, :path, :url, :scheme, :host
def initialize(attrs = {})
+ @scheme = attrs[:scheme]
+ @host = attrs[:host]
@url = attrs[:url]
@public_suffix = attrs[:public_suffix]
@domain = attrs[:domain]
@@ -33,6 +33,14 @@
@domain_parser.parse("http://www.pauldix.net")[:url].should == "http://www.pauldix.net"
end
+ it "includes the scheme" do
+ @domain_parser.parse("http://www.pauldix.net")[:scheme].should == "http"
+ end
+
+ it "includes the full host" do
+ @domain_parser.parse("http://www.pauldix.net")[:host].should == "www.pauldix.net"
+ end
+
it "parses out the path" do
@domain_parser.parse("http://pauldix.net/foo.html?asdf=foo")[:path].should == "/foo.html?asdf=foo"
@domain_parser.parse("http://pauldix.net?asdf=foo")[:path].should == "?asdf=foo"

0 comments on commit 1416b8b

Please sign in to comment.