alexrabarts-tld 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt ADDED
@@ -0,0 +1,15 @@
1
+ === 0.2.0 / 2008-11-25
2
+
3
+ * ISO 3166-1 alpha-3 country codes made available
4
+
5
+ === 0.1.1 / 2008-11-25
6
+
7
+ Bug fixes:
8
+
9
+ * US-based .gov and .mil TLDs now return USD as their currency
10
+ * .com no longer returns the currency for Comoros
11
+
12
+ === 0.1.0 / 2008-11-20
13
+
14
+ * Initial release
15
+
data/Manifest.txt ADDED
@@ -0,0 +1,22 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/tld.rb
6
+ lib/tld/alpha3.rb
7
+ lib/tld/cc_tld.rb
8
+ lib/tld/currency.rb
9
+ lib/tld/generic_tld.rb
10
+ lib/tld/infrastructure_tld.rb
11
+ lib/tld/name.rb
12
+ lib/tld/pseudo_tld.rb
13
+ lib/tld/reserved_tld.rb
14
+ lib/tld/retired_tld.rb
15
+ lib/tld/sponsored_tld.rb
16
+ lib/tld/tld.rb
17
+ rakelib/cultivate.rake
18
+ rakelib/tld.rake
19
+ rakelib/tld.rb
20
+ rakelib/tld.rb.erb
21
+ test/test_tld.rb
22
+ tld.gemspec
data/README.txt ADDED
@@ -0,0 +1,66 @@
1
+ = TLD
2
+
3
+ == DESCRIPTION:
4
+
5
+ Provides meta information for Internet Top Level Domains (TLDs) such as a
6
+ descriptive name, associated currency code and the TLD category.
7
+
8
+ == SYNOPSIS:
9
+
10
+ # Find a descriptive name
11
+ TLD.find('au').name # => "Australia"
12
+ TLD.find('biz').name # => "Business"
13
+
14
+ # Find the TLD category (country code, generic, infrastructure, pseudo,
15
+ # reserved, retired or sponsored)
16
+ TLD.find('au').type # => :cc
17
+ TLD.find('biz').type # => :generic
18
+
19
+ # Find the ISO 4217 currency code for a ccTld
20
+ TLD.find('au').currency # => 'AUD'
21
+
22
+ # Find the ISO 3166-1 alpha-3 country code for a ccTld
23
+ TLD.find('uk').alpha3 # => 'GBR'
24
+
25
+ # Search with a hostname or URL
26
+ TLD.find('foo.com.au').name # => "Australia"
27
+ TLD.find('http://foo.com.au/bar').name # => "Australia"
28
+
29
+ == REQUIREMENTS:
30
+
31
+ iso_country_codes gem (see http://github.com/alexrabarts/iso_country_codes)
32
+
33
+ == INSTALL:
34
+
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
42
+
43
+ == LICENSE:
44
+
45
+ (The MIT License)
46
+
47
+ Copyright (c) 2008 Stateless Systems (http://statelesssystems.com)
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ 'Software'), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
63
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
64
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
65
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
66
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/tld.rb'
6
+
7
+ Hoe.new('tld', TLD::VERSION) do |p|
8
+ # p.rubyforge_name = 'TLDx' # if different than lowercase project name
9
+ p.developer('Alex Rabarts', 'alexrabarts@gmail.com')
10
+ p.extra_deps = [
11
+ ['alexrabarts-iso_country_codes']
12
+ ]
13
+ end
14
+
15
+ # Load extra rake tasks.
16
+ tasks_path = File.join(File.dirname(__FILE__), 'rakelib')
17
+ rake_files = Dir["#{tasks_path}/*.rake"]
18
+ rake_files.each{|rake_file| load rake_file}
19
+
20
+ # vim: syntax=Ruby
data/lib/tld/alpha3.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'iso_country_codes'
3
+
4
+ class TLD
5
+ class Alpha3
6
+ class << self
7
+ def find(klass)
8
+ tld = klass.tld
9
+ return tld.match(/^\w\w$/) ? IsoCountryCodes.find(TLD::MAP[tld.to_sym] || tld).alpha3 : nil
10
+ end
11
+ end
12
+ end
13
+ end