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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73f88c0991bcb5bf2b2d08014ae66f04adb368b856d1cd084928549b282e7b33
|
4
|
+
data.tar.gz: f2edba4b8014c85a4e5c263635bbb04d1f8b03d11a91814d08e009705f94e0d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ebd72d36cd13b11979325ef5f69535c6a3665a2763ca8920570e13d93feae05fd4e319698207f44d89fecb29daf3db5f56c875705d0e65d9c7c4560a84b75ee
|
7
|
+
data.tar.gz: 69d70fdc81b89ffcc128931ead30b874e1d24660e2a9db59d120f6ad46cdec7a6657823abc5abe8ee107564b7cb52d49f38fc05800cdd0704ea8eebe9f12fb7a
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
2
|
+
# to commit it to your repository.
|
3
|
+
#
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
+
# or to provide custom queries or build logic.
|
6
|
+
#
|
7
|
+
# ******** NOTE ********
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
+
# supported CodeQL languages.
|
11
|
+
#
|
12
|
+
name: "CodeQL"
|
13
|
+
|
14
|
+
on:
|
15
|
+
push:
|
16
|
+
branches: [ master ]
|
17
|
+
pull_request:
|
18
|
+
# The branches below must be a subset of the branches above
|
19
|
+
branches: [ master ]
|
20
|
+
schedule:
|
21
|
+
- cron: '19 13 * * 5'
|
22
|
+
|
23
|
+
jobs:
|
24
|
+
analyze:
|
25
|
+
name: Analyze
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
permissions:
|
28
|
+
actions: read
|
29
|
+
contents: read
|
30
|
+
security-events: write
|
31
|
+
|
32
|
+
strategy:
|
33
|
+
fail-fast: false
|
34
|
+
matrix:
|
35
|
+
language: [ 'ruby' ]
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
38
|
+
|
39
|
+
steps:
|
40
|
+
- name: Checkout repository
|
41
|
+
uses: actions/checkout@v3
|
42
|
+
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
44
|
+
- name: Initialize CodeQL
|
45
|
+
uses: github/codeql-action/init@v1
|
46
|
+
with:
|
47
|
+
languages: ${{ matrix.language }}
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
52
|
+
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
55
|
+
- name: Autobuild
|
56
|
+
uses: github/codeql-action/autobuild@v1
|
57
|
+
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
59
|
+
# 📚 https://git.io/JvXDl
|
60
|
+
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
62
|
+
# and modify them (or add more) to build your code if your project
|
63
|
+
# uses a compiled language
|
64
|
+
|
65
|
+
#- run: |
|
66
|
+
# make bootstrap
|
67
|
+
# make release
|
68
|
+
|
69
|
+
- name: Perform CodeQL Analysis
|
70
|
+
uses: github/codeql-action/analyze@v1
|
data/.github/workflows/tests.yml
CHANGED
@@ -15,15 +15,11 @@ jobs:
|
|
15
15
|
strategy:
|
16
16
|
matrix:
|
17
17
|
include:
|
18
|
-
- ruby-version: 2.
|
18
|
+
- ruby-version: 2.7.6
|
19
19
|
bundler-version: default
|
20
|
-
- ruby-version:
|
20
|
+
- ruby-version: 3.0.4
|
21
21
|
bundler-version: default
|
22
|
-
- ruby-version:
|
23
|
-
bundler-version: default
|
24
|
-
- ruby-version: 3.0.3
|
25
|
-
bundler-version: default
|
26
|
-
- ruby-version: 3.1.0
|
22
|
+
- ruby-version: 3.1.2
|
27
23
|
bundler-version: default
|
28
24
|
steps:
|
29
25
|
- uses: actions/checkout@v2
|
data/.rubocop.yml
CHANGED
@@ -1 +1,40 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
NewCops: enable
|
5
|
+
|
6
|
+
Layout/LineLength:
|
7
|
+
Exclude:
|
8
|
+
- countries.gemspec
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*'
|
13
|
+
- Rakefile
|
14
|
+
- 'spec/**/*'
|
15
|
+
- 'lib/countries/tasks/*'
|
16
|
+
|
17
|
+
Style/RescueModifier:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Style/CaseEquality:
|
21
|
+
Exclude:
|
22
|
+
- 'lib/countries/country/finder_methods.rb'
|
23
|
+
|
24
|
+
Style/IfUnlessModifier:
|
25
|
+
Exclude:
|
26
|
+
- 'spec/thread_safety_spec.rb'
|
27
|
+
|
28
|
+
Naming/MethodName:
|
29
|
+
Exclude:
|
30
|
+
- 'lib/countries/country/class_methods.rb'
|
31
|
+
|
32
|
+
Lint/AmbiguousBlockAssociation:
|
33
|
+
Exclude:
|
34
|
+
- 'spec/perf_spec.rb'
|
35
|
+
|
36
|
+
Metrics/MethodLength:
|
37
|
+
Max: 20
|
38
|
+
|
39
|
+
Metrics/ClassLength:
|
40
|
+
Max: 130
|
data/.rubocop_todo.yml
CHANGED
@@ -1,52 +1,19 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2022-01-07 11:03:11 UTC using RuboCop version 1.24.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
# Offense count: 1
|
9
|
-
# Configuration parameters: CountComments.
|
10
|
-
Metrics/ClassLength:
|
11
|
-
Max: 101
|
12
8
|
|
13
|
-
# Offense count: 64
|
14
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
15
|
-
# URISchemes: http, https
|
16
|
-
Metrics/LineLength:
|
17
|
-
Max: 483
|
18
9
|
|
19
|
-
# Offense count:
|
10
|
+
# Offense count: 3
|
11
|
+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
20
12
|
Metrics/AbcSize:
|
21
|
-
Max:
|
13
|
+
Max: 33
|
22
14
|
|
23
|
-
#
|
24
|
-
Style/CaseEquality:
|
25
|
-
Exclude:
|
26
|
-
- 'lib/countries/country/class_methods.rb'
|
27
|
-
|
28
|
-
# Offense count: 7
|
29
|
-
Style/ClassVars:
|
30
|
-
Exclude:
|
31
|
-
- 'lib/countries/data.rb'
|
32
|
-
|
33
|
-
# Offense count: 9
|
15
|
+
# Enable after the doc branch is merged
|
34
16
|
Style/Documentation:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
- 'lib/countries/configuration.rb'
|
39
|
-
- 'lib/countries/country.rb'
|
40
|
-
- 'lib/countries/country/class_methods.rb'
|
41
|
-
- 'lib/countries/country/emoji.rb'
|
42
|
-
- 'lib/countries/global.rb'
|
43
|
-
- 'lib/countries/kwarg_struct.rb'
|
44
|
-
- 'lib/countries/mongoid.rb'
|
45
|
-
|
46
|
-
|
47
|
-
# Offense count: 1
|
48
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
49
|
-
# SupportedStyles: snake_case, camelCase
|
50
|
-
Style/MethodName:
|
51
|
-
Exclude:
|
52
|
-
- 'lib/countries/country/class_methods.rb'
|
17
|
+
Enabled: false
|
18
|
+
# Exclude:
|
19
|
+
# - 'spec/**/*'
|
data/CHANGELOG.md
CHANGED
@@ -3,12 +3,45 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
5
5
|
|
6
|
-
## [
|
6
|
+
## [5.1.0](https://github.com/countries/countries/releases/tag/v5.1.0') (2022/06/27 07:50 +00:00)
|
7
|
+
|
8
|
+
**Important changes**
|
9
|
+
- `Subdivision` now has a `type` attribute obtained from ISO3166-2 subdivision types. `type` is a _lowercase_ and _snake_cased_ string.
|
10
|
+
- Adds `Country#subdivision_types` and `#humanized_subdivision_types` to list a country's subdivision types
|
11
|
+
- Adds `Country#subdivisions_of_types(types)` to allow getting subdivisions of given type(s)
|
12
|
+
- `Country#states` is now deprecated to avoid confusion (this method was just an alias to `#subdivisions` and retuns all subdivisions, regarless of type)
|
13
|
+
|
14
|
+
**Merged pull requests:**
|
15
|
+
|
16
|
+
* Remove i18n_data dependency [\#755](https://github.com/countries/countries/pull/755) ([pmor](https://github.com/pmor))
|
17
|
+
* Update subdivision YAML with codes [\#757](https://github.com/countries/countries/pull/757) ([pmor](https://github.com/pmor))
|
18
|
+
* Add subdivision types from ISO3166-2 [\#758](https://github.com/countries/countries/pull/758) ([pmor](https://github.com/pmor))
|
19
|
+
|
20
|
+
## [5.0.2](https://github.com/countries/countries/releases/tag/v5.0.2') (2022/06/02 20:01 +00:00)
|
21
|
+
|
22
|
+
**Merged pull requests:**
|
23
|
+
|
24
|
+
* Fix common name for IR [\#754](https://github.com/countries/countries/pull/754) ([pmor](https://github.com/pmor))
|
25
|
+
* Update MX subdivisions: Remove DIF and update some unofficial names [\#755](https://github.com/countries/countries/pull/755) ([pmor](https://github.com/pmor))
|
26
|
+
|
27
|
+
## [5.0.1](https://github.com/countries/countries/releases/tag/v5.0.1') (2022/05/02 12:03 +00:00)
|
28
|
+
|
29
|
+
**Merged pull requests:**
|
30
|
+
|
31
|
+
* Added subdivision_names_with_codes method in documentation [\#747](https://github.com/countries/countries/pull/747) ([arymoraes](https://github.com/arymoraes))
|
32
|
+
* Corrected Portuguese subdivision names [\#748](https://github.com/countries/countries/pull/748) ([FilipaDurao](https://github.com/FilipaDurao))
|
33
|
+
|
34
|
+
## [5.0.0](https://github.com/countries/countries/releases/tag/v5.0.0') (2022/04/03 17:44 +00:00)
|
7
35
|
|
8
36
|
**Breaking Changes**
|
9
37
|
|
10
|
-
- Drop support for Ruby 2.5 and 2.6
|
38
|
+
- Drop support for Ruby 2.5 and 2.6. (EOL in 2021-03-31 and 2022-03-31, respectively)
|
39
|
+
- Remove deprecated attributes and add new `#find_by_any_name` finder, see https://github.com/countries/countries#upgrading-to-42-and-5x for details
|
40
|
+
|
41
|
+
**Merged pull requests:**
|
11
42
|
|
43
|
+
- Drop support for Ruby 2.5 and 2.6 [\#708](https://github.com/countries/countries/pull/708) ([pmor](https://github.com/pmor))
|
44
|
+
- Remove deprecated attributes; Add new `#find_by_any_name` finder [\#745](https://github.com/countries/countries/pull/708) ([pmor](https://github.com/pmor))
|
12
45
|
|
13
46
|
## [4.2.3](https://github.com/countries/countries/releases/tag/v4.2.2) (2022/03/24 11:00 +00:00)
|
14
47
|
|
data/Gemfile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
|
-
gem 'rake'
|
3
4
|
gem 'geocoder'
|
5
|
+
gem 'money'
|
6
|
+
gem 'rake'
|
4
7
|
gem 'retryable'
|
5
8
|
gem 'tzinfo'
|
6
|
-
gem 'money'
|
7
9
|
|
8
10
|
# Specify your gem's dependencies in countries.gemspec
|
9
11
|
gemspec
|
@@ -11,4 +13,4 @@ gemspec
|
|
11
13
|
group :development, :test do
|
12
14
|
gem 'pry'
|
13
15
|
gem 'yaml'
|
14
|
-
end
|
16
|
+
end
|
data/README.markdown
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
Countries is a collection of all sorts of useful information for every country in the ISO 3166 standard. It contains info for the following standards ISO3166-1 (countries), ISO3166-2 (states/subdivisions), ISO4217 (currency) and E.164 (phone numbers). I will add any country based data I can get access to. I hope this to be a repository for all country based information.
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/countries.svg)](https://badge.fury.io/rb/countries) [![Tests](https://github.com/countries/countries/actions/workflows/tests.yml/badge.svg)](https://github.com/countries/countries/actions/workflows/tests.yml) [![Code Climate](https://codeclimate.com/github/countries/countries.svg)](https://codeclimate.com/github/countries/countries)
|
6
|
+
[![CodeQL](https://github.com/countries/countries/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/countries/countries/actions/workflows/codeql-analysis.yml)
|
7
|
+
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -46,53 +48,28 @@ gem 'countries', require: 'countries/global'
|
|
46
48
|
|
47
49
|
## Upgrading to 4.2 and 5.x
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
"Common names" in English have been available in the translation data, via `#translation('en')`. As of release 4.2, a shortcut method has been added for simplicity, `#common_name`, which delegates to `#translation('en')`.
|
52
|
-
|
53
|
-
For additional clarity, the `#names` method, which was an alias to `#unofficial_names` has also been deprecated, together with the finder methods that use `name` or `names` attributes.
|
54
|
-
|
55
|
-
The `#name` and `#names` attributes, and corresponding finder methods will be removed in 5.0.
|
56
|
-
|
57
|
-
For translated country names, we use data from [pkg-isocodes](https://salsa.debian.org/iso-codes-team/iso-codes), via the [i18n_data](https://github.com/grosser/i18n_data) gem, and these generally correspond to the expected "common names". These names and the corresponding methods have not been changed.
|
58
|
-
|
59
|
-
## Selective Loading of Locales
|
60
|
-
|
61
|
-
As of 2.0 you can selectively load locales to reduce memory usage in production.
|
62
|
-
|
63
|
-
By default we load `I18n.available_locales` if I18n is present, otherwise only `[:en]`. This means almost any Rails environment will only bring in its supported translations.
|
51
|
+
Release 4.2.0 introduced changes to name attributes and finders and deprecated several methods to resolve some existing confusion regardign official ISO country names vs. the "common names" that are commonly used.
|
64
52
|
|
65
|
-
|
53
|
+
The 5.0 release removed these deprecated methods and also removed support for Ruby 2.5 and 2.6
|
66
54
|
|
67
|
-
|
68
|
-
ISO3166.configure do |config|
|
69
|
-
config.locales = [:af, :am, :ar, :as, :az, :be, :bg, :bn, :br, :bs, :ca, :cs, :cy, :da, :de, :dz, :el, :en, :eo, :es, :et, :eu, :fa, :fi, :fo, :fr, :ga, :gl, :gu, :he, :hi, :hr, :hu, :hy, :ia, :id, :is, :it, :ja, :ka, :kk, :km, :kn, :ko, :ku, :lt, :lv, :mi, :mk, :ml, :mn, :mr, :ms, :mt, :nb, :ne, :nl, :nn, :oc, :or, :pa, :pl, :ps, :pt, :ro, :ru, :rw, :si, :sk, :sl, :so, :sq, :sr, :sv, :sw, :ta, :te, :th, :ti, :tk, :tl, :tr, :tt, :ug, :uk, :ve, :vi, :wa, :wo, :xh, :zh, :zu]
|
70
|
-
end
|
71
|
-
```
|
72
|
-
|
73
|
-
or something a bit more simple
|
74
|
-
```ruby
|
75
|
-
ISO3166.configure do |config|
|
76
|
-
config.locales = [:en, :de, :fr, :es]
|
77
|
-
end
|
78
|
-
```
|
55
|
+
Plase see [UPGRADE.md](../master/UPGRADE.md) for more information
|
79
56
|
|
80
57
|
## Attribute-Based Finder Methods
|
81
58
|
|
82
59
|
You can lookup a country or an array of countries using any of the data attributes via the find\_country\_by_*attribute* dynamic methods:
|
83
60
|
|
84
61
|
```ruby
|
85
|
-
c = ISO3166::Country.find_country_by_iso_short_name('
|
62
|
+
c = ISO3166::Country.find_country_by_iso_short_name('italy')
|
63
|
+
c = ISO3166::Country.find_country_by_any_name('united states')
|
86
64
|
h = ISO3166::Country.find_all_by(:translated_names, 'França')
|
87
65
|
list = ISO3166::Country.find_all_countries_by_region('Americas')
|
88
|
-
c = ISO3166::Country.
|
66
|
+
c = ISO3166::Country.find_country_by_alpha2("FR")
|
89
67
|
```
|
90
68
|
|
91
69
|
For a list of available attributes please see `ISO3166::DEFAULT_COUNTRY_HASH`.
|
92
70
|
Note: searches are *case insensitive and ignore accents*.
|
93
71
|
|
94
|
-
_Please note that `find_by_name`, `find_by_names`, `find_*_by_name` and `find_*_by_names` methods
|
95
|
-
|
72
|
+
_Please note that `find_by_name`, `find_by_names`, `find_*_by_name` and `find_*_by_names` methods were removed in 5.0. See [UPGRADE.md](../blob/master/UPGRADE.md) for more information_
|
96
73
|
|
97
74
|
## Country Info
|
98
75
|
|
@@ -122,10 +99,11 @@ c.local_name # => "België"
|
|
122
99
|
c.translation('de') # => 'Vereinigte Staaten von Amerika'
|
123
100
|
c.translations['fr'] # => "États-Unis"
|
124
101
|
|
102
|
+
# Get all translations for a locale, defaults to 'en'
|
125
103
|
ISO3166::Country.translations # {"DE"=>"Germany",...}
|
126
|
-
ISO3166::Country.translations('
|
104
|
+
ISO3166::Country.translations('de') # {"DE"=>"Deutschland",...}
|
127
105
|
ISO3166::Country.all_translated # ['Germany', ...]
|
128
|
-
ISO3166::Country.all_translated('
|
106
|
+
ISO3166::Country.all_translated('de') # ['Deutschland', ...]
|
129
107
|
|
130
108
|
# Nationality
|
131
109
|
c.nationality # => "American"
|
@@ -135,7 +113,16 @@ c.nationality # => "American"
|
|
135
113
|
|
136
114
|
```ruby
|
137
115
|
c.subdivisions # => {"CO" => {"name" => "Colorado", "names" => "Colorado"}, ... }
|
116
|
+
c.subdivision_types # => ["state", "outlying_area", "district"]
|
117
|
+
c.subdivisions_of_types(['state']) # => {"CO" => {"name" => "Colorado", "names" => "Colorado"}, ... }
|
118
|
+
c.humanized_subdivision_types # => ["State", "Outlying area", "District"]
|
119
|
+
|
120
|
+
# This is now deprecated. #states is an alias of #subdivisions and returns all subdivisions regardless of type
|
138
121
|
c.states # => {"CO" => {"name" => "Colorado", "names" => "Colorado"}, ... }
|
122
|
+
|
123
|
+
|
124
|
+
# Get specific translations for the country subdivisions
|
125
|
+
c.subdivision_names_with_codes('es') #=> [ ..., ["Nuevo Hampshire", "NH"], ["Nueva Jersey", "NJ"], ... ]
|
139
126
|
```
|
140
127
|
|
141
128
|
### Location
|
@@ -149,7 +136,7 @@ c.region # => "Americas"
|
|
149
136
|
c.subregion # => "Northern America"
|
150
137
|
```
|
151
138
|
|
152
|
-
Please note that `latitude_dec` and `longitude_dec`
|
139
|
+
Please note that `latitude_dec` and `longitude_dec` were deprecated on release 4.2 and removed in 5.0. These attributes have been redundant for several years, since the `latitude` and `longitude` fields have been switched decimal coordinates.
|
153
140
|
|
154
141
|
### Timezones **(optional)**
|
155
142
|
|
@@ -198,13 +185,19 @@ c.in_eu? # => false
|
|
198
185
|
c.in_eea? # => false
|
199
186
|
```
|
200
187
|
|
201
|
-
|
202
188
|
### European Single Market Membership
|
203
189
|
|
204
190
|
```ruby
|
205
191
|
c.in_esm? # => false
|
206
192
|
```
|
207
193
|
|
194
|
+
## Country Code in Emoji
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
c = Country['MY']
|
198
|
+
c.emoji_flag # => "🇲🇾"
|
199
|
+
```
|
200
|
+
|
208
201
|
### Plucking multiple attributes
|
209
202
|
|
210
203
|
```ruby
|
@@ -242,6 +235,27 @@ A template for formatting addresses is available through the address_format meth
|
|
242
235
|
c.address_format # => "{{recipient}}\n{{street}}\n{{city}} {{region}} {{postalcode}}\n{{country}}"
|
243
236
|
```
|
244
237
|
|
238
|
+
## Selective Loading of Locales
|
239
|
+
|
240
|
+
As of 2.0 you can selectively load locales to reduce memory usage in production.
|
241
|
+
|
242
|
+
By default we load `I18n.available_locales` if I18n is present, otherwise only `[:en]`. This means almost any Rails environment will only bring in its supported translations.
|
243
|
+
|
244
|
+
You can add all the locales like this.
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
ISO3166.configure do |config|
|
248
|
+
config.locales = [:af, :am, :ar, :as, :az, :be, :bg, :bn, :br, :bs, :ca, :cs, :cy, :da, :de, :dz, :el, :en, :eo, :es, :et, :eu, :fa, :fi, :fo, :fr, :ga, :gl, :gu, :he, :hi, :hr, :hu, :hy, :ia, :id, :is, :it, :ja, :ka, :kk, :km, :kn, :ko, :ku, :lt, :lv, :mi, :mk, :ml, :mn, :mr, :ms, :mt, :nb, :ne, :nl, :nn, :oc, :or, :pa, :pl, :ps, :pt, :ro, :ru, :rw, :si, :sk, :sl, :so, :sq, :sr, :sv, :sw, :ta, :te, :th, :ti, :tk, :tl, :tr, :tt, :ug, :uk, :ve, :vi, :wa, :wo, :xh, :zh, :zu]
|
249
|
+
end
|
250
|
+
```
|
251
|
+
|
252
|
+
or something a bit more simple
|
253
|
+
```ruby
|
254
|
+
ISO3166.configure do |config|
|
255
|
+
config.locales = [:en, :de, :fr, :es]
|
256
|
+
end
|
257
|
+
```
|
258
|
+
|
245
259
|
## Loading Custom Data
|
246
260
|
|
247
261
|
As of 2.0 countries supports loading custom countries / overriding data in its data set, though if you choose to do this please contribute back to the upstream repo!
|
@@ -307,32 +321,11 @@ def country
|
|
307
321
|
end
|
308
322
|
```
|
309
323
|
|
310
|
-
## Country Code in Emoji
|
311
|
-
|
312
|
-
```ruby
|
313
|
-
c = Country['MY']
|
314
|
-
c.emoji_flag # => "🇲🇾"
|
315
|
-
```
|
316
|
-
|
317
324
|
## Note on Patches/Pull Requests
|
318
325
|
|
319
|
-
|
320
|
-
|
321
|
-
Any additions should be directed upstream to [pkg-isocodes](https://salsa.debian.org/iso-codes-team/iso-codes)
|
322
|
-
|
323
|
-
Localized country name data is sourced from https://github.com/grosser/i18n_data (which is based on https://salsa.debian.org/iso-codes-team/iso-codes/). Issues regarding localized country names can be reported to https://github.com/grosser/i18n_data/issues or https://salsa.debian.org/iso-codes-team/iso-codes/issues
|
324
|
-
If you need to correct an upstream translation please add it to the lib/countries/data/translations_corrections.yaml
|
325
|
-
|
326
|
-
```
|
327
|
-
# Ex:
|
328
|
-
#
|
329
|
-
# locale:
|
330
|
-
# alpha2: localized_name
|
331
|
-
#
|
332
|
-
```
|
326
|
+
**Please do not submit pull requests on `cache/**/*`**. These files generated by a rake task when preparing new releases and are not meant to be manually updated.
|
333
327
|
|
334
|
-
|
335
|
-
the next `rake update_cache`.
|
328
|
+
If you with to submit a PR to correct an translation, please edit the `lib/countries/data/translations/countries-<locale>.yaml` file. Changes to the locale YAML files will be injected during the next `rake update_cache`.
|
336
329
|
|
337
330
|
* Fork the project.
|
338
331
|
* Make your feature addition or bug fix.
|
@@ -341,12 +334,13 @@ the next `rake update_cache`.
|
|
341
334
|
* Commit, do not mess with rakefile, version, or history.
|
342
335
|
(if you want to have your own version, that is fine but
|
343
336
|
bump version in a commit by itself I can ignore when I pull)
|
344
|
-
*
|
337
|
+
* Make sure your you haven't made changes to `cache/**/*`
|
338
|
+
* Submit a pull request. Bonus points for topic branches.
|
345
339
|
|
346
340
|
## Copyright
|
347
341
|
|
348
|
-
Copyright (c) 2012-2015 hexorx
|
349
|
-
Copyright (c) 2015-2021 hexorx, rposborne
|
342
|
+
Copyright (c) 2012-2015 hexorx \
|
343
|
+
Copyright (c) 2015-2021 hexorx, rposborne \
|
350
344
|
Copyright (c) 2022 hexorx, rposborne, pmor
|
351
345
|
|
352
346
|
See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'bundler/gem_tasks'
|
3
5
|
|
4
6
|
require 'rake'
|
@@ -28,60 +30,34 @@ end
|
|
28
30
|
|
29
31
|
desc 'Update Cache'
|
30
32
|
task :update_cache do
|
31
|
-
require 'yaml'
|
32
|
-
require 'i18n_data'
|
33
|
-
|
34
33
|
codes = Dir['lib/countries/data/countries/*.yaml'].map { |x| File.basename(x, File.extname(x)) }.uniq.sort
|
35
34
|
data = {}
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
# Ignore locales that have bad data in i18n_data 0.16.0
|
41
|
-
language_keys -= %w[AY AM BA]
|
42
|
-
language_keys.each do |locale|
|
43
|
-
locale = locale.downcase
|
44
|
-
begin
|
45
|
-
local_names = I18nData.countries(locale)
|
46
|
-
rescue I18nData::NoTranslationAvailable
|
47
|
-
next
|
48
|
-
end
|
36
|
+
Dir['lib/countries/data/translations/countries-*.yaml'].each do |locale_file|
|
37
|
+
locale = locale_file.split('-').last.split('.').first.downcase
|
38
|
+
local_names = YAML.load_file(locale_file)
|
49
39
|
|
50
|
-
|
51
|
-
|
52
|
-
corrections[locale].each do |alpha2, localized_name|
|
53
|
-
local_names[alpha2] = localized_name
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
File.open(File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'locales', "#{locale.gsub(/_/, '-')}.json"), 'wb') { |f| f.write(local_names.to_json) }
|
40
|
+
out = File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'locales', "#{locale.gsub(/_/, '-')}.json")
|
41
|
+
File.binwrite(out, local_names.to_json)
|
58
42
|
end
|
59
43
|
|
60
44
|
codes.each do |alpha2|
|
61
|
-
|
45
|
+
country_file = File.join(File.dirname(__FILE__), 'lib', 'countries', 'data', 'countries', "#{alpha2}.yaml")
|
46
|
+
data[alpha2] ||= YAML.load_file(country_file)[alpha2]
|
62
47
|
end
|
63
48
|
|
64
|
-
File.
|
49
|
+
out_file = File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'countries.json')
|
50
|
+
File.binwrite(out_file, data.to_json)
|
65
51
|
end
|
66
52
|
|
67
|
-
|
68
|
-
task :
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
country_code = data.keys.first
|
78
|
-
iso_country = isodata.find {|c| c['cc'] == country_code}
|
79
|
-
|
80
|
-
data.values.first['iso_long_name'] = iso_country['iso_full_name']
|
81
|
-
data.values.first['iso_short_name'] = data.values.first.delete('name')
|
82
|
-
|
83
|
-
data[country_code.upcase] = data[country_code.upcase].sort.to_h
|
84
|
-
|
85
|
-
File.open(file, 'w') { |f| f.write data.to_yaml }
|
53
|
+
desc 'Sort subdivision YAML by code and translations by locale'
|
54
|
+
task :cleanup_subdivision_yaml do
|
55
|
+
ISO3166::Country.codes.each do |c_code|
|
56
|
+
sd = Sources::Local::Subdivision.new(c_code)
|
57
|
+
data = sd.load
|
58
|
+
next if data.nil? || data == {}
|
59
|
+
data = data.sort.to_h
|
60
|
+
data['translations'] = data['translations'].sort.to_h unless data['translations'].nil?
|
61
|
+
sd.save(data)
|
86
62
|
end
|
87
|
-
end
|
63
|
+
end
|
data/UPGRADE.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Upgrading to 4.2 and 5.x
|
2
|
+
|
3
|
+
In release 4.2 the `#name` attribute was deprecated in favour of `#iso_short_name` and we added the `#iso_long_name` attribute, to make it clear that these attributes use the ISO3166 names, and are not the "common names" most people might expect, eg: The ISO name for "United Kingdom" is "United Kingdom of Great Britain and Northern Ireland", but if you're building a dropdown box to select a country, you're likely expecting to see "United Kingdom" instead.
|
4
|
+
|
5
|
+
"Common names" in English have been available in the translation data, via `#translation('en')`. As of release 4.2, a shortcut method has been added for simplicity, `#common_name`, which delegates to `#translation('en')`.
|
6
|
+
|
7
|
+
For additional clarity, the `#names` method, which was an alias to `#unofficial_names` has also been deprecated, together with the finder methods that use `name` or `names` attributes.
|
8
|
+
|
9
|
+
The `#name` and `#names` attributes, and corresponding finder methods were removed in 5.0.
|
10
|
+
|
11
|
+
The replacement finders added in 5.0 are:
|
12
|
+
|
13
|
+
- `#find_by_name` => `#find_by_any_name` - Searches all the name attributes, same as before
|
14
|
+
- `#find_by_names` => `#find_by_unofficial_names`
|
15
|
+
- `#find_*_by_name` => `#find_*_by_any_name`
|
16
|
+
- `#find_*_by_names` => `#find_*_by_unofficial_names`
|
17
|
+
|
18
|
+
With the addition of the new name attributes, there are now also the following finders:
|
19
|
+
|
20
|
+
- `#find_by_common_name`/`#find_*_by_common_name`
|
21
|
+
- `#find_by_iso_short_name`/`#find_*_by_iso_short_name`
|
22
|
+
- `#find_by_iso_long_name`/`#find_*_by_iso_long_name`
|
23
|
+
|
24
|
+
For translated country names, we use data originally sourced from [pkg-isocodes](https://salsa.debian.org/iso-codes-team/iso-codes), via the [i18n_data](https://github.com/grosser/i18n_data) gem, and these generally correspond to the expected "common names". Some corrections have been applied to these localized names. The methods to access translated names have not been changed.
|
25
|
+
|
26
|
+
The 5.0 release removed support for Ruby 2.5 (EOL 2021-03-01) and 2.6 (EOL 2022-03-31)
|
27
|
+
|
28
|
+
# Upgrading to 5.1
|
29
|
+
|
30
|
+
In release 5.1 a `type` attribute was added to the subdivisions object, to allow filtering the collection of subdivisions.
|
31
|
+
|
32
|
+
- `Country#subdivision_types` returns a list of subdivision types for that country (lowercase, snake_cased)
|
33
|
+
- `#subdivisions_of_types(types)` accepts an array of subdivision types and returns the subdivisions for those types
|
34
|
+
|
35
|
+
The `#states` method is deprecated to avoid confusion, as this method is an alias to `#subdivisions` and returns all subdivisions, regardless of type.
|
36
|
+
|
37
|
+
To get a list of `state` subdivisions (something that was not possible before 5.1), use `subdivisions_of_types(['state'])`
|
38
|
+
|
39
|
+
Please note that the subdivision types are obtained from ISO data, and each country defines its own subdivision types, eg: `state`, `district`, `region`, `municipality` and many others types exist.
|
data/bin/console
CHANGED
data/countries.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('lib/countries/version', __dir__)
|
3
4
|
|
4
5
|
Gem::Specification.new do |gem|
|
5
6
|
gem.authors = ['Josh Robinson', 'Joe Corcoran', 'Russell Osborne', 'Pedro Moreira']
|
@@ -10,7 +11,8 @@ Gem::Specification.new do |gem|
|
|
10
11
|
gem.metadata = { 'bug_tracker_uri' => 'https://github.com/countries/countries/issues',
|
11
12
|
'changelog_uri' => 'https://github.com/countries/countries/blob/master/CHANGELOG.md',
|
12
13
|
'source_code_uri' => 'https://github.com/countries/countries',
|
13
|
-
'wiki_uri' => 'https://github.com/countries/countries/wiki'
|
14
|
+
'wiki_uri' => 'https://github.com/countries/countries/wiki',
|
15
|
+
'rubygems_mfa_required' => 'true' }
|
14
16
|
|
15
17
|
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
16
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
@@ -19,11 +21,10 @@ Gem::Specification.new do |gem|
|
|
19
21
|
gem.version = Countries::VERSION.dup
|
20
22
|
gem.license = 'MIT'
|
21
23
|
|
22
|
-
gem.required_ruby_version = '>= 2.
|
24
|
+
gem.required_ruby_version = '>= 2.7'
|
23
25
|
|
24
|
-
gem.add_dependency('i18n_data', '~> 0.16.0')
|
25
26
|
gem.add_dependency('sixarm_ruby_unaccent', '~> 1.1')
|
26
|
-
gem.add_development_dependency('rspec', '>= 3')
|
27
27
|
gem.add_development_dependency('activesupport', '>= 3')
|
28
28
|
gem.add_development_dependency('nokogiri', '>= 1.8')
|
29
|
+
gem.add_development_dependency('rspec', '>= 3')
|
29
30
|
end
|