countries 4.2.3 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.github/workflows/tests.yml +3 -7
- data/.rubocop.yml +40 -1
- data/.rubocop_todo.yml +8 -41
- data/CHANGELOG.md +35 -2
- data/Gemfile +5 -3
- data/README.markdown +56 -62
- data/Rakefile +21 -45
- data/UPGRADE.md +39 -0
- data/bin/console +1 -0
- data/countries.gemspec +7 -6
- data/lib/countries/cache/countries.json +1 -1
- data/lib/countries/cache/locales/ab.json +1 -1
- data/lib/countries/cache/locales/af.json +1 -1
- data/lib/countries/cache/locales/ak.json +1 -1
- data/lib/countries/cache/locales/am.json +1 -1
- data/lib/countries/cache/locales/an.json +1 -1
- data/lib/countries/cache/locales/ar.json +1 -1
- data/lib/countries/cache/locales/as.json +1 -1
- data/lib/countries/cache/locales/ay.json +1 -1
- data/lib/countries/cache/locales/az.json +1 -1
- data/lib/countries/cache/locales/ba.json +1 -1
- data/lib/countries/cache/locales/be.json +1 -1
- data/lib/countries/cache/locales/bg.json +1 -1
- data/lib/countries/cache/locales/bi.json +1 -1
- data/lib/countries/cache/locales/bn-in.json +1 -1
- data/lib/countries/cache/locales/bn.json +1 -1
- data/lib/countries/cache/locales/br.json +1 -1
- data/lib/countries/cache/locales/bs.json +1 -1
- data/lib/countries/cache/locales/ca.json +1 -1
- data/lib/countries/cache/locales/ce.json +1 -1
- data/lib/countries/cache/locales/ch.json +1 -1
- data/lib/countries/cache/locales/cs.json +1 -1
- data/lib/countries/cache/locales/cv.json +1 -1
- data/lib/countries/cache/locales/cy.json +1 -1
- data/lib/countries/cache/locales/da.json +1 -1
- data/lib/countries/cache/locales/de.json +1 -1
- data/lib/countries/cache/locales/dv.json +1 -1
- data/lib/countries/cache/locales/dz.json +1 -1
- data/lib/countries/cache/locales/ee.json +1 -1
- data/lib/countries/cache/locales/el.json +1 -1
- data/lib/countries/cache/locales/en.json +1 -1
- data/lib/countries/cache/locales/eo.json +1 -1
- data/lib/countries/cache/locales/es.json +1 -1
- data/lib/countries/cache/locales/et.json +1 -1
- data/lib/countries/cache/locales/eu.json +1 -1
- data/lib/countries/cache/locales/fa.json +1 -1
- data/lib/countries/cache/locales/ff.json +1 -1
- data/lib/countries/cache/locales/fi.json +1 -1
- data/lib/countries/cache/locales/fo.json +1 -1
- data/lib/countries/cache/locales/fr.json +1 -1
- data/lib/countries/cache/locales/fy.json +1 -1
- data/lib/countries/cache/locales/ga.json +1 -1
- data/lib/countries/cache/locales/gl.json +1 -1
- data/lib/countries/cache/locales/gn.json +1 -1
- data/lib/countries/cache/locales/gu.json +1 -1
- data/lib/countries/cache/locales/gv.json +1 -1
- data/lib/countries/cache/locales/ha.json +1 -1
- data/lib/countries/cache/locales/he.json +1 -1
- data/lib/countries/cache/locales/hi.json +1 -1
- data/lib/countries/cache/locales/hr.json +1 -1
- data/lib/countries/cache/locales/ht.json +1 -1
- data/lib/countries/cache/locales/hu.json +1 -1
- data/lib/countries/cache/locales/hy.json +1 -1
- data/lib/countries/cache/locales/ia.json +1 -1
- data/lib/countries/cache/locales/id.json +1 -1
- data/lib/countries/cache/locales/io.json +1 -1
- data/lib/countries/cache/locales/is.json +1 -1
- data/lib/countries/cache/locales/it.json +1 -1
- data/lib/countries/cache/locales/iu.json +1 -1
- data/lib/countries/cache/locales/ja.json +1 -1
- data/lib/countries/cache/locales/ka.json +1 -1
- data/lib/countries/cache/locales/ki.json +1 -1
- data/lib/countries/cache/locales/kk.json +1 -1
- data/lib/countries/cache/locales/kl.json +1 -1
- data/lib/countries/cache/locales/km.json +1 -1
- data/lib/countries/cache/locales/kn.json +1 -1
- data/lib/countries/cache/locales/ko.json +1 -1
- data/lib/countries/cache/locales/kv.json +1 -1
- data/lib/countries/cache/locales/kw.json +1 -1
- data/lib/countries/cache/locales/ky.json +1 -1
- data/lib/countries/cache/locales/lo.json +1 -1
- data/lib/countries/cache/locales/lt.json +1 -1
- data/lib/countries/cache/locales/lv.json +1 -1
- data/lib/countries/cache/locales/mi.json +1 -1
- data/lib/countries/cache/locales/mk.json +1 -1
- data/lib/countries/cache/locales/ml.json +1 -1
- data/lib/countries/cache/locales/mn.json +1 -1
- data/lib/countries/cache/locales/mr.json +1 -1
- data/lib/countries/cache/locales/ms.json +1 -1
- data/lib/countries/cache/locales/mt.json +1 -1
- data/lib/countries/cache/locales/my.json +1 -1
- data/lib/countries/cache/locales/na.json +1 -1
- data/lib/countries/cache/locales/nb.json +1 -1
- data/lib/countries/cache/locales/ne.json +1 -1
- data/lib/countries/cache/locales/nl.json +1 -1
- data/lib/countries/cache/locales/nn.json +1 -1
- data/lib/countries/cache/locales/nv.json +1 -1
- data/lib/countries/cache/locales/oc.json +1 -1
- data/lib/countries/cache/locales/or.json +1 -1
- data/lib/countries/cache/locales/pa.json +1 -1
- data/lib/countries/cache/locales/pi.json +1 -1
- data/lib/countries/cache/locales/pl.json +1 -1
- data/lib/countries/cache/locales/ps.json +1 -1
- data/lib/countries/cache/locales/pt-br.json +1 -1
- data/lib/countries/cache/locales/pt.json +1 -1
- data/lib/countries/cache/locales/ro.json +1 -1
- data/lib/countries/cache/locales/ru.json +1 -1
- data/lib/countries/cache/locales/rw.json +1 -1
- data/lib/countries/cache/locales/sc.json +1 -1
- data/lib/countries/cache/locales/sd.json +1 -1
- data/lib/countries/cache/locales/si.json +1 -1
- data/lib/countries/cache/locales/sk.json +1 -1
- data/lib/countries/cache/locales/sl.json +1 -1
- data/lib/countries/cache/locales/so.json +1 -1
- data/lib/countries/cache/locales/sq.json +1 -1
- data/lib/countries/cache/locales/sr.json +1 -1
- data/lib/countries/cache/locales/sv.json +1 -1
- data/lib/countries/cache/locales/sw.json +1 -1
- data/lib/countries/cache/locales/ta.json +1 -1
- data/lib/countries/cache/locales/te.json +1 -1
- data/lib/countries/cache/locales/tg.json +1 -1
- data/lib/countries/cache/locales/th.json +1 -1
- data/lib/countries/cache/locales/ti.json +1 -1
- data/lib/countries/cache/locales/tk.json +1 -1
- data/lib/countries/cache/locales/tl.json +1 -1
- data/lib/countries/cache/locales/tr.json +1 -1
- data/lib/countries/cache/locales/tt.json +1 -1
- data/lib/countries/cache/locales/ug.json +1 -1
- data/lib/countries/cache/locales/uk.json +1 -1
- data/lib/countries/cache/locales/ur.json +1 -1
- data/lib/countries/cache/locales/uz.json +1 -1
- data/lib/countries/cache/locales/ve.json +1 -1
- data/lib/countries/cache/locales/vi.json +1 -1
- data/lib/countries/cache/locales/wa.json +1 -1
- data/lib/countries/cache/locales/wo.json +1 -1
- data/lib/countries/cache/locales/xh.json +1 -1
- data/lib/countries/cache/locales/yo.json +1 -1
- data/lib/countries/cache/locales/zh-cn.json +1 -1
- data/lib/countries/cache/locales/zh-hk.json +1 -1
- data/lib/countries/cache/locales/zh-tw.json +1 -1
- data/lib/countries/cache/locales/zu.json +1 -1
- data/lib/countries/configuration.rb +2 -0
- data/lib/countries/country/class_methods.rb +20 -103
- data/lib/countries/country/currency_methods.rb +2 -0
- data/lib/countries/country/emoji.rb +2 -3
- data/lib/countries/country/finder_methods.rb +81 -0
- data/lib/countries/country.rb +32 -43
- data/lib/countries/data/countries/KN.yaml +0 -1
- data/lib/countries/data/subdivisions/AD.yaml +14 -7
- data/lib/countries/data/subdivisions/AE.yaml +14 -7
- data/lib/countries/data/subdivisions/AF.yaml +196 -201
- data/lib/countries/data/subdivisions/AG.yaml +16 -22
- data/lib/countries/data/subdivisions/AL.yaml +24 -12
- data/lib/countries/data/subdivisions/AM.yaml +22 -11
- data/lib/countries/data/subdivisions/AO.yaml +36 -18
- data/lib/countries/data/subdivisions/AR.yaml +48 -24
- data/lib/countries/data/subdivisions/AT.yaml +18 -9
- data/lib/countries/data/subdivisions/AU.yaml +16 -8
- data/lib/countries/data/subdivisions/AZ.yaml +434 -412
- data/lib/countries/data/subdivisions/BA.yaml +75 -223
- data/lib/countries/data/subdivisions/BB.yaml +22 -11
- data/lib/countries/data/subdivisions/BD.yaml +188 -116
- data/lib/countries/data/subdivisions/BE.yaml +174 -161
- data/lib/countries/data/subdivisions/BF.yaml +2918 -2860
- data/lib/countries/data/subdivisions/BG.yaml +56 -28
- data/lib/countries/data/subdivisions/BH.yaml +8 -21
- data/lib/countries/data/subdivisions/BI.yaml +176 -157
- data/lib/countries/data/subdivisions/BJ.yaml +24 -12
- data/lib/countries/data/subdivisions/BN.yaml +8 -4
- data/lib/countries/data/subdivisions/BO.yaml +18 -9
- data/lib/countries/data/subdivisions/BQ.yaml +6 -3
- data/lib/countries/data/subdivisions/BR.yaml +54 -27
- data/lib/countries/data/subdivisions/BS.yaml +575 -697
- data/lib/countries/data/subdivisions/BT.yaml +40 -20
- data/lib/countries/data/subdivisions/BW.yaml +337 -321
- data/lib/countries/data/subdivisions/BY.yaml +106 -116
- data/lib/countries/data/subdivisions/BZ.yaml +12 -6
- data/lib/countries/data/subdivisions/CA.yaml +26 -13
- data/lib/countries/data/subdivisions/CD.yaml +488 -525
- data/lib/countries/data/subdivisions/CF.yaml +34 -17
- data/lib/countries/data/subdivisions/CG.yaml +40 -28
- data/lib/countries/data/subdivisions/CH.yaml +52 -26
- data/lib/countries/data/subdivisions/CI.yaml +244 -516
- data/lib/countries/data/subdivisions/CL.yaml +81 -65
- data/lib/countries/data/subdivisions/CM.yaml +20 -10
- data/lib/countries/data/subdivisions/CN.yaml +2152 -2084
- data/lib/countries/data/subdivisions/CO.yaml +66 -33
- data/lib/countries/data/subdivisions/CR.yaml +14 -7
- data/lib/countries/data/subdivisions/CU.yaml +32 -16
- data/lib/countries/data/subdivisions/CV.yaml +427 -401
- data/lib/countries/data/subdivisions/CY.yaml +12 -6
- data/lib/countries/data/subdivisions/CZ.yaml +1116 -85
- data/lib/countries/data/subdivisions/DE.yaml +32 -16
- data/lib/countries/data/subdivisions/DJ.yaml +12 -6
- data/lib/countries/data/subdivisions/DK.yaml +25 -17
- data/lib/countries/data/subdivisions/DM.yaml +20 -10
- data/lib/countries/data/subdivisions/DO.yaml +84 -42
- data/lib/countries/data/subdivisions/DZ.yaml +96 -48
- data/lib/countries/data/subdivisions/EC.yaml +158 -134
- data/lib/countries/data/subdivisions/EE.yaml +501 -334
- data/lib/countries/data/subdivisions/EG.yaml +54 -27
- data/lib/countries/data/subdivisions/ER.yaml +12 -6
- data/lib/countries/data/subdivisions/ES.yaml +1459 -1390
- data/lib/countries/data/subdivisions/ET.yaml +22 -11
- data/lib/countries/data/subdivisions/FI.yaml +185 -1
- data/lib/countries/data/subdivisions/FJ.yaml +443 -424
- data/lib/countries/data/subdivisions/FM.yaml +8 -4
- data/lib/countries/data/subdivisions/FR.yaml +438 -275
- data/lib/countries/data/subdivisions/GA.yaml +18 -9
- data/lib/countries/data/subdivisions/GB.yaml +1185 -1708
- data/lib/countries/data/subdivisions/GD.yaml +14 -7
- data/lib/countries/data/subdivisions/GE.yaml +24 -12
- data/lib/countries/data/subdivisions/GH.yaml +114 -155
- data/lib/countries/data/subdivisions/GL.yaml +24 -79
- data/lib/countries/data/subdivisions/GM.yaml +12 -6
- data/lib/countries/data/subdivisions/GN.yaml +444 -403
- data/lib/countries/data/subdivisions/GQ.yaml +24 -13
- data/lib/countries/data/subdivisions/GR.yaml +114 -73
- data/lib/countries/data/subdivisions/GT.yaml +44 -22
- data/lib/countries/data/subdivisions/GW.yaml +69 -57
- data/lib/countries/data/subdivisions/GY.yaml +20 -10
- data/lib/countries/data/subdivisions/HN.yaml +36 -18
- data/lib/countries/data/subdivisions/HR.yaml +42 -21
- data/lib/countries/data/subdivisions/HT.yaml +73 -63
- data/lib/countries/data/subdivisions/HU.yaml +106 -63
- data/lib/countries/data/subdivisions/ID.yaml +229 -188
- data/lib/countries/data/subdivisions/IE.yaml +128 -97
- data/lib/countries/data/subdivisions/IL.yaml +12 -6
- data/lib/countries/data/subdivisions/IN.yaml +245 -396
- data/lib/countries/data/subdivisions/IQ.yaml +111 -91
- data/lib/countries/data/subdivisions/IR.yaml +1463 -1451
- data/lib/countries/data/subdivisions/IS.yaml +160 -25
- data/lib/countries/data/subdivisions/IT.yaml +8740 -8292
- data/lib/countries/data/subdivisions/JM.yaml +28 -14
- data/lib/countries/data/subdivisions/JO.yaml +24 -12
- data/lib/countries/data/subdivisions/JP.yaml +94 -47
- data/lib/countries/data/subdivisions/KE.yaml +95 -48
- data/lib/countries/data/subdivisions/KG.yaml +95 -86
- data/lib/countries/data/subdivisions/KH.yaml +64 -39
- data/lib/countries/data/subdivisions/KI.yaml +6 -3
- data/lib/countries/data/subdivisions/KM.yaml +6 -3
- data/lib/countries/data/subdivisions/KN.yaml +32 -16
- data/lib/countries/data/subdivisions/KP.yaml +24 -227
- data/lib/countries/data/subdivisions/KR.yaml +34 -17
- data/lib/countries/data/subdivisions/KW.yaml +12 -6
- data/lib/countries/data/subdivisions/KZ.yaml +47 -102
- data/lib/countries/data/subdivisions/LA.yaml +36 -34
- data/lib/countries/data/subdivisions/LB.yaml +71 -63
- data/lib/countries/data/subdivisions/LC.yaml +116 -106
- data/lib/countries/data/subdivisions/LI.yaml +22 -11
- data/lib/countries/data/subdivisions/LK.yaml +445 -411
- data/lib/countries/data/subdivisions/LR.yaml +146 -129
- data/lib/countries/data/subdivisions/LS.yaml +20 -10
- data/lib/countries/data/subdivisions/LT.yaml +1706 -1636
- data/lib/countries/data/subdivisions/LU.yaml +24 -12
- data/lib/countries/data/subdivisions/LV.yaml +1623 -1577
- data/lib/countries/data/subdivisions/LY.yaml +44 -22
- data/lib/countries/data/subdivisions/MA.yaml +810 -1589
- data/lib/countries/data/subdivisions/MC.yaml +261 -244
- data/lib/countries/data/subdivisions/MD.yaml +74 -79
- data/lib/countries/data/subdivisions/ME.yaml +217 -195
- data/lib/countries/data/subdivisions/MG.yaml +12 -6
- data/lib/countries/data/subdivisions/MH.yaml +167 -140
- data/lib/countries/data/subdivisions/MK.yaml +160 -80
- data/lib/countries/data/subdivisions/ML.yaml +48 -37
- data/lib/countries/data/subdivisions/MM.yaml +30 -15
- data/lib/countries/data/subdivisions/MN.yaml +44 -22
- data/lib/countries/data/subdivisions/MR.yaml +30 -34
- data/lib/countries/data/subdivisions/MT.yaml +136 -68
- data/lib/countries/data/subdivisions/MU.yaml +24 -262
- data/lib/countries/data/subdivisions/MV.yaml +161 -254
- data/lib/countries/data/subdivisions/MW.yaml +250 -219
- data/lib/countries/data/subdivisions/MX.yaml +67 -47
- data/lib/countries/data/subdivisions/MY.yaml +32 -16
- data/lib/countries/data/subdivisions/MZ.yaml +22 -11
- data/lib/countries/data/subdivisions/NA.yaml +58 -44
- data/lib/countries/data/subdivisions/NE.yaml +16 -8
- data/lib/countries/data/subdivisions/NG.yaml +74 -37
- data/lib/countries/data/subdivisions/NI.yaml +34 -17
- data/lib/countries/data/subdivisions/NL.yaml +303 -285
- data/lib/countries/data/subdivisions/NO.yaml +39 -17
- data/lib/countries/data/subdivisions/NP.yaml +302 -276
- data/lib/countries/data/subdivisions/NR.yaml +28 -14
- data/lib/countries/data/subdivisions/NZ.yaml +34 -17
- data/lib/countries/data/subdivisions/OM.yaml +260 -311
- data/lib/countries/data/subdivisions/PA.yaml +57 -44
- data/lib/countries/data/subdivisions/PE.yaml +107 -81
- data/lib/countries/data/subdivisions/PG.yaml +163 -158
- data/lib/countries/data/subdivisions/PH.yaml +5062 -4992
- data/lib/countries/data/subdivisions/PK.yaml +145 -235
- data/lib/countries/data/subdivisions/PL.yaml +51 -3
- data/lib/countries/data/subdivisions/PS.yaml +32 -16
- data/lib/countries/data/subdivisions/PT.yaml +53 -33
- data/lib/countries/data/subdivisions/PW.yaml +32 -16
- data/lib/countries/data/subdivisions/PY.yaml +36 -18
- data/lib/countries/data/subdivisions/QA.yaml +27 -78
- data/lib/countries/data/subdivisions/RO.yaml +84 -42
- data/lib/countries/data/subdivisions/RS.yaml +104 -72
- data/lib/countries/data/subdivisions/RU.yaml +166 -83
- data/lib/countries/data/subdivisions/RW.yaml +10 -5
- data/lib/countries/data/subdivisions/SA.yaml +26 -13
- data/lib/countries/data/subdivisions/SB.yaml +20 -10
- data/lib/countries/data/subdivisions/SC.yaml +54 -25
- data/lib/countries/data/subdivisions/SD.yaml +798 -780
- data/lib/countries/data/subdivisions/SE.yaml +42 -21
- data/lib/countries/data/subdivisions/SG.yaml +15 -10
- data/lib/countries/data/subdivisions/SH.yaml +21 -32
- data/lib/countries/data/subdivisions/SI.yaml +475 -263
- data/lib/countries/data/subdivisions/SK.yaml +16 -8
- data/lib/countries/data/subdivisions/SL.yaml +23 -18
- data/lib/countries/data/subdivisions/SM.yaml +18 -9
- data/lib/countries/data/subdivisions/SN.yaml +188 -174
- data/lib/countries/data/subdivisions/SO.yaml +36 -18
- data/lib/countries/data/subdivisions/SR.yaml +20 -10
- data/lib/countries/data/subdivisions/SS.yaml +20 -10
- data/lib/countries/data/subdivisions/ST.yaml +38 -52
- data/lib/countries/data/subdivisions/SV.yaml +28 -14
- data/lib/countries/data/subdivisions/SY.yaml +28 -14
- data/lib/countries/data/subdivisions/SZ.yaml +8 -4
- data/lib/countries/data/subdivisions/TD.yaml +312 -303
- data/lib/countries/data/subdivisions/TG.yaml +10 -5
- data/lib/countries/data/subdivisions/TH.yaml +211 -133
- data/lib/countries/data/subdivisions/TJ.yaml +161 -156
- data/lib/countries/data/subdivisions/TL.yaml +26 -13
- data/lib/countries/data/subdivisions/TM.yaml +12 -6
- data/lib/countries/data/subdivisions/TN.yaml +48 -24
- data/lib/countries/data/subdivisions/TO.yaml +10 -5
- data/lib/countries/data/subdivisions/TR.yaml +162 -81
- data/lib/countries/data/subdivisions/TT.yaml +128 -160
- data/lib/countries/data/subdivisions/TV.yaml +57 -63
- data/lib/countries/data/subdivisions/TW.yaml +143 -183
- data/lib/countries/data/subdivisions/TZ.yaml +62 -31
- data/lib/countries/data/subdivisions/UA.yaml +55 -28
- data/lib/countries/data/subdivisions/UG.yaml +4806 -4660
- data/lib/countries/data/subdivisions/UM.yaml +18 -9
- data/lib/countries/data/subdivisions/US.yaml +114 -57
- data/lib/countries/data/subdivisions/UY.yaml +99 -80
- data/lib/countries/data/subdivisions/UZ.yaml +28 -14
- data/lib/countries/data/subdivisions/VC.yaml +12 -6
- data/lib/countries/data/subdivisions/VE.yaml +50 -25
- data/lib/countries/data/subdivisions/VN.yaml +3576 -3513
- data/lib/countries/data/subdivisions/VU.yaml +12 -6
- data/lib/countries/data/subdivisions/WF.yaml +6 -3
- data/lib/countries/data/subdivisions/WS.yaml +22 -11
- data/lib/countries/data/subdivisions/YE.yaml +222 -200
- data/lib/countries/data/subdivisions/ZA.yaml +86 -100
- data/lib/countries/data/subdivisions/ZM.yaml +20 -10
- data/lib/countries/data/subdivisions/ZW.yaml +20 -10
- data/lib/countries/data/translations/countries-ab.yaml +254 -0
- data/lib/countries/data/translations/countries-af.yaml +254 -0
- data/lib/countries/data/translations/countries-ak.yaml +254 -0
- data/lib/countries/data/translations/countries-am.yaml +254 -0
- data/lib/countries/data/translations/countries-an.yaml +254 -0
- data/lib/countries/data/translations/countries-ar.yaml +254 -0
- data/lib/countries/data/translations/countries-as.yaml +254 -0
- data/lib/countries/data/translations/countries-ay.yaml +254 -0
- data/lib/countries/data/translations/countries-az.yaml +254 -0
- data/lib/countries/data/translations/countries-ba.yaml +254 -0
- data/lib/countries/data/translations/countries-be.yaml +254 -0
- data/lib/countries/data/translations/countries-bg.yaml +254 -0
- data/lib/countries/data/translations/countries-bi.yaml +254 -0
- data/lib/countries/data/translations/countries-bn.yaml +254 -0
- data/lib/countries/data/translations/countries-bn_IN.yaml +254 -0
- data/lib/countries/data/translations/countries-br.yaml +254 -0
- data/lib/countries/data/translations/countries-bs.yaml +254 -0
- data/lib/countries/data/translations/countries-ca.yaml +254 -0
- data/lib/countries/data/translations/countries-ce.yaml +254 -0
- data/lib/countries/data/translations/countries-ch.yaml +254 -0
- data/lib/countries/data/translations/countries-cs.yaml +254 -0
- data/lib/countries/data/translations/countries-cv.yaml +254 -0
- data/lib/countries/data/translations/countries-cy.yaml +254 -0
- data/lib/countries/data/translations/countries-da.yaml +254 -0
- data/lib/countries/data/translations/countries-de.yaml +254 -0
- data/lib/countries/data/translations/countries-dv.yaml +254 -0
- data/lib/countries/data/translations/countries-dz.yaml +254 -0
- data/lib/countries/data/translations/countries-ee.yaml +254 -0
- data/lib/countries/data/translations/countries-el.yaml +254 -0
- data/lib/countries/data/translations/countries-en.yaml +254 -0
- data/lib/countries/data/translations/countries-eo.yaml +254 -0
- data/lib/countries/data/translations/countries-es.yaml +254 -0
- data/lib/countries/data/translations/countries-et.yaml +254 -0
- data/lib/countries/data/translations/countries-eu.yaml +254 -0
- data/lib/countries/data/translations/countries-fa.yaml +254 -0
- data/lib/countries/data/translations/countries-ff.yaml +254 -0
- data/lib/countries/data/translations/countries-fi.yaml +254 -0
- data/lib/countries/data/translations/countries-fo.yaml +254 -0
- data/lib/countries/data/translations/countries-fr.yaml +254 -0
- data/lib/countries/data/translations/countries-fy.yaml +254 -0
- data/lib/countries/data/translations/countries-ga.yaml +254 -0
- data/lib/countries/data/translations/countries-gl.yaml +254 -0
- data/lib/countries/data/translations/countries-gn.yaml +254 -0
- data/lib/countries/data/translations/countries-gu.yaml +254 -0
- data/lib/countries/data/translations/countries-gv.yaml +254 -0
- data/lib/countries/data/translations/countries-ha.yaml +254 -0
- data/lib/countries/data/translations/countries-he.yaml +254 -0
- data/lib/countries/data/translations/countries-hi.yaml +254 -0
- data/lib/countries/data/translations/countries-hr.yaml +254 -0
- data/lib/countries/data/translations/countries-ht.yaml +254 -0
- data/lib/countries/data/translations/countries-hu.yaml +254 -0
- data/lib/countries/data/translations/countries-hy.yaml +254 -0
- data/lib/countries/data/translations/countries-ia.yaml +254 -0
- data/lib/countries/data/translations/countries-id.yaml +254 -0
- data/lib/countries/data/translations/countries-io.yaml +254 -0
- data/lib/countries/data/translations/countries-is.yaml +254 -0
- data/lib/countries/data/translations/countries-it.yaml +254 -0
- data/lib/countries/data/translations/countries-iu.yaml +254 -0
- data/lib/countries/data/translations/countries-ja.yaml +254 -0
- data/lib/countries/data/translations/countries-ka.yaml +254 -0
- data/lib/countries/data/translations/countries-ki.yaml +254 -0
- data/lib/countries/data/translations/countries-kk.yaml +254 -0
- data/lib/countries/data/translations/countries-kl.yaml +254 -0
- data/lib/countries/data/translations/countries-km.yaml +254 -0
- data/lib/countries/data/translations/countries-kn.yaml +254 -0
- data/lib/countries/data/translations/countries-ko.yaml +254 -0
- data/lib/countries/data/translations/countries-ku.yaml +254 -0
- data/lib/countries/data/translations/countries-kv.yaml +254 -0
- data/lib/countries/data/translations/countries-kw.yaml +254 -0
- data/lib/countries/data/translations/countries-ky.yaml +254 -0
- data/lib/countries/data/translations/countries-lo.yaml +254 -0
- data/lib/countries/data/translations/countries-lt.yaml +254 -0
- data/lib/countries/data/translations/countries-lv.yaml +254 -0
- data/lib/countries/data/translations/countries-mi.yaml +254 -0
- data/lib/countries/data/translations/countries-mk.yaml +254 -0
- data/lib/countries/data/translations/countries-ml.yaml +254 -0
- data/lib/countries/data/translations/countries-mn.yaml +254 -0
- data/lib/countries/data/translations/countries-mr.yaml +254 -0
- data/lib/countries/data/translations/countries-ms.yaml +254 -0
- data/lib/countries/data/translations/countries-mt.yaml +254 -0
- data/lib/countries/data/translations/countries-my.yaml +254 -0
- data/lib/countries/data/translations/countries-na.yaml +254 -0
- data/lib/countries/data/translations/countries-nb.yaml +254 -0
- data/lib/countries/data/translations/countries-ne.yaml +254 -0
- data/lib/countries/data/translations/countries-nl.yaml +254 -0
- data/lib/countries/data/translations/countries-nn.yaml +254 -0
- data/lib/countries/data/translations/countries-nv.yaml +254 -0
- data/lib/countries/data/translations/countries-oc.yaml +254 -0
- data/lib/countries/data/translations/countries-or.yaml +254 -0
- data/lib/countries/data/translations/countries-pa.yaml +254 -0
- data/lib/countries/data/translations/countries-pi.yaml +254 -0
- data/lib/countries/data/translations/countries-pl.yaml +254 -0
- data/lib/countries/data/translations/countries-ps.yaml +254 -0
- data/lib/countries/data/translations/countries-pt.yaml +254 -0
- data/lib/countries/data/translations/countries-pt_BR.yaml +254 -0
- data/lib/countries/data/translations/countries-ro.yaml +254 -0
- data/lib/countries/data/translations/countries-ru.yaml +254 -0
- data/lib/countries/data/translations/countries-rw.yaml +254 -0
- data/lib/countries/data/translations/countries-sc.yaml +254 -0
- data/lib/countries/data/translations/countries-sd.yaml +254 -0
- data/lib/countries/data/translations/countries-si.yaml +254 -0
- data/lib/countries/data/translations/countries-sk.yaml +254 -0
- data/lib/countries/data/translations/countries-sl.yaml +254 -0
- data/lib/countries/data/translations/countries-so.yaml +254 -0
- data/lib/countries/data/translations/countries-sq.yaml +254 -0
- data/lib/countries/data/translations/countries-sr.yaml +254 -0
- data/lib/countries/data/translations/countries-sv.yaml +254 -0
- data/lib/countries/data/translations/countries-sw.yaml +254 -0
- data/lib/countries/data/translations/countries-ta.yaml +254 -0
- data/lib/countries/data/translations/countries-te.yaml +254 -0
- data/lib/countries/data/translations/countries-tg.yaml +254 -0
- data/lib/countries/data/translations/countries-th.yaml +254 -0
- data/lib/countries/data/translations/countries-ti.yaml +254 -0
- data/lib/countries/data/translations/countries-tk.yaml +254 -0
- data/lib/countries/data/translations/countries-tl.yaml +254 -0
- data/lib/countries/data/translations/countries-tr.yaml +254 -0
- data/lib/countries/data/translations/countries-tt.yaml +254 -0
- data/lib/countries/data/translations/countries-ug.yaml +254 -0
- data/lib/countries/data/translations/countries-uk.yaml +254 -0
- data/lib/countries/data/translations/countries-ur.yaml +254 -0
- data/lib/countries/data/translations/countries-uz.yaml +254 -0
- data/lib/countries/data/translations/countries-ve.yaml +254 -0
- data/lib/countries/data/translations/countries-vi.yaml +254 -0
- data/lib/countries/data/translations/countries-wa.yaml +254 -0
- data/lib/countries/data/translations/countries-wo.yaml +254 -0
- data/lib/countries/data/translations/countries-xh.yaml +254 -0
- data/lib/countries/data/translations/countries-yo.yaml +254 -0
- data/lib/countries/data/translations/countries-zh_CN.yaml +254 -0
- data/lib/countries/data/translations/countries-zh_HK.yaml +254 -0
- data/lib/countries/data/translations/countries-zh_TW.yaml +254 -0
- data/lib/countries/data/translations/countries-zu.yaml +254 -0
- data/lib/countries/data.rb +45 -42
- data/lib/countries/global.rb +2 -0
- data/lib/countries/iso3166.rb +3 -1
- data/lib/countries/kwarg_struct.rb +2 -0
- data/lib/countries/mongoid.rb +2 -0
- data/lib/countries/sources/cldr/downloader.rb +8 -8
- data/lib/countries/sources/cldr/subdivision.rb +3 -0
- data/lib/countries/sources/cldr/subdivision_updater.rb +23 -17
- data/lib/countries/sources/local/cached_loader.rb +3 -0
- data/lib/countries/sources/local/subdivision.rb +5 -2
- data/lib/countries/sources.rb +2 -0
- data/lib/countries/structure.rb +1 -1
- data/lib/countries/subdivision.rb +21 -8
- data/lib/countries/tasks/geocoding.rake +15 -6
- data/lib/countries/tasks/postal_codes.rake +5 -3
- data/lib/countries/timezones.rb +5 -2
- data/lib/countries/translations.rb +2 -0
- data/lib/countries/version.rb +3 -1
- data/lib/countries.rb +2 -0
- data/spec/00_global_spec.rb +2 -0
- data/spec/configuration_spec.rb +11 -5
- data/spec/country_spec.rb +131 -38
- data/spec/data_spec.rb +85 -21
- data/spec/mongoid_spec.rb +2 -2
- data/spec/perf_spec.rb +16 -16
- data/spec/spec_helper.rb +2 -0
- data/spec/subdivision_spec.rb +6 -4
- data/spec/thread_safety_spec.rb +4 -3
- data/spec/timezone_spec.rb +2 -0
- metadata +146 -34
- data/lib/countries/cache/locales/zh.json +0 -1
- data/lib/countries/data/subdivisions/AI.yaml +0 -197
- data/lib/countries/data/subdivisions/BM.yaml +0 -155
- data/lib/countries/data/subdivisions/CK.yaml +0 -155
- data/lib/countries/data/subdivisions/EH.yaml +0 -80
- data/lib/countries/data/subdivisions/SJ.yaml +0 -29
- data/lib/countries/data/subdivisions/TK.yaml +0 -43
- data/lib/countries/data/translation_corrections.yaml +0 -51
- data/lib/countries/setup.rb +0 -18
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sixarm_ruby_unaccent'
|
2
4
|
|
3
5
|
module ISO3166
|
4
6
|
UNSEARCHABLE_METHODS = [:translations].freeze
|
5
7
|
|
6
|
-
def self
|
8
|
+
def self.Country(country_data_or_country)
|
7
9
|
case country_data_or_country
|
8
10
|
when ISO3166::Country
|
9
11
|
country_data_or_country
|
@@ -15,9 +17,6 @@ module ISO3166
|
|
15
17
|
end
|
16
18
|
|
17
19
|
module CountryClassMethods
|
18
|
-
FIND_BY_REGEX = /^find_(all_)?(country_|countries_)?by_(.+)/
|
19
|
-
SEARCH_TERM_FILTER_REGEX = /\(|\)|\[\]|,/
|
20
|
-
|
21
20
|
def new(country_data)
|
22
21
|
super if country_data.is_a?(Hash) || codes.include?(country_data.to_s.upcase)
|
23
22
|
end
|
@@ -33,10 +32,6 @@ module ISO3166
|
|
33
32
|
|
34
33
|
alias countries all
|
35
34
|
|
36
|
-
def all_translated(locale = 'en')
|
37
|
-
translations(locale).values
|
38
|
-
end
|
39
|
-
|
40
35
|
def all_names_with_codes(locale = 'en')
|
41
36
|
Country.all.map do |c|
|
42
37
|
lc = (c.translation(locale) || c.iso_short_name)
|
@@ -50,64 +45,23 @@ module ISO3166
|
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
48
|
+
def all_translated(locale = 'en')
|
49
|
+
translations(locale).values
|
50
|
+
end
|
51
|
+
|
53
52
|
def translations(locale = 'en')
|
54
|
-
|
53
|
+
locale = locale.downcase
|
54
|
+
file_path = ISO3166::Data.datafile_path(%W[locales #{locale}.json])
|
55
|
+
translations = JSON.parse(File.read(file_path))
|
55
56
|
|
56
|
-
custom_countries =
|
57
|
+
custom_countries = {}
|
58
|
+
(ISO3166::Data.codes - ISO3166::Data.loaded_codes).each do |code|
|
57
59
|
country = ISO3166::Country[code]
|
58
60
|
translation = country.translations[locale] || country.iso_short_name
|
59
|
-
[code
|
60
|
-
end.to_h
|
61
|
-
|
62
|
-
i18n_data_countries.merge(custom_countries)
|
63
|
-
end
|
64
|
-
|
65
|
-
def search(query)
|
66
|
-
country = new(query.to_s.upcase)
|
67
|
-
country && country.valid? ? country : nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def [](query)
|
71
|
-
search(query)
|
72
|
-
end
|
73
|
-
|
74
|
-
def method_missing(method_name, *arguments)
|
75
|
-
matches = method_name.to_s.match(FIND_BY_REGEX)
|
76
|
-
return_all = matches[1]
|
77
|
-
super unless matches
|
78
|
-
|
79
|
-
if matches[3] == 'names'
|
80
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
81
|
-
warn "DEPRECATION WARNING: 'find_by_name' and 'find_*_by_name' methods are deprecated, please refer to the README file for more information on this change.", uplevel: 1, category: :deprecated
|
82
|
-
else
|
83
|
-
warn "DEPRECATION WARNING: 'find_by_name' and 'find_*_by_name' methods are deprecated, please refer to the README file for more information on this change.", uplevel: 1
|
84
|
-
end
|
61
|
+
custom_countries[code] = translation
|
85
62
|
end
|
86
63
|
|
87
|
-
|
88
|
-
return_all ? countries : countries.last
|
89
|
-
end
|
90
|
-
|
91
|
-
def respond_to_missing?(method_name, include_private = false)
|
92
|
-
matches = method_name.to_s.match(FIND_BY_REGEX)
|
93
|
-
if matches && matches[3]
|
94
|
-
instance_methods.include?(matches[3].to_sym)
|
95
|
-
else
|
96
|
-
super
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def find_all_by(attribute, val)
|
101
|
-
attributes, lookup_value = parse_attributes(attribute, val)
|
102
|
-
|
103
|
-
ISO3166::Data.cache.select do |_, v|
|
104
|
-
country = Country.new(v)
|
105
|
-
attributes.any? do |attr|
|
106
|
-
Array(country.send(attr)).any? do |n|
|
107
|
-
lookup_value === cached(n) { parse_value(n) }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
64
|
+
translations.merge(custom_countries)
|
111
65
|
end
|
112
66
|
|
113
67
|
def subdivisions(alpha2)
|
@@ -117,58 +71,20 @@ module ISO3166
|
|
117
71
|
|
118
72
|
def create_subdivisions(subdivision_data)
|
119
73
|
subdivision_data.each_with_object({}) do |(k, v), hash|
|
120
|
-
|
121
|
-
hash[k] = Subdivision.new(data)
|
74
|
+
hash[k] = Subdivision.new(v)
|
122
75
|
end
|
123
76
|
end
|
124
77
|
|
125
78
|
protected
|
126
79
|
|
127
|
-
def strip_accents(
|
128
|
-
if
|
129
|
-
Regexp.new(
|
80
|
+
def strip_accents(string)
|
81
|
+
if string.is_a?(Regexp)
|
82
|
+
Regexp.new(string.source.unaccent, 'i')
|
130
83
|
else
|
131
|
-
|
84
|
+
string.to_s.unaccent.downcase
|
132
85
|
end
|
133
86
|
end
|
134
87
|
|
135
|
-
def parse_attributes(attribute, val)
|
136
|
-
raise "Invalid attribute name '#{attribute}'" unless searchable_attribute?(attribute.to_sym)
|
137
|
-
|
138
|
-
attributes = Array(attribute.to_s)
|
139
|
-
if attribute.to_s == 'name'
|
140
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
141
|
-
warn "DEPRECATION WARNING: 'find_by_name' and 'find_*_by_name' methods are deprecated, please refer to the README file for more information on this change.", uplevel: 1, category: :deprecated
|
142
|
-
else
|
143
|
-
warn "DEPRECATION WARNING: 'find_by_name' and 'find_*_by_name' methods are deprecated, please refer to the README file for more information on this change.", uplevel: 1
|
144
|
-
end
|
145
|
-
# 'find_by_name' and 'find_*_by_name' will be changed for 5.0
|
146
|
-
# The addition of 'iso_short_name' here ensures the behaviour of 4.1 is kept for 4.2
|
147
|
-
attributes = %w[iso_short_name unofficial_names translated_names]
|
148
|
-
end
|
149
|
-
|
150
|
-
[attributes, parse_value(val)]
|
151
|
-
end
|
152
|
-
|
153
|
-
def searchable_attribute?(attribute)
|
154
|
-
searchable_attributes.include?(attribute.to_sym)
|
155
|
-
end
|
156
|
-
|
157
|
-
def searchable_attributes
|
158
|
-
instance_methods - UNSEARCHABLE_METHODS
|
159
|
-
end
|
160
|
-
|
161
|
-
def find_by(attribute, value, obj = nil)
|
162
|
-
find_all_by(attribute.downcase, value).map do |country|
|
163
|
-
obj.nil? ? country : new(country.last)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def parse_value(value)
|
168
|
-
value = value.gsub(SEARCH_TERM_FILTER_REGEX, '') if value.respond_to?(:gsub)
|
169
|
-
strip_accents(value)
|
170
|
-
end
|
171
|
-
|
172
88
|
def subdivision_data(alpha2)
|
173
89
|
file = subdivision_file_path(alpha2)
|
174
90
|
File.exist?(file) ? YAML.load_file(file) : {}
|
@@ -190,6 +106,7 @@ module ISO3166
|
|
190
106
|
def cached(value)
|
191
107
|
@_parsed_values_cache ||= {}
|
192
108
|
return @_parsed_values_cache[value] if @_parsed_values_cache[value]
|
109
|
+
|
193
110
|
@_parsed_values_cache[value] = yield
|
194
111
|
end
|
195
112
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
# encoding: utf-8
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module ISO3166
|
5
4
|
module Emoji
|
@@ -36,7 +35,7 @@ module ISO3166
|
|
36
35
|
#
|
37
36
|
# The emoji flag for this country, using Unicode Regional Indicator characters. e.g: "U+1F1FA U+1F1F8" for 🇺🇸
|
38
37
|
def emoji_flag
|
39
|
-
alpha2.downcase.chars.map { |c| CODE_POINTS[c] }.join
|
38
|
+
alpha2.downcase.chars.map { |c| CODE_POINTS[c] }.join
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ISO3166
|
4
|
+
module CountryFinderMethods
|
5
|
+
FIND_BY_REGEX = /^find_(all_)?(country_|countries_)?by_(.+)/.freeze
|
6
|
+
SEARCH_TERM_FILTER_REGEX = /\(|\)|\[\]|,/.freeze
|
7
|
+
|
8
|
+
def search(query)
|
9
|
+
country = new(query.to_s.upcase)
|
10
|
+
country&.valid? ? country : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](query)
|
14
|
+
search(query)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_all_by(attribute, val)
|
18
|
+
attributes, lookup_value = parse_attributes(attribute, val)
|
19
|
+
|
20
|
+
ISO3166::Data.cache.select do |_, v|
|
21
|
+
country = Country.new(v)
|
22
|
+
attributes.any? do |attr|
|
23
|
+
Array(country.send(attr)).any? do |n|
|
24
|
+
lookup_value === cached(n) { parse_value(n) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def method_missing(method_name, *arguments)
|
31
|
+
matches = method_name.to_s.match(FIND_BY_REGEX)
|
32
|
+
return_all = matches[1]
|
33
|
+
super unless matches
|
34
|
+
|
35
|
+
countries = find_by(matches[3], arguments[0], matches[2])
|
36
|
+
return_all ? countries : countries.last
|
37
|
+
end
|
38
|
+
|
39
|
+
def respond_to_missing?(method_name, include_private = false)
|
40
|
+
matches = method_name.to_s.match(FIND_BY_REGEX)
|
41
|
+
if matches && matches[3]
|
42
|
+
instance_methods.include?(matches[3].to_sym)
|
43
|
+
else
|
44
|
+
super
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def find_by(attribute, value, obj = nil)
|
51
|
+
find_all_by(attribute.downcase, value).map do |country|
|
52
|
+
obj.nil? ? country : new(country.last)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_attributes(attribute, val)
|
57
|
+
raise "Invalid attribute name '#{attribute}'" unless searchable_attribute?(attribute.to_sym)
|
58
|
+
|
59
|
+
attributes = Array(attribute.to_s)
|
60
|
+
if attribute.to_s == 'any_name'
|
61
|
+
attributes = %w[iso_long_name iso_short_name unofficial_names translated_names]
|
62
|
+
end
|
63
|
+
|
64
|
+
[attributes, parse_value(val)]
|
65
|
+
end
|
66
|
+
|
67
|
+
def parse_value(value)
|
68
|
+
value = value.gsub(SEARCH_TERM_FILTER_REGEX, '') if value.respond_to?(:gsub)
|
69
|
+
strip_accents(value)
|
70
|
+
end
|
71
|
+
|
72
|
+
def searchable_attribute?(attribute)
|
73
|
+
searchable_attributes.include?(attribute.to_sym)
|
74
|
+
end
|
75
|
+
|
76
|
+
def searchable_attributes
|
77
|
+
# Add name and names until we complete the deprecation of the finders
|
78
|
+
instance_methods - UNSEARCHABLE_METHODS + [:name, :names, :any_name]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/countries/country.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ISO3166
|
2
4
|
class Country
|
3
5
|
extend CountryClassMethods
|
6
|
+
extend CountryFinderMethods
|
4
7
|
include Emoji
|
5
8
|
attr_reader :data
|
6
9
|
|
@@ -31,24 +34,6 @@ module ISO3166
|
|
31
34
|
alias zip_format postal_code_format
|
32
35
|
alias languages languages_official
|
33
36
|
|
34
|
-
def latitude_dec
|
35
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
36
|
-
warn "DEPRECATION WARNING: The Country#latitude_dec method has been deprecated and will be removed in 5.0. Please use Country#latitude instead.", uplevel: 1, category: :deprecated
|
37
|
-
else
|
38
|
-
warn "DEPRECATION WARNING: The Country#latitude_dec method has been deprecated and will be removed in 5.0. Please use Country#latitude instead.", uplevel: 1
|
39
|
-
end
|
40
|
-
latitude
|
41
|
-
end
|
42
|
-
|
43
|
-
def longitude_dec
|
44
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
45
|
-
warn "DEPRECATION WARNING: The Country#longitude_dec method has been deprecated and will be removed in 5.0. Please use Country#longitude instead.", uplevel: 1, category: :deprecated
|
46
|
-
else
|
47
|
-
warn "DEPRECATION WARNING: The Country#longitude_dec method has been deprecated and will be removed in 5.0. Please use Country#longitude instead.", uplevel: 1
|
48
|
-
end
|
49
|
-
longitude
|
50
|
-
end
|
51
|
-
|
52
37
|
def ==(other)
|
53
38
|
other.respond_to?(:alpha2) && other.alpha2 == alpha2
|
54
39
|
end
|
@@ -79,13 +64,41 @@ module ISO3166
|
|
79
64
|
end
|
80
65
|
end
|
81
66
|
|
67
|
+
# @param types [Array<String>] The locale to use for translations.
|
68
|
+
# @return [Array<ISO3166::Subdivision>] the list of subdivisions of the given type(s) for this Country.
|
69
|
+
def subdivisions_of_types(types)
|
70
|
+
subdivisions.select{|k,v| types.include?(v.type)}
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [Array<String>] the list of subdivision types for this country
|
74
|
+
def subdivision_types
|
75
|
+
subdivisions.map{|k,v| v['type']}.uniq
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [Array<String>] the list of humanized subdivision types for this country. Uses ActiveSupport's `#humanize` if available
|
79
|
+
def humanized_subdivision_types
|
80
|
+
if String.instance_methods.include?(:humanize)
|
81
|
+
subdivisions.map{|k,v| v['type'].humanize}.uniq
|
82
|
+
else
|
83
|
+
subdivisions.map{|k,v| v['type'][0].upcase + v['type'].tr('_', ' ')[1..-1]}.uniq
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
82
87
|
# @param locale [String] The locale to use for translations.
|
83
88
|
# @return [Array<Array>] This Country's subdivision pairs of names and codes.
|
84
89
|
def subdivision_names_with_codes(locale = 'en')
|
85
90
|
subdivisions.map { |k, v| [v.translations[locale] || v.name, k] }
|
86
91
|
end
|
87
92
|
|
88
|
-
|
93
|
+
def states
|
94
|
+
if RUBY_VERSION =~ /^3\.\d\.\d/
|
95
|
+
warn "DEPRECATION WARNING: The Country#states method has been deprecated and will be removed in 6.0. Please use Country#subdivisions instead.", uplevel: 1, category: :deprecated
|
96
|
+
else
|
97
|
+
warn "DEPRECATION WARNING: The Country#states method has been deprecated and will be removed in 6.0. Please use Country#subdivisions instead.", uplevel: 1
|
98
|
+
end
|
99
|
+
|
100
|
+
subdivisions
|
101
|
+
end
|
89
102
|
|
90
103
|
# +true+ if this country is a member of the European Union.
|
91
104
|
def in_eu?
|
@@ -136,28 +149,6 @@ module ISO3166
|
|
136
149
|
@local_name ||= local_names.first
|
137
150
|
end
|
138
151
|
|
139
|
-
# @return [String] This Country's ISO Short Name
|
140
|
-
# @deprecated Use {#iso_short_name} instead.
|
141
|
-
def name
|
142
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
143
|
-
warn "DEPRECATION WARNING: The Country#name method has been deprecated. Please use Country#iso_short_name instead or refer to the README file for more information on this change.", uplevel: 1, category: :deprecated
|
144
|
-
else
|
145
|
-
warn "DEPRECATION WARNING: The Country#name method has been deprecated. Please use Country#iso_short_name instead or refer to the README file for more information on this change.", uplevel: 1
|
146
|
-
end
|
147
|
-
iso_short_name
|
148
|
-
end
|
149
|
-
|
150
|
-
# @return [Array<String>] Array of unofficial, slang names or aliases for this Country
|
151
|
-
# @deprecated Use {#unofficial_names} instead.
|
152
|
-
def names
|
153
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
154
|
-
warn "DEPRECATION WARNING: The Country#names method has been deprecated. Please use Country#unofficial_names instead or refer to the README file for more information on this change.", uplevel: 1, category: :deprecated
|
155
|
-
else
|
156
|
-
warn "DEPRECATION WARNING: The Country#names method has been deprecated. Please use Country#unofficial_names instead or refer to the README file for more information on this change.", uplevel: 1
|
157
|
-
end
|
158
|
-
unofficial_names
|
159
|
-
end
|
160
|
-
|
161
152
|
# @!attribute alpha2
|
162
153
|
# @return [String] the ISO3166 alpha-2 code for this Country
|
163
154
|
#
|
@@ -242,8 +233,6 @@ module ISO3166
|
|
242
233
|
# @!attribute world_region
|
243
234
|
# @return [String] The "World Region" this country is in: +"AMER"+ , +"APAC"+ or +"EMEA"+
|
244
235
|
|
245
|
-
|
246
|
-
|
247
236
|
private
|
248
237
|
|
249
238
|
def reload
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
'02':
|
3
3
|
name: Canillo
|
4
|
-
code:
|
4
|
+
code: '02'
|
5
5
|
unofficial_names: Canillo
|
6
6
|
geo:
|
7
7
|
latitude: 42.5666535
|
@@ -13,9 +13,10 @@
|
|
13
13
|
translations:
|
14
14
|
en: Canillo
|
15
15
|
comments:
|
16
|
+
type: parish
|
16
17
|
'03':
|
17
18
|
name: Encamp
|
18
|
-
code:
|
19
|
+
code: '03'
|
19
20
|
unofficial_names: Encamp
|
20
21
|
geo:
|
21
22
|
latitude: 42.5362652
|
@@ -27,9 +28,10 @@
|
|
27
28
|
translations:
|
28
29
|
en: Encamp
|
29
30
|
comments:
|
31
|
+
type: parish
|
30
32
|
'04':
|
31
33
|
name: La Massana
|
32
|
-
code:
|
34
|
+
code: '04'
|
33
35
|
unofficial_names: La Massana
|
34
36
|
geo:
|
35
37
|
latitude: 42.545625
|
@@ -41,9 +43,10 @@
|
|
41
43
|
translations:
|
42
44
|
en: La Massana
|
43
45
|
comments:
|
46
|
+
type: parish
|
44
47
|
'05':
|
45
48
|
name: Ordino
|
46
|
-
code:
|
49
|
+
code: '05'
|
47
50
|
unofficial_names: Ordino
|
48
51
|
geo:
|
49
52
|
latitude: 42.5556547
|
@@ -55,9 +58,10 @@
|
|
55
58
|
translations:
|
56
59
|
en: Ordino
|
57
60
|
comments:
|
61
|
+
type: parish
|
58
62
|
'06':
|
59
63
|
name: Sant Julià de Lòria
|
60
|
-
code:
|
64
|
+
code: '06'
|
61
65
|
unofficial_names:
|
62
66
|
- Saint Julia de Loria
|
63
67
|
geo:
|
@@ -70,9 +74,10 @@
|
|
70
74
|
translations:
|
71
75
|
en: Sant Julià de Lòria
|
72
76
|
comments:
|
77
|
+
type: parish
|
73
78
|
'07':
|
74
79
|
name: Andorra la Vella
|
75
|
-
code:
|
80
|
+
code: '07'
|
76
81
|
unofficial_names:
|
77
82
|
- Andorra la Vieja
|
78
83
|
- Andorre-la-Vieille
|
@@ -86,9 +91,10 @@
|
|
86
91
|
translations:
|
87
92
|
en: Andorra la Vella
|
88
93
|
comments:
|
94
|
+
type: parish
|
89
95
|
'08':
|
90
96
|
name: Escaldes-Engordany
|
91
|
-
code:
|
97
|
+
code: '08'
|
92
98
|
unofficial_names:
|
93
99
|
- Les Escaldes
|
94
100
|
geo:
|
@@ -101,3 +107,4 @@
|
|
101
107
|
translations:
|
102
108
|
en: Escaldes-Engordany
|
103
109
|
comments:
|
110
|
+
type: parish
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
AJ:
|
3
3
|
name: "'Ajmān"
|
4
|
-
code:
|
4
|
+
code: AJ
|
5
5
|
unofficial_names: "-إمارة عجمانّ - Ujman"
|
6
6
|
geo:
|
7
7
|
latitude: 25.3995
|
@@ -74,9 +74,10 @@ AJ:
|
|
74
74
|
'no': Emiratet Ajman
|
75
75
|
yo_BJ: Ajman
|
76
76
|
comments:
|
77
|
+
type: emirate
|
77
78
|
AZ:
|
78
79
|
name: Abū Z̧aby [Abu Dhabi]
|
79
|
-
code:
|
80
|
+
code: AZ
|
80
81
|
unofficial_names:
|
81
82
|
- أبو ظبي
|
82
83
|
- Abu Zabi
|
@@ -157,9 +158,10 @@ AZ:
|
|
157
158
|
mk: Абу Даби
|
158
159
|
'no': Emiratet Abu Dhabi
|
159
160
|
comments:
|
161
|
+
type: emirate
|
160
162
|
DU:
|
161
163
|
name: Dubayy
|
162
|
-
code:
|
164
|
+
code: DU
|
163
165
|
unofficial_names:
|
164
166
|
- دبي
|
165
167
|
- Dubai
|
@@ -232,9 +234,10 @@ DU:
|
|
232
234
|
bs: Dubai
|
233
235
|
'no': Emiratet Dubai
|
234
236
|
comments:
|
237
|
+
type: emirate
|
235
238
|
FU:
|
236
239
|
name: Al Fujayrah
|
237
|
-
code:
|
240
|
+
code: FU
|
238
241
|
unofficial_names:
|
239
242
|
- الفجيرة
|
240
243
|
- Al Fujayrah
|
@@ -309,9 +312,10 @@ FU:
|
|
309
312
|
'no': Emiratet Fujairah
|
310
313
|
yo_BJ: Fujairah
|
311
314
|
comments:
|
315
|
+
type: emirate
|
312
316
|
RK:
|
313
317
|
name: Ra's al Khaymah
|
314
|
-
code:
|
318
|
+
code: RK
|
315
319
|
unofficial_names:
|
316
320
|
- إمارة رأس الخيمة
|
317
321
|
- Ras al-Khaimah
|
@@ -385,9 +389,10 @@ RK:
|
|
385
389
|
'no': Emiratet Ras al-Khaimah
|
386
390
|
yo_BJ: Ras al Khaimah
|
387
391
|
comments:
|
392
|
+
type: emirate
|
388
393
|
SH:
|
389
394
|
name: Ash Shariqah [Sharjah]
|
390
|
-
code:
|
395
|
+
code: SH
|
391
396
|
unofficial_names:
|
392
397
|
- إمارة الشارقةّ
|
393
398
|
- Ash Shariqah
|
@@ -462,9 +467,10 @@ SH:
|
|
462
467
|
'no': Emiratet Sharjah
|
463
468
|
yo_BJ: Sharjah
|
464
469
|
comments:
|
470
|
+
type: emirate
|
465
471
|
UQ:
|
466
472
|
name: Umm al Qaywayn
|
467
|
-
code:
|
473
|
+
code: UQ
|
468
474
|
unofficial_names:
|
469
475
|
- أمّ القيوين
|
470
476
|
- Umm al-Quwain
|
@@ -537,3 +543,4 @@ UQ:
|
|
537
543
|
'no': Emiratet Umm al-Qaiwain
|
538
544
|
yo_BJ: Um Al Quwain
|
539
545
|
comments:
|
546
|
+
type: emirate
|