iso 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -3
- data/VERSION +1 -1
- data/data/un-m49.yml +502 -0
- data/iso.gemspec +5 -2
- data/lib/iso.rb +1 -0
- data/lib/iso/region.rb +2 -1
- data/lib/iso/subtag.rb +2 -1
- data/lib/iso/tag.rb +1 -1
- data/lib/iso/un/region.rb +23 -0
- data/locales/en.yml +36 -0
- data/spec/lib/iso/subtag_spec.rb +16 -0
- data/spec/lib/iso/tag_spec.rb +17 -0
- data/spec/lib/iso/un/region_spec.rb +38 -0
- metadata +20 -17
data/README.md
CHANGED
@@ -26,7 +26,16 @@ Regions are defined by **ISO 3166-1**; that is the 2 letter uppercase region cod
|
|
26
26
|
|
27
27
|
=> #<ISO::Region:0x007fe2ba070e50
|
28
28
|
@code="MX",
|
29
|
-
@name="Mexico">
|
29
|
+
@name="Mexico">
|
30
|
+
|
31
|
+
Regions can also be defined by the **UN M49** standard; that is the 3 digit region code.
|
32
|
+
|
33
|
+
> ISO::UN::Region.find('419')
|
34
|
+
|
35
|
+
=> #<ISO::Region:0x007fe2ba43db50
|
36
|
+
@code="419",
|
37
|
+
@name="Latin America and the Caribbean">
|
38
|
+
|
30
39
|
|
31
40
|
## Tags
|
32
41
|
|
@@ -46,8 +55,8 @@ The combination of a language and a region is called a Tag :
|
|
46
55
|
|
47
56
|
You can check if a Tag is valid like so :
|
48
57
|
|
49
|
-
|
50
|
-
|
58
|
+
> ISO::Tag.new('pt-BR').valid? => true
|
59
|
+
> ISO::Tag.new('lolcat').valid? => false
|
51
60
|
|
52
61
|
## I18n
|
53
62
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/data/un-m49.yml
ADDED
@@ -0,0 +1,502 @@
|
|
1
|
+
'002':
|
2
|
+
'004':
|
3
|
+
iso_code: AF
|
4
|
+
'005':
|
5
|
+
'008':
|
6
|
+
iso_code: AL
|
7
|
+
'009':
|
8
|
+
'011':
|
9
|
+
'012':
|
10
|
+
iso_code: DZ
|
11
|
+
'013':
|
12
|
+
'014':
|
13
|
+
'015':
|
14
|
+
'016':
|
15
|
+
iso_code: AS
|
16
|
+
'017':
|
17
|
+
'018':
|
18
|
+
'019':
|
19
|
+
'020':
|
20
|
+
iso_code: AD
|
21
|
+
'021':
|
22
|
+
'024':
|
23
|
+
iso_code: AO
|
24
|
+
'028':
|
25
|
+
iso_code: AG
|
26
|
+
'029':
|
27
|
+
'030':
|
28
|
+
'031':
|
29
|
+
iso_code: AZ
|
30
|
+
'032':
|
31
|
+
iso_code: AR
|
32
|
+
'034':
|
33
|
+
'035':
|
34
|
+
'036':
|
35
|
+
iso_code: AU
|
36
|
+
'039':
|
37
|
+
'040':
|
38
|
+
iso_code: AT
|
39
|
+
'044':
|
40
|
+
iso_code: BS
|
41
|
+
'048':
|
42
|
+
iso_code: BH
|
43
|
+
'050':
|
44
|
+
iso_code: BD
|
45
|
+
'051':
|
46
|
+
iso_code: AM
|
47
|
+
'052':
|
48
|
+
iso_code: BB
|
49
|
+
'053':
|
50
|
+
'054':
|
51
|
+
'056':
|
52
|
+
iso_code: BE
|
53
|
+
'057':
|
54
|
+
'060':
|
55
|
+
iso_code: BM
|
56
|
+
'061':
|
57
|
+
'064':
|
58
|
+
iso_code: BT
|
59
|
+
'068':
|
60
|
+
iso_code: BO
|
61
|
+
'070':
|
62
|
+
iso_code: BA
|
63
|
+
'072':
|
64
|
+
iso_code: BW
|
65
|
+
'076':
|
66
|
+
iso_code: BR
|
67
|
+
'084':
|
68
|
+
iso_code: BZ
|
69
|
+
'090':
|
70
|
+
iso_code: SB
|
71
|
+
'092':
|
72
|
+
iso_code: VG
|
73
|
+
'096':
|
74
|
+
iso_code: BN
|
75
|
+
'100':
|
76
|
+
iso_code: BG
|
77
|
+
'104':
|
78
|
+
iso_code: MM
|
79
|
+
'108':
|
80
|
+
iso_code: BI
|
81
|
+
'112':
|
82
|
+
iso_code: BY
|
83
|
+
'116':
|
84
|
+
iso_code: KH
|
85
|
+
'120':
|
86
|
+
iso_code: CM
|
87
|
+
'124':
|
88
|
+
iso_code: CA
|
89
|
+
'132':
|
90
|
+
iso_code: CV
|
91
|
+
'136':
|
92
|
+
iso_code: KY
|
93
|
+
'140':
|
94
|
+
iso_code: CF
|
95
|
+
'142':
|
96
|
+
'143':
|
97
|
+
'144':
|
98
|
+
iso_code: LK
|
99
|
+
'145':
|
100
|
+
'148':
|
101
|
+
iso_code: TD
|
102
|
+
'150':
|
103
|
+
'151':
|
104
|
+
'152':
|
105
|
+
iso_code: CL
|
106
|
+
'154':
|
107
|
+
'155':
|
108
|
+
'156':
|
109
|
+
iso_code: CN
|
110
|
+
'170':
|
111
|
+
iso_code: CO
|
112
|
+
'174':
|
113
|
+
iso_code: KM
|
114
|
+
'175':
|
115
|
+
iso_code: YT
|
116
|
+
'178':
|
117
|
+
iso_code: CG
|
118
|
+
'180':
|
119
|
+
iso_code: CD
|
120
|
+
'184':
|
121
|
+
iso_code: CK
|
122
|
+
'188':
|
123
|
+
iso_code: CR
|
124
|
+
'191':
|
125
|
+
iso_code: HR
|
126
|
+
'192':
|
127
|
+
iso_code: CU
|
128
|
+
'196':
|
129
|
+
iso_code: CY
|
130
|
+
'203':
|
131
|
+
iso_code: CZ
|
132
|
+
'204':
|
133
|
+
iso_code: BJ
|
134
|
+
'208':
|
135
|
+
iso_code: DK
|
136
|
+
'212':
|
137
|
+
iso_code: DM
|
138
|
+
'214':
|
139
|
+
iso_code: DO
|
140
|
+
'218':
|
141
|
+
iso_code: EC
|
142
|
+
'222':
|
143
|
+
iso_code: SV
|
144
|
+
'226':
|
145
|
+
iso_code: GQ
|
146
|
+
'231':
|
147
|
+
iso_code: ET
|
148
|
+
'232':
|
149
|
+
iso_code: ER
|
150
|
+
'233':
|
151
|
+
iso_code: EE
|
152
|
+
'234':
|
153
|
+
iso_code: FO
|
154
|
+
'238':
|
155
|
+
iso_code: FK
|
156
|
+
'242':
|
157
|
+
iso_code: FJ
|
158
|
+
'246':
|
159
|
+
iso_code: FI
|
160
|
+
'248':
|
161
|
+
'250':
|
162
|
+
iso_code: FR
|
163
|
+
'254':
|
164
|
+
iso_code: GF
|
165
|
+
'258':
|
166
|
+
iso_code: PF
|
167
|
+
'262':
|
168
|
+
iso_code: DJ
|
169
|
+
'266':
|
170
|
+
iso_code: GA
|
171
|
+
'268':
|
172
|
+
iso_code: GE
|
173
|
+
'270':
|
174
|
+
iso_code: GM
|
175
|
+
'275':
|
176
|
+
iso_code: PS
|
177
|
+
'276':
|
178
|
+
iso_code: DE
|
179
|
+
'288':
|
180
|
+
iso_code: GH
|
181
|
+
'292':
|
182
|
+
iso_code: GI
|
183
|
+
'296':
|
184
|
+
iso_code: KI
|
185
|
+
'300':
|
186
|
+
iso_code: GR
|
187
|
+
'304':
|
188
|
+
iso_code: GL
|
189
|
+
'308':
|
190
|
+
iso_code: GD
|
191
|
+
'312':
|
192
|
+
iso_code: GP
|
193
|
+
'316':
|
194
|
+
iso_code: GU
|
195
|
+
'320':
|
196
|
+
iso_code: GT
|
197
|
+
'324':
|
198
|
+
iso_code: GN
|
199
|
+
'328':
|
200
|
+
iso_code: GY
|
201
|
+
'332':
|
202
|
+
iso_code: HT
|
203
|
+
'336':
|
204
|
+
iso_code: VE
|
205
|
+
'340':
|
206
|
+
iso_code: HN
|
207
|
+
'344':
|
208
|
+
'348':
|
209
|
+
iso_code: HU
|
210
|
+
'352':
|
211
|
+
iso_code: IS
|
212
|
+
'356':
|
213
|
+
iso_code: IN
|
214
|
+
'360':
|
215
|
+
iso_code: ID
|
216
|
+
'364':
|
217
|
+
iso_code: IR
|
218
|
+
'368':
|
219
|
+
iso_code: IQ
|
220
|
+
'372':
|
221
|
+
iso_code: IE
|
222
|
+
'376':
|
223
|
+
iso_code: IL
|
224
|
+
'380':
|
225
|
+
iso_code: IT
|
226
|
+
'384':
|
227
|
+
iso_code: CI
|
228
|
+
'388':
|
229
|
+
iso_code: JM
|
230
|
+
'392':
|
231
|
+
iso_code: JP
|
232
|
+
'398':
|
233
|
+
iso_code: KZ
|
234
|
+
'400':
|
235
|
+
iso_code: JO
|
236
|
+
'404':
|
237
|
+
iso_code: KE
|
238
|
+
'408':
|
239
|
+
iso_code: KP
|
240
|
+
'410':
|
241
|
+
iso_code: KR
|
242
|
+
'414':
|
243
|
+
iso_code: KW
|
244
|
+
'417':
|
245
|
+
iso_code: KG
|
246
|
+
'418':
|
247
|
+
iso_code: LA
|
248
|
+
'419':
|
249
|
+
'422':
|
250
|
+
iso_code: LB
|
251
|
+
'426':
|
252
|
+
iso_code: LS
|
253
|
+
'428':
|
254
|
+
iso_code: LV
|
255
|
+
'430':
|
256
|
+
iso_code: LR
|
257
|
+
'434':
|
258
|
+
iso_code: LY
|
259
|
+
'438':
|
260
|
+
iso_code: LI
|
261
|
+
'440':
|
262
|
+
iso_code: LT
|
263
|
+
'442':
|
264
|
+
iso_code: LU
|
265
|
+
'446':
|
266
|
+
'450':
|
267
|
+
iso_code: MG
|
268
|
+
'454':
|
269
|
+
iso_code: MW
|
270
|
+
'458':
|
271
|
+
iso_code: MY
|
272
|
+
'462':
|
273
|
+
iso_code: MV
|
274
|
+
'466':
|
275
|
+
iso_code: ML
|
276
|
+
'470':
|
277
|
+
iso_code: MT
|
278
|
+
'474':
|
279
|
+
iso_code: MQ
|
280
|
+
'478':
|
281
|
+
iso_code: MR
|
282
|
+
'480':
|
283
|
+
iso_code: MU
|
284
|
+
'484':
|
285
|
+
iso_code: MX
|
286
|
+
'492':
|
287
|
+
iso_code: MC
|
288
|
+
'496':
|
289
|
+
iso_code: MN
|
290
|
+
'498':
|
291
|
+
iso_code: MD
|
292
|
+
'499':
|
293
|
+
iso_code: ME
|
294
|
+
'500':
|
295
|
+
iso_code: MS
|
296
|
+
'504':
|
297
|
+
iso_code: MA
|
298
|
+
'508':
|
299
|
+
iso_code: MZ
|
300
|
+
'512':
|
301
|
+
iso_code: OM
|
302
|
+
'516':
|
303
|
+
iso_code: NA
|
304
|
+
'520':
|
305
|
+
iso_code: NR
|
306
|
+
'524':
|
307
|
+
iso_code: NP
|
308
|
+
'528':
|
309
|
+
iso_code: NL
|
310
|
+
'531':
|
311
|
+
'533':
|
312
|
+
iso_code: AW
|
313
|
+
'534':
|
314
|
+
iso_code: SX
|
315
|
+
'535':
|
316
|
+
'540':
|
317
|
+
iso_code: NC
|
318
|
+
'548':
|
319
|
+
iso_code: VU
|
320
|
+
'554':
|
321
|
+
iso_code: NZ
|
322
|
+
'558':
|
323
|
+
iso_code: NI
|
324
|
+
'562':
|
325
|
+
iso_code: NE
|
326
|
+
'566':
|
327
|
+
iso_code: NG
|
328
|
+
'570':
|
329
|
+
iso_code: NU
|
330
|
+
'574':
|
331
|
+
iso_code: NF
|
332
|
+
'578':
|
333
|
+
iso_code: 'NO'
|
334
|
+
'580':
|
335
|
+
iso_code: MP
|
336
|
+
'583':
|
337
|
+
iso_code: FM
|
338
|
+
'584':
|
339
|
+
iso_code: MH
|
340
|
+
'585':
|
341
|
+
iso_code: PW
|
342
|
+
'586':
|
343
|
+
iso_code: PK
|
344
|
+
'591':
|
345
|
+
iso_code: PA
|
346
|
+
'598':
|
347
|
+
iso_code: PG
|
348
|
+
'600':
|
349
|
+
iso_code: PY
|
350
|
+
'604':
|
351
|
+
iso_code: PE
|
352
|
+
'608':
|
353
|
+
iso_code: PH
|
354
|
+
'612':
|
355
|
+
iso_code: PN
|
356
|
+
'616':
|
357
|
+
iso_code: PL
|
358
|
+
'620':
|
359
|
+
iso_code: PT
|
360
|
+
'624':
|
361
|
+
iso_code: GW
|
362
|
+
'626':
|
363
|
+
iso_code: TL
|
364
|
+
'630':
|
365
|
+
iso_code: PR
|
366
|
+
'634':
|
367
|
+
iso_code: QA
|
368
|
+
'638':
|
369
|
+
'642':
|
370
|
+
iso_code: RO
|
371
|
+
'643':
|
372
|
+
iso_code: RU
|
373
|
+
'646':
|
374
|
+
iso_code: RW
|
375
|
+
'652':
|
376
|
+
iso_code: BL
|
377
|
+
'654':
|
378
|
+
iso_code: SH
|
379
|
+
'659':
|
380
|
+
iso_code: KN
|
381
|
+
'660':
|
382
|
+
iso_code: AI
|
383
|
+
'662':
|
384
|
+
iso_code: LC
|
385
|
+
'663':
|
386
|
+
iso_code: MF
|
387
|
+
'666':
|
388
|
+
iso_code: PM
|
389
|
+
'670':
|
390
|
+
iso_code: VC
|
391
|
+
'674':
|
392
|
+
iso_code: SM
|
393
|
+
'678':
|
394
|
+
iso_code: ST
|
395
|
+
'680':
|
396
|
+
'682':
|
397
|
+
iso_code: SA
|
398
|
+
'686':
|
399
|
+
iso_code: SN
|
400
|
+
'688':
|
401
|
+
iso_code: RS
|
402
|
+
'690':
|
403
|
+
iso_code: SC
|
404
|
+
'694':
|
405
|
+
iso_code: SL
|
406
|
+
'702':
|
407
|
+
iso_code: SG
|
408
|
+
'703':
|
409
|
+
iso_code: SK
|
410
|
+
'704':
|
411
|
+
iso_code: VN
|
412
|
+
'705':
|
413
|
+
iso_code: SI
|
414
|
+
'706':
|
415
|
+
iso_code: SO
|
416
|
+
'710':
|
417
|
+
iso_code: ZA
|
418
|
+
'716':
|
419
|
+
iso_code: ZW
|
420
|
+
'724':
|
421
|
+
iso_code: ES
|
422
|
+
'728':
|
423
|
+
iso_code: SS
|
424
|
+
'729':
|
425
|
+
iso_code: SD
|
426
|
+
'732':
|
427
|
+
iso_code: EH
|
428
|
+
'740':
|
429
|
+
iso_code: SR
|
430
|
+
'744':
|
431
|
+
iso_code: SJ
|
432
|
+
'748':
|
433
|
+
iso_code: SZ
|
434
|
+
'752':
|
435
|
+
iso_code: SE
|
436
|
+
'756':
|
437
|
+
iso_code: CH
|
438
|
+
'760':
|
439
|
+
iso_code: SY
|
440
|
+
'762':
|
441
|
+
iso_code: TJ
|
442
|
+
'764':
|
443
|
+
iso_code: TH
|
444
|
+
'768':
|
445
|
+
iso_code: TG
|
446
|
+
'772':
|
447
|
+
iso_code: TK
|
448
|
+
'776':
|
449
|
+
iso_code: TO
|
450
|
+
'780':
|
451
|
+
iso_code: TT
|
452
|
+
'784':
|
453
|
+
iso_code: AE
|
454
|
+
'788':
|
455
|
+
iso_code: TN
|
456
|
+
'792':
|
457
|
+
iso_code: TR
|
458
|
+
'795':
|
459
|
+
iso_code: TM
|
460
|
+
'796':
|
461
|
+
iso_code: TC
|
462
|
+
'798':
|
463
|
+
iso_code: TV
|
464
|
+
'800':
|
465
|
+
iso_code: UG
|
466
|
+
'804':
|
467
|
+
iso_code: UA
|
468
|
+
'807':
|
469
|
+
iso_code: MK
|
470
|
+
'818':
|
471
|
+
iso_code: EG
|
472
|
+
'826':
|
473
|
+
iso_code: GB
|
474
|
+
'830':
|
475
|
+
'831':
|
476
|
+
iso_code: GG
|
477
|
+
'832':
|
478
|
+
iso_code: JE
|
479
|
+
'833':
|
480
|
+
iso_code: IM
|
481
|
+
'834':
|
482
|
+
iso_code: TZ
|
483
|
+
'840':
|
484
|
+
iso_code: US
|
485
|
+
'850':
|
486
|
+
iso_code: VG
|
487
|
+
'854':
|
488
|
+
iso_code: BF
|
489
|
+
'858':
|
490
|
+
iso_code: UY
|
491
|
+
'860':
|
492
|
+
iso_code: UZ
|
493
|
+
'862':
|
494
|
+
iso_code: VE
|
495
|
+
'876':
|
496
|
+
iso_code: WS
|
497
|
+
'882':
|
498
|
+
iso_code: WS
|
499
|
+
'887':
|
500
|
+
iso_code: YE
|
501
|
+
'894':
|
502
|
+
iso_code: ZM
|
data/iso.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{iso}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Christopher Dell}]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-11-11}
|
13
13
|
s.description = %q{A subset of the ISO spec implemented in ruby}
|
14
14
|
s.email = %q{chris@tigrish.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,12 +28,14 @@ Gem::Specification.new do |s|
|
|
28
28
|
"VERSION",
|
29
29
|
"data/iso-3166-1.yml",
|
30
30
|
"data/iso-639-1.yml",
|
31
|
+
"data/un-m49.yml",
|
31
32
|
"iso.gemspec",
|
32
33
|
"lib/iso.rb",
|
33
34
|
"lib/iso/language.rb",
|
34
35
|
"lib/iso/region.rb",
|
35
36
|
"lib/iso/subtag.rb",
|
36
37
|
"lib/iso/tag.rb",
|
38
|
+
"lib/iso/un/region.rb",
|
37
39
|
"locales/en.yml",
|
38
40
|
"locales/fr.yml",
|
39
41
|
"spec/fixtures/base.yml",
|
@@ -41,6 +43,7 @@ Gem::Specification.new do |s|
|
|
41
43
|
"spec/lib/iso/region_spec.rb",
|
42
44
|
"spec/lib/iso/subtag_spec.rb",
|
43
45
|
"spec/lib/iso/tag_spec.rb",
|
46
|
+
"spec/lib/iso/un/region_spec.rb",
|
44
47
|
"spec/spec_helper.rb"
|
45
48
|
]
|
46
49
|
s.homepage = %q{http://github.com/tigrish/iso}
|
data/lib/iso.rb
CHANGED
data/lib/iso/region.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
class ISO::Region < ISO::Subtag
|
2
|
-
DEFINITIONS_FILE
|
2
|
+
DEFINITIONS_FILE = "#{File.dirname(__FILE__)}/../../data/iso-3166-1.yml"
|
3
3
|
|
4
4
|
def self.identify(full_code)
|
5
5
|
full_code =~ /[-_]([A-Z]{2})$/ ? find($1) : nil
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
9
|
+
|
9
10
|
def i18n_scope
|
10
11
|
super << ".regions"
|
11
12
|
end
|
data/lib/iso/subtag.rb
CHANGED
@@ -4,6 +4,7 @@ module ISO
|
|
4
4
|
|
5
5
|
def initialize(code, options={})
|
6
6
|
@code = code
|
7
|
+
@options = options
|
7
8
|
end
|
8
9
|
|
9
10
|
def ==(object)
|
@@ -11,7 +12,7 @@ module ISO
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def name
|
14
|
-
I18n.t(code, :scope => i18n_scope)
|
15
|
+
@options[:name] || I18n.t(code, :scope => i18n_scope)
|
15
16
|
end
|
16
17
|
|
17
18
|
def full_name
|
data/lib/iso/tag.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module ISO
|
2
|
+
module UN
|
3
|
+
class Region < ISO::Region
|
4
|
+
DEFINITIONS_FILE = "#{File.dirname(__FILE__)}/../../../data/un-m49.yml"
|
5
|
+
|
6
|
+
attr_reader :iso_code
|
7
|
+
|
8
|
+
def initialize(code, options={})
|
9
|
+
@iso_code = options[:iso_code]
|
10
|
+
super(code, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
return super if iso_code.nil?
|
15
|
+
@options[:name] || I18n.t(iso_code, :scope => i18n_scope)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.identify(full_code)
|
19
|
+
full_code =~ /-(\d{3})$/ ? find($1) : nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/locales/en.yml
CHANGED
@@ -187,6 +187,42 @@ en:
|
|
187
187
|
zh: Chinese
|
188
188
|
zu: Zulu
|
189
189
|
regions:
|
190
|
+
'002': Africa
|
191
|
+
'005': South America
|
192
|
+
'009': Oceania
|
193
|
+
'011': Western Africa
|
194
|
+
'013': Central America
|
195
|
+
'014': Eastern Africa
|
196
|
+
'015': Northern Africa
|
197
|
+
'017': Middle Africa
|
198
|
+
'018': Southern Africa
|
199
|
+
'019': Americas
|
200
|
+
'021': Northern Americab
|
201
|
+
'029': Caribbean
|
202
|
+
'030': Eastern Asia
|
203
|
+
'034': Southern Asia
|
204
|
+
'035': South-Eastern Asia
|
205
|
+
'039': Southern Europe
|
206
|
+
'053': Australia and New Zealand
|
207
|
+
'054': Melanesia
|
208
|
+
'057': Micronesia
|
209
|
+
'061': Polynesia
|
210
|
+
'142': Asia
|
211
|
+
'143': Central Asia
|
212
|
+
'145': Western Asia
|
213
|
+
'150': Europe
|
214
|
+
'151': Eastern Europe
|
215
|
+
'154': Northern Europe
|
216
|
+
'155': Western Europe
|
217
|
+
'248': Land Islands
|
218
|
+
'344': China, Hong Kong Special Administrative Region
|
219
|
+
'419': Latin America and the Caribbean
|
220
|
+
'446': China, Macao Special Administrative Region
|
221
|
+
'531': Curaao
|
222
|
+
'535': Bonaire, Saint Eustatius and Saba
|
223
|
+
'638': Runion
|
224
|
+
'680': Sark
|
225
|
+
'830': Channel Islands
|
190
226
|
AF: Afghanistan
|
191
227
|
AX: Aland Islands
|
192
228
|
AL: Albania
|
data/spec/lib/iso/subtag_spec.rb
CHANGED
@@ -20,6 +20,22 @@ describe ISO::Subtag do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe "#name" do
|
24
|
+
let(:fake_region) { ISO::Subtag.new('FR', name: 'This is a lie') }
|
25
|
+
let(:mars) { ISO::Subtag.new('MRS') }
|
26
|
+
|
27
|
+
it 'will accept a name option' do
|
28
|
+
I18n.should_not_receive(:t)
|
29
|
+
fake_region.name.should == 'This is a lie'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'falls back to the translation' do
|
33
|
+
I18n.should_receive(:t).with('MRS', scope: 'vendor.iso').and_return('Mars')
|
34
|
+
mars.name.should == 'Mars'
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
23
39
|
describe "#full_name" do
|
24
40
|
it "is composed of the code and the name" do
|
25
41
|
full_name = Subtag.find('fr').full_name
|
data/spec/lib/iso/tag_spec.rb
CHANGED
@@ -8,6 +8,12 @@ describe ISO::Tag do
|
|
8
8
|
tag.region.code.should == 'MX'
|
9
9
|
end
|
10
10
|
|
11
|
+
it "returns a tag containing the language and UN region" do
|
12
|
+
tag = ISO::Tag.new('en-419')
|
13
|
+
tag.language.code.should == 'en'
|
14
|
+
tag.region.code.should == '419'
|
15
|
+
end
|
16
|
+
|
11
17
|
it "returns a tag containing the language only" do
|
12
18
|
tag = ISO::Tag.new('en-XXXXXX')
|
13
19
|
tag.language.code.should == 'en'
|
@@ -19,6 +25,12 @@ describe ISO::Tag do
|
|
19
25
|
tag.language.should be_nil
|
20
26
|
tag.region.code.should == 'CH'
|
21
27
|
end
|
28
|
+
|
29
|
+
it "returns a tag containing the UN region only" do
|
30
|
+
tag = ISO::Tag.new('gsw-419')
|
31
|
+
tag.language.should be_nil
|
32
|
+
tag.region.code.should == '419'
|
33
|
+
end
|
22
34
|
|
23
35
|
it "returns a tag containing no language or region" do
|
24
36
|
tag = ISO::Tag.new('csb-XXXXXX')
|
@@ -62,6 +74,10 @@ describe ISO::Tag do
|
|
62
74
|
ISO::Tag.new('da-AT').should be_valid
|
63
75
|
end
|
64
76
|
|
77
|
+
it "returns true when a valid language an UN region are supplied" do
|
78
|
+
ISO::Tag.new('es-419').should be_valid
|
79
|
+
end
|
80
|
+
|
65
81
|
it "returns false when no code is supplied" do
|
66
82
|
ISO::Tag.new('').should_not be_valid
|
67
83
|
end
|
@@ -73,5 +89,6 @@ describe ISO::Tag do
|
|
73
89
|
it "returns false when supplied region is invalid" do
|
74
90
|
ISO::Tag.new('en-lol').should_not be_valid
|
75
91
|
end
|
92
|
+
|
76
93
|
end
|
77
94
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ISO::UN::Region do
|
4
|
+
let(:has_iso) { ISO::UN::Region.find('004') }
|
5
|
+
let(:no_iso) { ISO::UN::Region.find('002') }
|
6
|
+
|
7
|
+
describe "#iso_code" do
|
8
|
+
it "returns the corresponding iso code" do
|
9
|
+
has_iso.iso_code.should == 'AF'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns nil when there is no corresponding iso code" do
|
13
|
+
no_iso.iso_code.should be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#name" do
|
18
|
+
it "uses the correct scope when there is an iso code" do
|
19
|
+
has_iso.name.should == 'Afghanistan'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "uses the correct scope when there is no iso code" do
|
23
|
+
no_iso.name.should == 'Africa'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".identify(full_code)" do
|
28
|
+
it "identifies from 'es-419'" do
|
29
|
+
region = ISO::UN::Region.identify('es-419')
|
30
|
+
region.should_not be_nil
|
31
|
+
region.should == ISO::UN::Region.find('419')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns nil when it can't identify" do
|
35
|
+
ISO::UN::Region.identify('gsw').should be_nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement: &
|
16
|
+
requirement: &70215111244900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70215111244900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70215111244420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.8.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70215111244420
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdoc
|
38
|
-
requirement: &
|
38
|
+
requirement: &70215111243940 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.12'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70215111243940
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70215111243460 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.2.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70215111243460
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70215111242980 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.8.4
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70215111242980
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70215111242500 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70215111242500
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: localeapp
|
82
|
-
requirement: &
|
82
|
+
requirement: &70215111242020 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70215111242020
|
91
91
|
description: A subset of the ISO spec implemented in ruby
|
92
92
|
email: chris@tigrish.com
|
93
93
|
executables: []
|
@@ -107,12 +107,14 @@ files:
|
|
107
107
|
- VERSION
|
108
108
|
- data/iso-3166-1.yml
|
109
109
|
- data/iso-639-1.yml
|
110
|
+
- data/un-m49.yml
|
110
111
|
- iso.gemspec
|
111
112
|
- lib/iso.rb
|
112
113
|
- lib/iso/language.rb
|
113
114
|
- lib/iso/region.rb
|
114
115
|
- lib/iso/subtag.rb
|
115
116
|
- lib/iso/tag.rb
|
117
|
+
- lib/iso/un/region.rb
|
116
118
|
- locales/en.yml
|
117
119
|
- locales/fr.yml
|
118
120
|
- spec/fixtures/base.yml
|
@@ -120,6 +122,7 @@ files:
|
|
120
122
|
- spec/lib/iso/region_spec.rb
|
121
123
|
- spec/lib/iso/subtag_spec.rb
|
122
124
|
- spec/lib/iso/tag_spec.rb
|
125
|
+
- spec/lib/iso/un/region_spec.rb
|
123
126
|
- spec/spec_helper.rb
|
124
127
|
homepage: http://github.com/tigrish/iso
|
125
128
|
licenses:
|
@@ -136,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
139
|
version: '0'
|
137
140
|
segments:
|
138
141
|
- 0
|
139
|
-
hash:
|
142
|
+
hash: 2282321289166675717
|
140
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
144
|
none: false
|
142
145
|
requirements:
|