domainatrix 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
1
  module Domainatrix
2
2
  class DomainParser
3
+ include Addressable
4
+
3
5
  attr_reader :public_suffixes
4
6
 
5
7
  def initialize(file_name)
@@ -28,7 +30,12 @@ module Domainatrix
28
30
  else
29
31
  path = uri.path
30
32
  end
31
- parse_domains_from_host(uri.host).merge({:path => path, :url => url})
33
+ parse_domains_from_host(uri.host).merge({
34
+ :scheme => uri.scheme,
35
+ :host => uri.host,
36
+ :path => path,
37
+ :url => url
38
+ })
32
39
  end
33
40
 
34
41
  def parse_domains_from_host(host)
@@ -1,8 +1,10 @@
1
1
  module Domainatrix
2
2
  class Url
3
- attr_reader :public_suffix, :domain, :subdomain, :path, :url
3
+ attr_reader :public_suffix, :domain, :subdomain, :path, :url, :scheme, :host
4
4
 
5
5
  def initialize(attrs = {})
6
+ @scheme = attrs[:scheme]
7
+ @host = attrs[:host]
6
8
  @url = attrs[:url]
7
9
  @public_suffix = attrs[:public_suffix]
8
10
  @domain = attrs[:domain]
data/lib/domainatrix.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))
2
2
 
3
- require 'uri'
3
+ require 'addressable/uri'
4
4
  require 'domainatrix/domain_parser.rb'
5
5
  require 'domainatrix/url.rb'
6
6
 
7
7
  module Domainatrix
8
- VERSION = "0.0.6"
8
+ VERSION = "0.0.7"
9
9
 
10
10
  def self.parse(url)
11
11
  @domain_parser ||= DomainParser.new("#{File.dirname(__FILE__)}/effective_tld_names.dat")
@@ -33,6 +33,14 @@ describe "domain parser" do
33
33
  @domain_parser.parse("http://www.pauldix.net")[:url].should == "http://www.pauldix.net"
34
34
  end
35
35
 
36
+ it "includes the scheme" do
37
+ @domain_parser.parse("http://www.pauldix.net")[:scheme].should == "http"
38
+ end
39
+
40
+ it "includes the full host" do
41
+ @domain_parser.parse("http://www.pauldix.net")[:host].should == "www.pauldix.net"
42
+ end
43
+
36
44
  it "parses out the path" do
37
45
  @domain_parser.parse("http://pauldix.net/foo.html?asdf=foo")[:path].should == "/foo.html?asdf=foo"
38
46
  @domain_parser.parse("http://pauldix.net?asdf=foo")[:path].should == "?asdf=foo"
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix
@@ -11,8 +11,17 @@ cert_chain: []
11
11
 
12
12
  date: 2009-12-10 00:00:00 -05:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: addressable
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
16
25
  description:
17
26
  email: paul@pauldix.net
18
27
  executables: []