iso_country_codes 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.rdoc +14 -0
- data/VERSION +1 -1
- data/lib/iso_country_codes/iso_3166_1.rb +1 -1
- data/overrides.yml +3 -0
- data/rakelib/iso_3166_1.rb +21 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3407315feef40a75fcfc9513b41b094aedbe17b
|
4
|
+
data.tar.gz: 0b53033413873611069018b59cc3fcb36f72cd20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b39f3664b3ca8aad85dae6bb60838139fe5b6fb20ea483f7e5f86e704c652a1a352b244889a3b523a8513b4fa6a90de7ae01f9a7da77f06f1078e1c3be19aefe
|
7
|
+
data.tar.gz: 43fae37741f6c235335cc4cb4b7ca9c4f96c5de5acef5ac753f7283fa54162f2412bcd85af8dff9d3cc46d0cd69150b77fc6bc0f943a1157927a498da62f35ca
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -43,6 +43,20 @@ Provides ISO codes, names and currencies for countries.
|
|
43
43
|
|
44
44
|
gem install iso_country_codes
|
45
45
|
|
46
|
+
== DATA SOURCE:
|
47
|
+
|
48
|
+
IsoCountryCodes pulls its data from the Wikipedia ISO 3166-1 tables
|
49
|
+
(https://en.wikipedia.org/wiki/ISO_3166-1), combined with a small number of
|
50
|
+
overrides contained in the `overrides.yml` file. For example, the country name
|
51
|
+
of TWN is overridden to "Taiwan" from "Taiwan, Province of China", to make it
|
52
|
+
less politicised.
|
53
|
+
|
54
|
+
The format of the `overrides.yml` file is the 3-letter alpha country
|
55
|
+
code as the key, and the fields one wants to override as follows:
|
56
|
+
|
57
|
+
"TWN":
|
58
|
+
:name: "Taiwan"
|
59
|
+
|
46
60
|
== LICENSE:
|
47
61
|
|
48
62
|
(The MIT License)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.8
|
data/overrides.yml
ADDED
data/rakelib/iso_3166_1.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'open-uri'
|
3
3
|
require 'erubis'
|
4
|
+
require 'yaml'
|
4
5
|
|
5
6
|
class IsoCountryCodes
|
6
7
|
module Task
|
@@ -30,6 +31,14 @@ class IsoCountryCodes
|
|
30
31
|
|
31
32
|
next if value == ''
|
32
33
|
|
34
|
+
# This is a terrible hack to skip the first table of the
|
35
|
+
# Wikipedia page, under "Naming and disputes". The
|
36
|
+
# giveaway is that this table doesn't include a "Numeric
|
37
|
+
# code" field.
|
38
|
+
if key == :numeric
|
39
|
+
next unless value.to_i > 0
|
40
|
+
end
|
41
|
+
|
33
42
|
value_hash[key] = value
|
34
43
|
|
35
44
|
if value_hash.length == code_labels.length - 1
|
@@ -40,6 +49,8 @@ class IsoCountryCodes
|
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
52
|
+
codes = recurse_merge(codes, self.exceptions)
|
53
|
+
|
43
54
|
to_ruby(codes) if codes
|
44
55
|
end
|
45
56
|
|
@@ -48,6 +59,16 @@ class IsoCountryCodes
|
|
48
59
|
eruby = Erubis::Eruby.new(tmpl)
|
49
60
|
eruby.result(:codes => codes)
|
50
61
|
end
|
62
|
+
|
63
|
+
def self.exceptions
|
64
|
+
@config ||= YAML.load_file('overrides.yml')
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.recurse_merge(a,b)
|
68
|
+
a.merge(b) do |_,x,y|
|
69
|
+
(x.is_a?(Hash) && y.is_a?(Hash)) ? recurse_merge(x,y) : y
|
70
|
+
end
|
71
|
+
end
|
51
72
|
end # UpdateCodes
|
52
73
|
end # Task
|
53
74
|
end # IsoCountryCodes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso_country_codes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rabarts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/iso_country_codes/iso_3166_1.rb
|
92
92
|
- lib/iso_country_codes/iso_4217.rb
|
93
93
|
- lib/iso_country_codes/iso_country_codes.rb
|
94
|
+
- overrides.yml
|
94
95
|
- rakelib/cultivate.rake
|
95
96
|
- rakelib/iso_3166_1.rake
|
96
97
|
- rakelib/iso_3166_1.rb
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
120
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.6.11
|
121
122
|
signing_key:
|
122
123
|
specification_version: 4
|
123
124
|
summary: Provides ISO 3166-1 country codes/names and ISO 4217 currencies.
|