countries 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/countries.gemspec +3 -2
- data/lib/countries.rb +45 -1
- data/lib/data/addresses.yaml +473 -0
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/countries.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{countries}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["hexorx"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-30}
|
13
13
|
s.description = %q{All sorts of useful information about every country. It includes data from ISO3166-1, ISO3166-2 and E.164}
|
14
14
|
s.email = %q{hexorx@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"VERSION",
|
26
26
|
"countries.gemspec",
|
27
27
|
"lib/countries.rb",
|
28
|
+
"lib/data/addresses.yaml",
|
28
29
|
"lib/data/countries.yaml",
|
29
30
|
"lib/data/import.rb",
|
30
31
|
"lib/data/iso3166-1.csv",
|
data/lib/countries.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
class Country
|
2
|
-
Data = File.open( 'lib/data/countries.yaml' ) {
|
2
|
+
Data = File.open( 'lib/data/countries.yaml' ) {|yaml| YAML::load( yaml )}
|
3
|
+
Names = Data.map {|code,data| data[:name]}
|
3
4
|
|
4
5
|
attr_reader :number, :alpha2, :alpha3, :name, :names, :latitude, :longitude, :region, :subregion, :country_code, :national_destination_code_lengths, :national_number_lengths, :international_prefix, :national_prefix
|
5
6
|
|
@@ -37,4 +38,47 @@ class Country
|
|
37
38
|
def subdivisions?
|
38
39
|
File.exist?("lib/data/subdivisions/#{alpha2}.yaml")
|
39
40
|
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# CountrySelect - stolen from http://github.com/rails/iso-3166-country-select
|
44
|
+
module ActionView
|
45
|
+
module Helpers
|
46
|
+
module FormOptionsHelper
|
47
|
+
|
48
|
+
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
|
49
|
+
InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def country_options_for_select(selected = nil, priority_countries = nil)
|
53
|
+
country_options = ""
|
54
|
+
|
55
|
+
if priority_countries
|
56
|
+
country_options += options_for_select(priority_countries, selected)
|
57
|
+
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
|
58
|
+
end
|
59
|
+
|
60
|
+
return country_options + options_for_select(Country::Names, selected)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class InstanceTag
|
65
|
+
def to_country_select_tag(priority_countries, options, html_options)
|
66
|
+
html_options = html_options.stringify_keys
|
67
|
+
add_default_name_and_id(html_options)
|
68
|
+
value = value(object)
|
69
|
+
content_tag("select",
|
70
|
+
add_options(
|
71
|
+
country_options_for_select(value, priority_countries),
|
72
|
+
options, value
|
73
|
+
), html_options
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class FormBuilder
|
79
|
+
def country_select(method, priority_countries = nil, options = {}, html_options = {})
|
80
|
+
@template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
40
84
|
end
|
@@ -0,0 +1,473 @@
|
|
1
|
+
# Avaible placeholders:
|
2
|
+
# * recipient
|
3
|
+
# * street
|
4
|
+
# * zip
|
5
|
+
# * city
|
6
|
+
# * state
|
7
|
+
# * country
|
8
|
+
#
|
9
|
+
---
|
10
|
+
ae:
|
11
|
+
name: United Arab Emirates
|
12
|
+
format: |-
|
13
|
+
{{recipient}}
|
14
|
+
{{street}}
|
15
|
+
{{zip}} {{city}}
|
16
|
+
{{country}}
|
17
|
+
ar:
|
18
|
+
name: Argentina
|
19
|
+
format: |-
|
20
|
+
{{recipient}}
|
21
|
+
{{street}}
|
22
|
+
{{zip}} {{city}}
|
23
|
+
{{state}}
|
24
|
+
{{country}}
|
25
|
+
at:
|
26
|
+
name: Austria
|
27
|
+
format: |-
|
28
|
+
{{recipient}}
|
29
|
+
{{street}}
|
30
|
+
{{zip}} {{city}}
|
31
|
+
{{country}}
|
32
|
+
au:
|
33
|
+
name: Australia
|
34
|
+
format: |-
|
35
|
+
{{recipient}}
|
36
|
+
{{street}}
|
37
|
+
{{city}} {{state}} {{zip}}
|
38
|
+
{{country}}
|
39
|
+
ba:
|
40
|
+
name: Bosnia and Herzegovina
|
41
|
+
format: |-
|
42
|
+
{{recipient}}
|
43
|
+
{{street}}
|
44
|
+
{{zip}} {{city}}
|
45
|
+
{{country}}
|
46
|
+
be:
|
47
|
+
name: Belgium
|
48
|
+
format: |-
|
49
|
+
{{recipient}}
|
50
|
+
{{street}}
|
51
|
+
{{zip}} {{city}}
|
52
|
+
{{country}}
|
53
|
+
bg:
|
54
|
+
name: Bulgaria
|
55
|
+
format: |-
|
56
|
+
{{recipient}}
|
57
|
+
{{street}}
|
58
|
+
{{zip}} {{city}}
|
59
|
+
{{country}}
|
60
|
+
bh:
|
61
|
+
name: Bahrain
|
62
|
+
format: |-
|
63
|
+
{{recipient}}
|
64
|
+
{{street}}
|
65
|
+
{{zip}} {{city}}
|
66
|
+
{{country}}
|
67
|
+
br:
|
68
|
+
name: Brazil
|
69
|
+
format: |-
|
70
|
+
{{recipient}}
|
71
|
+
{{street}}
|
72
|
+
{{zip}} {{city}} {{state}}
|
73
|
+
{{country}}
|
74
|
+
ca:
|
75
|
+
name: Canada
|
76
|
+
format: |-
|
77
|
+
{{recipient}}
|
78
|
+
{{street}}
|
79
|
+
{{city}} {{state}} {{zip}}
|
80
|
+
{{country}}
|
81
|
+
ch:
|
82
|
+
name: Switzerland
|
83
|
+
format: |-
|
84
|
+
{{recipient}}
|
85
|
+
{{street}}
|
86
|
+
{{zip}} {{city}}
|
87
|
+
{{country}}
|
88
|
+
cn:
|
89
|
+
name: China
|
90
|
+
format: |-
|
91
|
+
{{recipient}}
|
92
|
+
{{street}}
|
93
|
+
{{zip}} {{city}} {{state}}
|
94
|
+
{{country}}
|
95
|
+
cz:
|
96
|
+
name: Czech
|
97
|
+
format: |-
|
98
|
+
{{recipient}}
|
99
|
+
{{street}}
|
100
|
+
{{zip}} {{city}}
|
101
|
+
{{country}}
|
102
|
+
de:
|
103
|
+
name: Germany
|
104
|
+
format: |-
|
105
|
+
{{recipient}}
|
106
|
+
{{street}}
|
107
|
+
{{zip}} {{city}}
|
108
|
+
{{country}}
|
109
|
+
dk:
|
110
|
+
name: Denmark
|
111
|
+
format: |-
|
112
|
+
{{recipient}}
|
113
|
+
{{street}}
|
114
|
+
{{zip}} {{city}}
|
115
|
+
{{state}}
|
116
|
+
{{country}}
|
117
|
+
eg:
|
118
|
+
name: Egypt
|
119
|
+
format: |-
|
120
|
+
{{recipient}}
|
121
|
+
{{street}}
|
122
|
+
{{zip}} {{city}}
|
123
|
+
{{country}}
|
124
|
+
es:
|
125
|
+
name: Spain
|
126
|
+
format: |-
|
127
|
+
{{recipient}}
|
128
|
+
{{street}}
|
129
|
+
{{zip}} {{city}} {{state}}
|
130
|
+
{{country}}
|
131
|
+
fi:
|
132
|
+
name: Finland
|
133
|
+
format: |-
|
134
|
+
{{recipient}}
|
135
|
+
{{street}}
|
136
|
+
{{zip}} {{city}}
|
137
|
+
{{country}}
|
138
|
+
fr:
|
139
|
+
name: France
|
140
|
+
format: |-
|
141
|
+
{{recipient}}
|
142
|
+
{{street}}
|
143
|
+
{{zip}} {{city}}
|
144
|
+
{{country}}
|
145
|
+
gb:
|
146
|
+
name: United Kingdom
|
147
|
+
format: |-
|
148
|
+
{{recipient}}
|
149
|
+
{{street}}
|
150
|
+
{{city}}
|
151
|
+
{{state}}
|
152
|
+
{{zip}}
|
153
|
+
{{country}}
|
154
|
+
gl:
|
155
|
+
name: Greenland
|
156
|
+
format: |-
|
157
|
+
{{recipient}}
|
158
|
+
{{street}}
|
159
|
+
{{zip}} {{city}}
|
160
|
+
{{country}}
|
161
|
+
gr:
|
162
|
+
name: Greece
|
163
|
+
format: |-
|
164
|
+
{{recipient}}
|
165
|
+
{{street}}
|
166
|
+
{{zip}} {{city}}
|
167
|
+
{{country}}
|
168
|
+
hk:
|
169
|
+
name: Hong Kong
|
170
|
+
format: |-
|
171
|
+
{{recipient}}
|
172
|
+
{{street}}
|
173
|
+
{{zip}} {{city}} {{state}}
|
174
|
+
{{country}}
|
175
|
+
hr:
|
176
|
+
name: Croatia
|
177
|
+
format: |-
|
178
|
+
{{recipient}}
|
179
|
+
{{street}}
|
180
|
+
{{zip}} {{city}}
|
181
|
+
{{country}}
|
182
|
+
hu:
|
183
|
+
name: Hungary
|
184
|
+
format: |-
|
185
|
+
{{recipient}}
|
186
|
+
{{city}}
|
187
|
+
{{street}}
|
188
|
+
{{zip}}
|
189
|
+
{{country}}
|
190
|
+
id:
|
191
|
+
name: Indonesia
|
192
|
+
format: |-
|
193
|
+
{{recipient}}
|
194
|
+
{{street}}
|
195
|
+
{{city}}
|
196
|
+
{{state}} {{zip}}
|
197
|
+
{{country}}
|
198
|
+
ie:
|
199
|
+
name: Ireland
|
200
|
+
format: |-
|
201
|
+
{{recipient}}
|
202
|
+
{{street}}
|
203
|
+
{{city}} {{state}} {{zip}}
|
204
|
+
{{country}}
|
205
|
+
il:
|
206
|
+
name: Israel
|
207
|
+
format: |-
|
208
|
+
{{recipient}}
|
209
|
+
{{street}}
|
210
|
+
{{zip}} {{city}}
|
211
|
+
{{country}}
|
212
|
+
in:
|
213
|
+
name: India
|
214
|
+
format: |-
|
215
|
+
{{recipient}}
|
216
|
+
{{street}}
|
217
|
+
{{state}}
|
218
|
+
{{city}} {{zip}}
|
219
|
+
{{country}}
|
220
|
+
is:
|
221
|
+
name: Iceland
|
222
|
+
format: |-
|
223
|
+
{{recipient}}
|
224
|
+
{{street}}
|
225
|
+
{{zip}} {{city}}
|
226
|
+
{{country}}
|
227
|
+
it:
|
228
|
+
name: Italy
|
229
|
+
format: |-
|
230
|
+
{{recipient}}
|
231
|
+
{{street}}
|
232
|
+
{{zip}} {{city}} {{state}}
|
233
|
+
{{country}}
|
234
|
+
jo:
|
235
|
+
name: Jordan
|
236
|
+
format: |-
|
237
|
+
{{recipient}}
|
238
|
+
{{street}}
|
239
|
+
{{zip}} {{city}}
|
240
|
+
{{country}}
|
241
|
+
# Here is a sample of Japanese formatted addresses (Apple Japan HQ).
|
242
|
+
# Usually they have "Postal mark" before zip (postal) code,
|
243
|
+
# and parts of an address are not separated with space.
|
244
|
+
# Biggs::Formatter.new(:blank_country_on => "jp").format(
|
245
|
+
# "jp",
|
246
|
+
# :recipient => "アップルジャパン株式会社 本社",
|
247
|
+
# :street => "西新宿3-20-2",
|
248
|
+
# :city => "新宿区",
|
249
|
+
# :state => "東京都",
|
250
|
+
# :zip => "163-1480")
|
251
|
+
# 〒163-1480
|
252
|
+
# 東京都新宿区西新宿3-20-2
|
253
|
+
# アップルジャパン株式会社 本社
|
254
|
+
jp:
|
255
|
+
name: Japan
|
256
|
+
format: |-
|
257
|
+
〒{{zip}}
|
258
|
+
{{state}}{{city}}{{street}}
|
259
|
+
{{recipient}}
|
260
|
+
{{country}}
|
261
|
+
kr:
|
262
|
+
name: South Korea
|
263
|
+
format: |-
|
264
|
+
{{recipient}}
|
265
|
+
{{street}}
|
266
|
+
{{city}} {{state}}
|
267
|
+
{{zip}}
|
268
|
+
{{country}}
|
269
|
+
kw:
|
270
|
+
name: Kuwait
|
271
|
+
format: |-
|
272
|
+
{{recipient}}
|
273
|
+
{{street}}
|
274
|
+
{{zip}} {{city}}
|
275
|
+
{{state}}
|
276
|
+
{{country}}
|
277
|
+
lb:
|
278
|
+
name: Lebanon
|
279
|
+
format: |-
|
280
|
+
{{recipient}}
|
281
|
+
{{street}}
|
282
|
+
{{zip}} {{city}}
|
283
|
+
{{country}}
|
284
|
+
lu:
|
285
|
+
name: Luxembourg
|
286
|
+
format: |-
|
287
|
+
{{recipient}}
|
288
|
+
{{street}}
|
289
|
+
{{zip}} {{city}}
|
290
|
+
{{country}}
|
291
|
+
mk:
|
292
|
+
name: Macedonia
|
293
|
+
format: |-
|
294
|
+
{{recipient}}
|
295
|
+
{{street}}
|
296
|
+
{{city}} {{zip}}
|
297
|
+
{{country}}
|
298
|
+
mx:
|
299
|
+
name: Mexico
|
300
|
+
format: |-
|
301
|
+
{{recipient}}
|
302
|
+
{{street}}
|
303
|
+
{{zip}} {{city}} {{state}}
|
304
|
+
{{country}}
|
305
|
+
nl:
|
306
|
+
name: Netherlands
|
307
|
+
format: |-
|
308
|
+
{{recipient}}
|
309
|
+
{{street}}
|
310
|
+
{{zip}} {{city}}
|
311
|
+
{{country}}
|
312
|
+
no:
|
313
|
+
name: Norway
|
314
|
+
format: |-
|
315
|
+
{{recipient}}
|
316
|
+
{{street}}
|
317
|
+
{{zip}} {{city}}
|
318
|
+
{{country}}
|
319
|
+
nz:
|
320
|
+
name: New Zealand
|
321
|
+
format: |-
|
322
|
+
{{recipient}}
|
323
|
+
{{street}}
|
324
|
+
{{state}}
|
325
|
+
{{city}} {{zip}}
|
326
|
+
{{country}}
|
327
|
+
om:
|
328
|
+
name: Oman
|
329
|
+
format: |-
|
330
|
+
{{recipient}}
|
331
|
+
{{street}}
|
332
|
+
{{zip}} {{city}}
|
333
|
+
{{state}}
|
334
|
+
{{country}}
|
335
|
+
ph:
|
336
|
+
name: Philippines
|
337
|
+
format: |-
|
338
|
+
{{recipient}}
|
339
|
+
{{street}} {{state}}
|
340
|
+
{{zip}} {{city}}
|
341
|
+
{{country}}
|
342
|
+
pl:
|
343
|
+
name: Poland
|
344
|
+
format: |-
|
345
|
+
{{recipient}}
|
346
|
+
{{street}}
|
347
|
+
{{zip}} {{city}}
|
348
|
+
{{state}}
|
349
|
+
{{country}}
|
350
|
+
pt:
|
351
|
+
name: Portugal
|
352
|
+
format: |-
|
353
|
+
{{recipient}}
|
354
|
+
{{street}}
|
355
|
+
{{zip}} {{city}} {{state}}
|
356
|
+
{{country}}
|
357
|
+
qa:
|
358
|
+
name: Qatar
|
359
|
+
format: |-
|
360
|
+
{{recipient}}
|
361
|
+
{{street}}
|
362
|
+
{{zip}} {{city}}
|
363
|
+
{{country}}
|
364
|
+
ro:
|
365
|
+
name: Romania
|
366
|
+
format: |-
|
367
|
+
{{recipient}}
|
368
|
+
{{street}}
|
369
|
+
{{zip}} {{city}}
|
370
|
+
{{country}}
|
371
|
+
ru:
|
372
|
+
name: Russian Federation
|
373
|
+
format: |-
|
374
|
+
{{recipient}}
|
375
|
+
{{zip}} {{city}}
|
376
|
+
{{street}}
|
377
|
+
{{country}}
|
378
|
+
sa:
|
379
|
+
name: Saudi Arabia
|
380
|
+
format: |-
|
381
|
+
{{recipient}}
|
382
|
+
{{street}}
|
383
|
+
{{zip}} {{city}}
|
384
|
+
{{country}}
|
385
|
+
se:
|
386
|
+
name: Sweden
|
387
|
+
format: |-
|
388
|
+
{{recipient}}
|
389
|
+
{{street}}
|
390
|
+
{{zip}} {{city}}
|
391
|
+
{{country}}
|
392
|
+
sg:
|
393
|
+
name: Singapore
|
394
|
+
format: |-
|
395
|
+
{{recipient}}
|
396
|
+
{{street}}
|
397
|
+
{{city}} {{zip}}
|
398
|
+
{{country}}
|
399
|
+
si:
|
400
|
+
name: Slovenia
|
401
|
+
format: |-
|
402
|
+
{{recipient}}
|
403
|
+
{{street}}
|
404
|
+
{{zip}} {{city}}
|
405
|
+
{{country}}
|
406
|
+
sk:
|
407
|
+
name: Slovakia
|
408
|
+
format: |-
|
409
|
+
{{recipient}}
|
410
|
+
{{street}}
|
411
|
+
{{zip}} {{city}}
|
412
|
+
{{country}}
|
413
|
+
sy:
|
414
|
+
name: Syrian Arab Republic
|
415
|
+
format: |-
|
416
|
+
{{recipient}}
|
417
|
+
{{street}}
|
418
|
+
{{zip}} {{city}}
|
419
|
+
{{country}}
|
420
|
+
tr:
|
421
|
+
name: Turkey
|
422
|
+
format: |-
|
423
|
+
{{recipient}}
|
424
|
+
{{street}}
|
425
|
+
{{zip}} {{city}}
|
426
|
+
{{country}}
|
427
|
+
tw:
|
428
|
+
name: Taiwan
|
429
|
+
format: |-
|
430
|
+
{{recipient}}
|
431
|
+
{{street}}
|
432
|
+
{{city}} {{state}} {{zip}}
|
433
|
+
{{country}}
|
434
|
+
ua:
|
435
|
+
name: Ukraine
|
436
|
+
format: |-
|
437
|
+
{{recipient}}
|
438
|
+
{{street}}
|
439
|
+
{{city}} {{state}}
|
440
|
+
{{zip}}
|
441
|
+
{{country}}
|
442
|
+
us:
|
443
|
+
name: United States
|
444
|
+
format: |-
|
445
|
+
{{recipient}}
|
446
|
+
{{street}}
|
447
|
+
{{city}} {{state}} {{zip}}
|
448
|
+
{{country}}
|
449
|
+
ye:
|
450
|
+
name: Yemen
|
451
|
+
format: |-
|
452
|
+
{{recipient}}
|
453
|
+
{{street}}
|
454
|
+
{{zip}} {{city}}
|
455
|
+
{{country}}
|
456
|
+
yu:
|
457
|
+
name: Serbia and Montenegro
|
458
|
+
format: |-
|
459
|
+
{{recipient}}
|
460
|
+
{{street}}
|
461
|
+
{{zip}} {{city}}
|
462
|
+
|
463
|
+
{{state}}
|
464
|
+
{{country}}
|
465
|
+
za:
|
466
|
+
name: South Africa
|
467
|
+
format: |-
|
468
|
+
{{recipient}}
|
469
|
+
{{street}}
|
470
|
+
{{city}}
|
471
|
+
{{state}}
|
472
|
+
{{zip}}
|
473
|
+
{{country}}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: countries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hexorx
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-30 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- VERSION
|
51
51
|
- countries.gemspec
|
52
52
|
- lib/countries.rb
|
53
|
+
- lib/data/addresses.yaml
|
53
54
|
- lib/data/countries.yaml
|
54
55
|
- lib/data/import.rb
|
55
56
|
- lib/data/iso3166-1.csv
|