country-select-iso 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/data/countries.txt +303 -0
- data/data/states.txt +3836 -0
- data/lib/countries-list.rb +72 -0
- metadata +5 -2
@@ -0,0 +1,72 @@
|
|
1
|
+
module CountrySelectIso
|
2
|
+
def self.load_countries_from file_name
|
3
|
+
File.read(file_name).split("\n")
|
4
|
+
.select{|l| l =~ /^\#/ ? false : true}
|
5
|
+
.map{|l| l.split("\t")}
|
6
|
+
.map {|p|
|
7
|
+
# # Field Example
|
8
|
+
# ---------------------------------------------
|
9
|
+
# 0 ISO US
|
10
|
+
# 1 ISO3 USA
|
11
|
+
# 2 ISO-Numeric 840
|
12
|
+
# 3 fips US
|
13
|
+
# 4 Country United States
|
14
|
+
# 5 Capital Washington
|
15
|
+
# 6 Area(in sq km) 9629091
|
16
|
+
# 7 Population 310232863
|
17
|
+
# 8 Continent NA
|
18
|
+
# 9 tld .us
|
19
|
+
# 10 CurrencyCode USD
|
20
|
+
# 11 CurrencyName Dollar
|
21
|
+
# 12 Phone 1
|
22
|
+
# 13 Postal Code Format #####-####
|
23
|
+
# 14 Postal Code Regex ^\d{5}(-\d{4})?$
|
24
|
+
# 15 Languages en-US,es-US,haw,fr
|
25
|
+
# 16 geonameid 6252001
|
26
|
+
# 17 neighbours CA,MX,CU
|
27
|
+
# 18 EquivalentFipsCode
|
28
|
+
{
|
29
|
+
iso2: p[0],
|
30
|
+
iso3: p[1],
|
31
|
+
iso_num: p[2],
|
32
|
+
name: p[4],
|
33
|
+
capital: p[5],
|
34
|
+
continent: p[8],
|
35
|
+
top_level_domain: p[9],
|
36
|
+
currency_code: p[10],
|
37
|
+
currency_name: p[11],
|
38
|
+
phone_code: p[12],
|
39
|
+
postal_code_format: p[13],
|
40
|
+
postal_code_epxr: Regexp.new(p[14]),
|
41
|
+
languages: (p[15] || '').split(','),
|
42
|
+
neighbours_iso2: (p[17] || '').split(',')
|
43
|
+
}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.load_states_from file_name
|
48
|
+
File.read(file_name).split("\n")
|
49
|
+
.select{|l| l =~ /^\#/ ? false : true}
|
50
|
+
.map{|l| l.split("\t")}
|
51
|
+
.map {|p|
|
52
|
+
# AD.06 Parròquia de Sant Julià de Lòria Parroquia de Sant Julia de Loria 3039162
|
53
|
+
code_parts = p[0].split('.')
|
54
|
+
{
|
55
|
+
country_iso2: code_parts[0],
|
56
|
+
state_code: code_parts[1],
|
57
|
+
full_code: p[0],
|
58
|
+
localized_name: p[1],
|
59
|
+
name: p[2],
|
60
|
+
something_unknown: p[3]
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.countries
|
66
|
+
@@countries ||= load_countries_from(File.join(File.dirname(__FILE__), "../data/countries.txt"))
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.states
|
70
|
+
@@states ||= load_states_from(File.join(File.dirname(__FILE__), '../data/states.txt'))
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: country-select-iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-01-
|
14
|
+
date: 2012-01-07 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: Provides country & state utilities with country & state selection boxes
|
17
17
|
email: shapigor@gmail.com
|
@@ -20,6 +20,9 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- lib/country-select-iso.rb
|
23
|
+
- lib/countries-list.rb
|
24
|
+
- data/countries.txt
|
25
|
+
- data/states.txt
|
23
26
|
homepage: https://github.com/igorshapiro/country-select
|
24
27
|
licenses: []
|
25
28
|
post_install_message:
|