domainatrix 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -23,6 +23,7 @@ require 'rubygems'
23
23
  require 'domainatrix'
24
24
 
25
25
  url = Domainatrix.parse("http://www.pauldix.net")
26
+ url.url # => "http://www.pauldix.net" (the original url)
26
27
  url.tld # => "net"
27
28
  url.domain # => "pauldix"
28
29
  url.canonical # => "net.pauldix"
data/lib/domainatrix.rb CHANGED
@@ -5,7 +5,7 @@ require 'domainatrix/domain_parser.rb'
5
5
  require 'domainatrix/url.rb'
6
6
 
7
7
  module Domainatrix
8
- VERSION = "0.0.3"
8
+ VERSION = "0.0.4"
9
9
 
10
10
  def self.parse(url)
11
11
  @domain_parser ||= DomainParser.new("#{File.dirname(__FILE__)}/effective_tld_names.dat")
@@ -28,7 +28,7 @@ module Domainatrix
28
28
  else
29
29
  path = uri.path
30
30
  end
31
- parse_domains_from_host(uri.host).merge({:path => path})
31
+ parse_domains_from_host(uri.host).merge({:path => path, :url => url})
32
32
  end
33
33
 
34
34
  def parse_domains_from_host(host)
@@ -1,8 +1,9 @@
1
1
  module Domainatrix
2
2
  class Url
3
- attr_reader :tld, :domain, :subdomain, :path
3
+ attr_reader :tld, :domain, :subdomain, :path, :url
4
4
 
5
5
  def initialize(attrs = {})
6
+ @url = attrs[:url]
6
7
  @tld = attrs[:tld]
7
8
  @domain = attrs[:domain]
8
9
  @subdomain = attrs[:subdomain]
@@ -29,8 +29,8 @@ describe "domain parser" do
29
29
  @domain_parser.parse("http://pauldix.net").should be_a Hash
30
30
  end
31
31
 
32
- it "should strip the http://" do
33
- @domain_parser.parse("http://pauldix.net").values.each {|val| (val =~ /http\:\/\//).should_not be}
32
+ it "includes the original url" do
33
+ @domain_parser.parse("http://www.pauldix.net")[:url].should == "http://www.pauldix.net"
34
34
  end
35
35
 
36
36
  it "parses out the path" do
@@ -1,6 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe "url" do
4
+ it "has the original url" do
5
+ Domainatrix::Url.new(:url => "http://pauldix.net").url.should == "http://pauldix.net"
6
+ end
7
+
4
8
  it "has the tld" do
5
9
  Domainatrix::Url.new(:tld => "net").tld.should == "net"
6
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domainatrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix