normalize_country 0.1.0 → 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.
- checksums.yaml +6 -14
- data/README.rdoc +23 -13
- data/lib/normalize_country.rb +1 -1
- data/lib/normalize_country/countries/en.yml +13 -13
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MTA4MWExODA0NDQyZjIwMTM3YmJkNzM0NTkzM2JmZjFlNWFjYzc4NjVhY2E5
|
10
|
-
MTk4ZjlkYTkyMTU1OGYzZTUxN2QwZmIxNThkY2Y4Yzk4OTlmODUwYTg4Y2E5
|
11
|
-
N2I5NjMxMjQzMWIzYmRhNDhmZGFmYWYwMTVkOTY3ZDkzYmFjMDQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZDk2YTRhYTZmMWMxM2RiOTA4NzRmZTNhMDM1MzM0ZDdlODVjYWVhNDk0OWI5
|
14
|
-
MWM5Njk4ZWFlMGZjMTZlY2M5NzU5ZTg2NjNhNjliOGJkMjczODNmYWFlMDli
|
15
|
-
OWZkM2VhNTZlZDZmMmI1NDMzOTg1ODk1YTlkZDBiM2IzMzY1ZWQ=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 720b98ff2eaf8ba074e13dd4b579de5d574651f6
|
4
|
+
data.tar.gz: 3143241445d0755a2af8b6a3cd5f43f0f242d350
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e97e36e0249acb98d7aa31687f306d5b86e687d88ca242ac18d012392a820302188b5334987c3819ac1369c0bf553c46c95d0b2cb13d39cc4bb13530e78c3f75
|
7
|
+
data.tar.gz: 68c7833905d7e1461e793cb73658fbd4e113c2b3f8fd9a844ccf786828c8e7112e12700594249f0d3c1d184d55c3c8fa7d2ad62906c75760bbe0289fbe387faa
|
data/README.rdoc
CHANGED
@@ -23,23 +23,33 @@ Convert country names and codes to a standard.
|
|
23
23
|
|
24
24
|
# Or
|
25
25
|
NormalizeCountry.convert("U.S.", :to => :alpha2) # "US"
|
26
|
-
|
26
|
+
|
27
27
|
# Set the default
|
28
|
-
NormalizeCountry.to = :alpha3
|
28
|
+
NormalizeCountry.to = :alpha3
|
29
29
|
NormalizeCountry.convert("Mexico") # "MEX"
|
30
30
|
NormalizeCountry.convert("United Mexican States") # "MEX"
|
31
31
|
|
32
|
+
=== Installation
|
33
|
+
|
34
|
+
Rubygems ({part of Ruby}[https://www.ruby-lang.org]):
|
35
|
+
|
36
|
+
shell > gem install normalize_country
|
37
|
+
|
38
|
+
{Bundler}[http://bundler.io]:
|
39
|
+
|
40
|
+
gem "normalize_country"
|
41
|
+
|
32
42
|
=== Supported Conversions
|
33
43
|
|
34
|
-
In addition to trying to convert from common, non-standardized names and abbrivations, +NormalizeCountry+
|
44
|
+
In addition to trying to convert from common, non-standardized names and abbrivations, +NormalizeCountry+
|
35
45
|
will convert to/from the following:
|
36
46
|
|
37
47
|
[:alpha2] ISO 3166-1 alpha-2
|
38
48
|
[:alpha3] ISO 3166-1 alpha-3
|
39
49
|
[:fifa] FIFA (International Federation of Association Football)
|
40
50
|
[:official] The country's official name
|
41
|
-
[:ioc] International Olympic Committee
|
42
|
-
[:iso_name] Country name used by ISO 3166-1
|
51
|
+
[:ioc] International Olympic Committee
|
52
|
+
[:iso_name] Country name used by ISO 3166-1
|
43
53
|
[:numeric] ISO 3166-1 numeric code
|
44
54
|
[:short] A shortned version of the country's name, commonly used when speaking and/or writing (US English)
|
45
55
|
|
@@ -47,9 +57,9 @@ A list of valid formats can be obtained by calling +NormalizeCountry.formats+.
|
|
47
57
|
|
48
58
|
=== Obtaining an Array or Hash
|
49
59
|
|
50
|
-
NormalizeCountry.to_a
|
51
|
-
NormalizeCountry.to_a(:ioc)
|
52
|
-
NormalizeCountry.to_h(:ioc)
|
60
|
+
NormalizeCountry.to_a # Defaults to NormalizeCountry.to
|
61
|
+
NormalizeCountry.to_a(:ioc) # Array of IOC codes in ascending order
|
62
|
+
NormalizeCountry.to_h(:ioc) # :ioc => NormalizeCountry.to
|
53
63
|
NormalizeCountry.to_h(:ioc, :to => :numeric) # :ioc => :numeric
|
54
64
|
|
55
65
|
=== Conversion Utility
|
@@ -62,7 +72,7 @@ A small script is included that can convert country names contained in a DB tabl
|
|
62
72
|
-f, --format FORMAT The format of SOURCE
|
63
73
|
-t, --to CONVERSION Convert country names to this format (see docs for valid formats)
|
64
74
|
-l, --location LOCATION The location of the conversion
|
65
|
-
|
75
|
+
|
66
76
|
Some examples
|
67
77
|
|
68
78
|
normalize_country -t alpha2 -l 'Country Name' -f csv data.csv
|
@@ -74,13 +84,13 @@ If the format is +xml+ or +csv+ you can spefify a directory instead of a filenam
|
|
74
84
|
normalize_country -t alpha2 -l 'Country Name' -f csv /home/sshaw/capital-losses/2008
|
75
85
|
|
76
86
|
With a format of +csv+ it will read all files with an extension of +csv+ or +tsv+.
|
77
|
-
For +csv+ and +xml+ <b>the original file(s) will be overwritten with new file(s) containing the converted country names</b>.
|
87
|
+
For +csv+ and +xml+ <b>the original file(s) will be overwritten with new file(s) containing the converted country names</b>.
|
78
88
|
|
79
|
-
To convert an XML file with namespaces just include the namespace prefix defined in the file in the
|
89
|
+
To convert an XML file with namespaces just include the namespace prefix defined in the file in the
|
80
90
|
XPath query (+LOCATION+).
|
81
91
|
|
82
92
|
The +db+ format's +SOURCE+ argument must be a {Sequel connection string}[http://sequel.jeremyevans.net/rdoc/classes/Sequel.html#method-c-connect].
|
83
|
-
Here +LOCATION+ is in the format +table.column+, which will be updated with the converted name.
|
93
|
+
Here +LOCATION+ is in the format +table.column+, which will be updated with the converted name.
|
84
94
|
|
85
95
|
=== Random Country Data for Your Tests
|
86
96
|
|
@@ -97,7 +107,7 @@ This code was -to some extent- part of a larger project that allowed users to pe
|
|
97
107
|
Country names were stored in the DB by their ISO names.
|
98
108
|
|
99
109
|
Several years later at work we had to extract country names from a web service that didn't standardize
|
100
|
-
them. Sometimes they used UK, other times U.K. It then occured to me that this code could be useful outside
|
110
|
+
them. Sometimes they used UK, other times U.K. It then occured to me that this code could be useful outside
|
101
111
|
of the original project. The web service was fixed but, nevertheless...
|
102
112
|
|
103
113
|
=== Somewhat Similar Gems
|
data/lib/normalize_country.rb
CHANGED
@@ -146,10 +146,10 @@ AX:
|
|
146
146
|
alpha3: ALA
|
147
147
|
fifa:
|
148
148
|
ioc:
|
149
|
-
iso_name:
|
149
|
+
iso_name: Åland Islands
|
150
150
|
numeric: "248"
|
151
|
-
official:
|
152
|
-
short:
|
151
|
+
official: Åland Islands
|
152
|
+
short: Åland Islands
|
153
153
|
AZ:
|
154
154
|
alpha2: AZ
|
155
155
|
alpha3: AZE
|
@@ -251,9 +251,9 @@ BL:
|
|
251
251
|
alpha3: BLM
|
252
252
|
fifa:
|
253
253
|
ioc:
|
254
|
-
iso_name:
|
254
|
+
iso_name: Saint Barthélemy
|
255
255
|
numeric: "652"
|
256
|
-
official:
|
256
|
+
official: Territorial Collectivity of Saint Barthélemy
|
257
257
|
short: Saint Barths
|
258
258
|
BM:
|
259
259
|
aliases:
|
@@ -418,9 +418,9 @@ CI:
|
|
418
418
|
alpha3: CIV
|
419
419
|
fifa: CIV
|
420
420
|
ioc: CIV
|
421
|
-
iso_name:
|
421
|
+
iso_name: Côte D'Ivoire
|
422
422
|
numeric: "384"
|
423
|
-
official:
|
423
|
+
official: Republic of Côte D'Ivoire
|
424
424
|
short: Ivory Coast
|
425
425
|
CK:
|
426
426
|
alpha2: CK
|
@@ -1753,10 +1753,10 @@ RE:
|
|
1753
1753
|
alpha3: REU
|
1754
1754
|
fifa:
|
1755
1755
|
ioc:
|
1756
|
-
iso_name:
|
1756
|
+
iso_name: Réunion
|
1757
1757
|
numeric: "638"
|
1758
|
-
official:
|
1759
|
-
short:
|
1758
|
+
official: Réunion Island
|
1759
|
+
short: Réunion
|
1760
1760
|
RO:
|
1761
1761
|
alpha2: RO
|
1762
1762
|
alpha3: ROU
|
@@ -1945,15 +1945,15 @@ SS:
|
|
1945
1945
|
short: South Sudan
|
1946
1946
|
ST:
|
1947
1947
|
aliases:
|
1948
|
-
- Democratic Republic of Sao Tome and Principe
|
1949
|
-
-
|
1948
|
+
- Democratic Republic of Sao Tome and Principe
|
1949
|
+
- São Tomé and Príncipe
|
1950
1950
|
alpha2: ST
|
1951
1951
|
alpha3: STP
|
1952
1952
|
fifa: STP
|
1953
1953
|
ioc: STP
|
1954
1954
|
iso_name: Sao Tome and Principe
|
1955
1955
|
numeric: "678"
|
1956
|
-
official:
|
1956
|
+
official: Democratic Republic of São Tomé and Príncipe
|
1957
1957
|
short: Sao Tome and Principe
|
1958
1958
|
SV:
|
1959
1959
|
alpha2: SV
|
metadata
CHANGED
@@ -1,47 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: normalize_country
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Skye Shaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.9'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
description: |2
|
42
|
+
Converts country names and codes from standardized and non-standardized names and abbreviations to one of the following:
|
43
|
+
ISO 3166-1 (code/name/number), FIFA, IOC, a country's official name or shortened name.
|
44
|
+
|
45
|
+
Includes a small script to convert names/codes in a DB, XML or CSV file.
|
45
46
|
email: skye.shaw@gmail.com
|
46
47
|
executables:
|
47
48
|
- normalize_country
|
@@ -64,17 +65,17 @@ require_paths:
|
|
64
65
|
- lib
|
65
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
66
67
|
requirements:
|
67
|
-
- -
|
68
|
+
- - ">="
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: '0'
|
70
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
72
|
requirements:
|
72
|
-
- -
|
73
|
+
- - ">="
|
73
74
|
- !ruby/object:Gem::Version
|
74
75
|
version: '0'
|
75
76
|
requirements: []
|
76
77
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.1.11
|
78
79
|
signing_key:
|
79
80
|
specification_version: 4
|
80
81
|
summary: Convert country names and codes to a standard
|