alexrabarts-tld 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.5.0 / 2009-06-30
2
+
3
+ * TLD.valid? method added, which allows you to check if a given string is
4
+ a valid TLD.
5
+
1
6
  === 0.4.0 / 2009-06-30
2
7
 
3
8
  * You can now call to_s on a TLD object, which will return the canonical name
data/README.rdoc CHANGED
@@ -7,6 +7,8 @@ descriptive name, associated currency code and the TLD category.
7
7
 
8
8
  == SYNOPSIS:
9
9
 
10
+ require 'tld'
11
+
10
12
  # Find a descriptive name
11
13
  TLD.find('au').name # => "Australia"
12
14
  TLD.find('biz').name # => "Business"
@@ -26,19 +28,17 @@ descriptive name, associated currency code and the TLD category.
26
28
  TLD.find('foo.com.au').name # => "Australia"
27
29
  TLD.find('http://foo.com.au/bar').name # => "Australia"
28
30
 
31
+ # Check if a TLD is valid
32
+ TLD.valid?('au') # => true
33
+ TLD.valid?('foo') # => false
34
+
29
35
  == REQUIREMENTS:
30
36
 
31
37
  iso_country_codes gem (see http://github.com/alexrabarts/iso_country_codes)
32
38
 
33
39
  == INSTALL:
34
40
 
35
- * Via git:
36
-
37
- git clone git://github.com/alexrabarts/tld.git
38
-
39
- * Via gem:
40
-
41
- gem install alexrabarts-tld -s http://gems.github.com
41
+ gem install alexrabarts-tld -s http://gems.github.com
42
42
 
43
43
  == LICENSE:
44
44
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 4
2
+ :minor: 5
3
3
  :patch: 0
4
4
  :major: 0
data/lib/tld/tld.rb CHANGED
@@ -85,5 +85,9 @@ class TLD
85
85
 
86
86
  instance
87
87
  end
88
+
89
+ def valid?(tld)
90
+ !!all.select { |t| t.to_s == tld.downcase }.first
91
+ end
88
92
  end
89
93
  end
data/test/tld_test.rb CHANGED
@@ -59,4 +59,13 @@ class TestTld < Test::Unit::TestCase
59
59
  TLD.find('foo')
60
60
  end
61
61
  end
62
+
63
+ should 'confirm that TLD is valid' do
64
+ assert TLD.valid?('au')
65
+ assert TLD.valid?('AU')
66
+ end
67
+
68
+ should 'confirm that TLD is invalid' do
69
+ assert_equal false, TLD.valid?('not-a-tld')
70
+ end
62
71
  end
data/tld.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{tld}
5
- s.version = "0.4.0"
5
+ s.version = "0.5.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["alex"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexrabarts-tld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alex