country_tools 0.2 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +11 -4
- data/lib/country_tools.rb +37 -2
- data/names.yml +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb68538b70a76984bdc49f9a9bfb2bab77daee1e
|
4
|
+
data.tar.gz: b5d03f82c7682bd3d98d40668d1bd1f7c011ac81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67e4df0096959c23852674a4bd6db36457a116105477c87d8edc43de361b875ad5f6d3a9ef252c3bc541917f0d123a6121fc269db311d99401e1de31d5f70df5
|
7
|
+
data.tar.gz: 5d51eb9492cc9e110ee35cdcb27afc44ba3708d6fad4a792cea98353cd2ac7b6a514b0fb72f54b749973c65a5465d0dc3b5b07e98f1ddfb354a2c51ea9dda077
|
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== Installation
|
4
4
|
|
5
|
-
gem 'country_tools'
|
5
|
+
gem 'country_tools'
|
6
6
|
|
7
7
|
== Supported languages
|
8
8
|
|
@@ -22,12 +22,19 @@ Get the name of a country by code [i18n aware] :
|
|
22
22
|
|
23
23
|
CountryTools.name('BE') #=> 'Belgium'
|
24
24
|
|
25
|
-
Ask if a country is in
|
25
|
+
Ask if a country is in European Union :
|
26
26
|
|
27
|
-
CountryTools.
|
27
|
+
CountryTools.in_eu?('BE') #=> true
|
28
28
|
|
29
29
|
Get options for a select (inside form_for) :
|
30
30
|
|
31
31
|
<%= f.select :country_code, CountryTools.options_for_select %>
|
32
32
|
|
33
|
-
|
33
|
+
== Contributors
|
34
|
+
|
35
|
+
* Aurélien Malisart — https://phonoid.com
|
36
|
+
* Michaël Hoste — https://80limit.com
|
37
|
+
|
38
|
+
== License
|
39
|
+
|
40
|
+
Copyright (c) 2011-2019 Aurélien Malisart, released under the MIT license.
|
data/lib/country_tools.rb
CHANGED
@@ -4,10 +4,45 @@ module CountryTools
|
|
4
4
|
@@all_countries ||= YAML.load(File.read(path))
|
5
5
|
end
|
6
6
|
|
7
|
-
|
7
|
+
# https://en.wikipedia.org/wiki/European_Union
|
8
|
+
EU_CODES = [
|
9
|
+
'AT', # Austria
|
10
|
+
'BE', # Belgium
|
11
|
+
'BG', # Bulgaria
|
12
|
+
'HR', # Croatia
|
13
|
+
'CY', # Cyprus
|
14
|
+
'CZ', # Czech Republic
|
15
|
+
'DK', # Denmark
|
16
|
+
'EE', # Estonia
|
17
|
+
'FI', # Finland
|
18
|
+
'FR', # France
|
19
|
+
'DE', # Germany
|
20
|
+
'GR', 'EL', # Greece (https://fr.wikipedia.org/wiki/Union_europ%C3%A9enne#cite_ref-79)
|
21
|
+
'HU', # Hungary
|
22
|
+
'IE', # Ireland
|
23
|
+
'IT', # Italy
|
24
|
+
'LV', # Latvia
|
25
|
+
'LT', # Lithuania
|
26
|
+
'LU', # Luxembourg
|
27
|
+
'MT', # Malta
|
28
|
+
'NL', # Netherlands
|
29
|
+
'PL', # Poland
|
30
|
+
'PT', # Portugal
|
31
|
+
'RO', # Romania
|
32
|
+
'SK', # Slovakia
|
33
|
+
'SI', # Slovenia
|
34
|
+
'ES', # Spain
|
35
|
+
'SE', # Sweden
|
36
|
+
'GB', 'UK', # United Kingdom (https://fr.wikipedia.org/wiki/Union_europ%C3%A9enne#cite_ref-81)
|
37
|
+
]
|
38
|
+
|
39
|
+
def self.in_eu?(code)
|
40
|
+
EU_CODES.include?(code)
|
41
|
+
end
|
8
42
|
|
9
43
|
def self.in_cee?(code)
|
10
|
-
|
44
|
+
warn "[DEPRECATION] `in_cee?` is deprecated. Please use `in_eu?` instead."
|
45
|
+
in_eu?(code)
|
11
46
|
end
|
12
47
|
|
13
48
|
def self.options_for_select
|
data/names.yml
CHANGED
@@ -270,6 +270,10 @@ GR:
|
|
270
270
|
fr: Grèce
|
271
271
|
en: Greece
|
272
272
|
es: Grecia
|
273
|
+
EL: # https://www.quora.com/Why-is-Greeces-country-code-EL-in-the-European-Union-but-GR-everywhere-else
|
274
|
+
fr: Grèce
|
275
|
+
en: Greece
|
276
|
+
es: Grecia
|
273
277
|
GD:
|
274
278
|
fr: Grenade
|
275
279
|
en: Grenada
|
@@ -754,6 +758,10 @@ GB:
|
|
754
758
|
fr: Royaume-Uni
|
755
759
|
en: United Kingdom
|
756
760
|
es: Reino Unido
|
761
|
+
UK: # Though GB is the United Kingdom's ISO 3166-1 alpha-2 code, UK is exceptionally reserved for the United Kingdom on the request of the country. (https://en.wikipedia.org/wiki/ISO_3166-2:GB)
|
762
|
+
fr: Royaume-Uni
|
763
|
+
en: United Kingdom
|
764
|
+
es: Reino Unido
|
757
765
|
US:
|
758
766
|
fr: États-Unis
|
759
767
|
en: United States
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: country_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurélien Malisart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Country tools for Rails
|
14
|
-
email: aurelien
|
14
|
+
email: aurelien@phonoid.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files:
|