domain_name 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -4,14 +4,18 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "domain_name"
8
- s.version = "0.5.0"
7
+ s.name = %q{domain_name}
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Akinori MUSHA"]
12
- s.date = "2011-11-04"
13
- s.description = "This is a Domain Name manipulation library for Ruby.\n\nIt can also be used for cookie domain validation based on the Public\nSuffix List.\n"
14
- s.email = "knu@idaemons.org"
11
+ s.authors = [%q{Akinori MUSHA}]
12
+ s.date = %q{2011-11-09}
13
+ s.description = %q{This is a Domain Name manipulation library for Ruby.
14
+
15
+ It can also be used for cookie domain validation based on the Public
16
+ Suffix List.
17
+ }
18
+ s.email = %q{knu@idaemons.org}
15
19
  s.extra_rdoc_files = [
16
20
  "LICENSE.txt",
17
21
  "README.md"
@@ -34,11 +38,11 @@ Gem::Specification.new do |s|
34
38
  "test/test_domain_name.rb",
35
39
  "tool/gen_etld_data.rb"
36
40
  ]
37
- s.homepage = "http://github.com/knu/ruby-domain_name"
38
- s.licenses = ["BSD + MPL 1.1/GPL 2.0/LGPL 2.1"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = "1.8.11"
41
- s.summary = "Domain Name manipulation library for Ruby"
41
+ s.homepage = %q{http://github.com/knu/ruby-domain_name}
42
+ s.licenses = [%q{BSD + MPL 1.1/GPL 2.0/LGPL 2.1}]
43
+ s.require_paths = [%q{lib}]
44
+ s.rubygems_version = %q{1.8.5}
45
+ s.summary = %q{Domain Name manipulation library for Ruby}
42
46
 
43
47
  if s.respond_to? :specification_version then
44
48
  s.specification_version = 3
@@ -58,6 +58,9 @@ class DomainName
58
58
  # Parses _hostname_ into a DomainName object. An IP address is also
59
59
  # accepted. An IPv6 address may be enclosed in square brackets.
60
60
  def initialize(hostname)
61
+ hostname.is_a?(String) or
62
+ (hostname.respond_to?(:to_str) && (hostname = hostname.to_str).is_a?(String)) or
63
+ raise TypeError, "#{hostname.class} is not a String"
61
64
  if hostname.start_with?(DOT)
62
65
  raise ArgumentError, "domain name must not start with a dot: #{hostname}"
63
66
  end
@@ -146,10 +149,10 @@ class DomainName
146
149
  othername = other.hostname
147
150
  if othername == @hostname
148
151
  0
149
- elsif @hostname.end_with?(othername) && @hostname[-othername.size - 1] == '.'
152
+ elsif @hostname.end_with?(othername) && @hostname[-othername.size - 1, 1] == DOT
150
153
  # The other is higher
151
154
  -1
152
- elsif othername.end_with?(@hostname) && othername[-@hostname.size - 1] == '.'
155
+ elsif othername.end_with?(@hostname) && othername[-@hostname.size - 1, 1] == DOT
153
156
  # The other is lower
154
157
  1
155
158
  else
@@ -14,6 +14,26 @@ class TestDomainName < Test::Unit::TestCase
14
14
  }
15
15
  end
16
16
 
17
+ should "accept a String-alike for initialization" do
18
+ Object.new.tap { |obj|
19
+ def obj.to_str
20
+ "Example.org"
21
+ end
22
+ assert_equal "example.org", DomainName.new(obj).hostname
23
+ }
24
+
25
+ Object.new.tap { |obj|
26
+ def obj.to_str
27
+ 123
28
+ end
29
+ assert_raises(TypeError) { DomainName.new(obj) }
30
+ }
31
+
32
+ Object.new.tap { |obj|
33
+ assert_raises(TypeError) { DomainName.new(obj) }
34
+ }
35
+ end
36
+
17
37
  should "parse canonical domain names correctly" do
18
38
  [
19
39
  # Mixed case.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domain_name
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Akinori MUSHA
@@ -15,10 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-04 00:00:00 Z
18
+ date: 2011-11-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ name: unf
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
23
  none: false
23
24
  requirements:
24
25
  - - ~>
@@ -29,12 +30,12 @@ dependencies:
29
30
  - 0
30
31
  - 3
31
32
  version: 0.0.3
32
- version_requirements: *id001
33
- name: unf
34
- prerelease: false
35
33
  type: :runtime
34
+ requirement: *id001
35
+ prerelease: false
36
36
  - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ name: shoulda
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
39
  none: false
39
40
  requirements:
40
41
  - - ">="
@@ -43,12 +44,12 @@ dependencies:
43
44
  segments:
44
45
  - 0
45
46
  version: "0"
46
- version_requirements: *id002
47
- name: shoulda
48
- prerelease: false
49
47
  type: :development
48
+ requirement: *id002
49
+ prerelease: false
50
50
  - !ruby/object:Gem::Dependency
51
- requirement: &id003 !ruby/object:Gem::Requirement
51
+ name: bundler
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
53
  none: false
53
54
  requirements:
54
55
  - - ~>
@@ -59,12 +60,12 @@ dependencies:
59
60
  - 0
60
61
  - 0
61
62
  version: 1.0.0
62
- version_requirements: *id003
63
- name: bundler
64
- prerelease: false
65
63
  type: :development
64
+ requirement: *id003
65
+ prerelease: false
66
66
  - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
67
+ name: jeweler
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
69
  none: false
69
70
  requirements:
70
71
  - - ~>
@@ -75,12 +76,12 @@ dependencies:
75
76
  - 6
76
77
  - 4
77
78
  version: 1.6.4
78
- version_requirements: *id004
79
- name: jeweler
80
- prerelease: false
81
79
  type: :development
80
+ requirement: *id004
81
+ prerelease: false
82
82
  - !ruby/object:Gem::Dependency
83
- requirement: &id005 !ruby/object:Gem::Requirement
83
+ name: rcov
84
+ version_requirements: &id005 !ruby/object:Gem::Requirement
84
85
  none: false
85
86
  requirements:
86
87
  - - ">="
@@ -89,10 +90,9 @@ dependencies:
89
90
  segments:
90
91
  - 0
91
92
  version: "0"
92
- version_requirements: *id005
93
- name: rcov
94
- prerelease: false
95
93
  type: :development
94
+ requirement: *id005
95
+ prerelease: false
96
96
  description: |
97
97
  This is a Domain Name manipulation library for Ruby.
98
98
 
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  requirements: []
154
154
 
155
155
  rubyforge_project:
156
- rubygems_version: 1.8.11
156
+ rubygems_version: 1.8.5
157
157
  signing_key:
158
158
  specification_version: 3
159
159
  summary: Domain Name manipulation library for Ruby