alexrabarts-IsoCountryCodes 0.1.1

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.
@@ -0,0 +1,8 @@
1
+ === 0.1.1 / 2008-11-21
2
+
3
+ * Each country now represented by a single class instead of one for each code
4
+
5
+ === 0.1.0 / 2008-11-20
6
+
7
+ * Initial release
8
+
@@ -0,0 +1,6 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/iso_country_codes.rb
6
+ test/test_iso_country_codes.rb
@@ -0,0 +1,65 @@
1
+ = IsoCountryCodes
2
+
3
+ == DESCRIPTION:
4
+
5
+ Provides ISO codes and names for countries.
6
+
7
+ == FEATURES:
8
+
9
+ * Search by name or code (alpha-2, alpha-3 or numeric)
10
+
11
+ == PROBLEMS:
12
+
13
+ * Name search requires an exact match (although it is case-insensitive)
14
+
15
+ == SYNOPSIS:
16
+
17
+ # Finding an ISO code returns the country name and other code formats
18
+ code = IsoCountryCodes.find('au')
19
+ code.name # => "Australia"
20
+ code.numeric # => "036"
21
+ code.alpha2 # => "AU"
22
+ code.alpha3 # => "AUS"
23
+
24
+ # Codes can be found via numeric, alpha-2 or alpha-3 format
25
+ IsoCountryCodes.find(36)
26
+ IsoCountryCodes.find('au')
27
+ IsoCountryCodes.find('aus')
28
+
29
+ # Codes can be found by country name
30
+ IsoCountryCodes.find('australia')
31
+
32
+ == INSTALL:
33
+
34
+ * Via git:
35
+
36
+ git clone git://github.com/alexrabarts/iso-country-codes.git
37
+
38
+ * Via gem:
39
+
40
+ gem install alexrabarts-iso-country-codes -s http://gems.github.com
41
+
42
+ == LICENSE:
43
+
44
+ (The MIT License)
45
+
46
+ Copyright (c) 2008 Stateless Systems (http://statelesssystems.com)
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of this software and associated documentation files (the
50
+ 'Software'), to deal in the Software without restriction, including
51
+ without limitation the rights to use, copy, modify, merge, publish,
52
+ distribute, sublicense, and/or sell copies of the Software, and to
53
+ permit persons to whom the Software is furnished to do so, subject to
54
+ the following conditions:
55
+
56
+ The above copyright notice and this permission notice shall be
57
+ included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
60
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
63
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
64
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
65
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/iso_country_codes.rb'
6
+
7
+ Hoe.new('IsoCountryCodes', IsoCountryCodes::VERSION) do |p|
8
+ # p.rubyforge_name = 'IsoCountryCodesx' # if different than lowercase project name
9
+ p.developer('Alex Rabarts', 'alexrabarts@gmail.com')
10
+ end
11
+
12
+ # Load extra rake tasks.
13
+ tasks_path = File.join(File.dirname(__FILE__), 'rakelib')
14
+ rake_files = Dir["#{tasks_path}/*.rake"]
15
+ rake_files.each{|rake_file| load rake_file}
16
+
17
+ # vim: syntax=Ruby
@@ -0,0 +1,6 @@
1
+ dir = File.dirname(__FILE__)
2
+ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
3
+
4
+ require 'iso_country_codes/code'
5
+ require 'iso_country_codes/iso_3166_1'
6
+ require 'iso_country_codes/iso_country_codes'
@@ -0,0 +1,70 @@
1
+ require 'test/unit'
2
+ require 'iso_country_codes'
3
+
4
+ class TestIsoCountryCodes < Test::Unit::TestCase
5
+ def test_find_with_numeric_as_two_digit_string
6
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('36')
7
+ end
8
+
9
+ def test_find_with_numeric_as_three_digit_string
10
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('036')
11
+ end
12
+
13
+ def test_find_with_numeric_as_integer
14
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find(36)
15
+ end
16
+
17
+ def test_find_with_lowercase_alpha2
18
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('au')
19
+ end
20
+
21
+ def test_find_with_uppercase_alpha2
22
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('AU')
23
+ end
24
+
25
+ def test_find_with_lowercase_alpha3
26
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('aus')
27
+ end
28
+
29
+ def test_find_with_uppercase_alpha3
30
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('AUS')
31
+ end
32
+
33
+ def test_find_with_lowercase_name
34
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('australia')
35
+ end
36
+
37
+ def test_find_with_uppercase_name
38
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('AUSTRALIA')
39
+ end
40
+
41
+ def test_find_with_mixed_case_name
42
+ assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('Australia')
43
+ end
44
+
45
+ def test_get_numeric
46
+ assert_equal '036', IsoCountryCodes::Code::AUS.numeric
47
+ assert_equal '036', IsoCountryCodes::Code::AUS.instance.numeric
48
+ end
49
+
50
+ def test_get_alpha2
51
+ assert_equal 'AU', IsoCountryCodes::Code::AUS.alpha2
52
+ assert_equal 'AU', IsoCountryCodes::Code::AUS.instance.alpha2
53
+ end
54
+
55
+ def test_get_alpha3
56
+ assert_equal 'AUS', IsoCountryCodes::Code::AUS.alpha3
57
+ assert_equal 'AUS', IsoCountryCodes::Code::AUS.instance.alpha3
58
+ end
59
+
60
+ def test_get_name
61
+ assert_equal 'Australia', IsoCountryCodes::Code::AUS.name
62
+ assert_equal 'Australia', IsoCountryCodes::Code::AUS.instance.name
63
+ end
64
+
65
+ def test_unknown_iso_code
66
+ assert_raises IsoCountryCodes::UnknownCodeError do
67
+ IsoCountryCodes.find('FOO')
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alexrabarts-IsoCountryCodes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Rabarts
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-21 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.8.2
23
+ version:
24
+ description: Provides ISO codes and names for countries.
25
+ email:
26
+ - alexrabarts@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ files:
36
+ - History.txt
37
+ - Manifest.txt
38
+ - README.txt
39
+ - Rakefile
40
+ - lib/iso_country_codes.rb
41
+ - test/test_iso_country_codes.rb
42
+ has_rdoc: true
43
+ homepage:
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --main
47
+ - README.txt
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ requirements: []
63
+
64
+ rubyforge_project: isocountrycodes
65
+ rubygems_version: 1.2.0
66
+ signing_key:
67
+ specification_version: 2
68
+ summary: Provides ISO codes and names for countries.
69
+ test_files:
70
+ - test/test_iso_country_codes.rb