countries 1.2.5 → 4.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/tests.yml +39 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +52 -0
- data/CHANGELOG.md +557 -1
- data/Gemfile +7 -0
- data/LICENSE +3 -1
- data/README.markdown +264 -132
- data/Rakefile +44 -74
- data/bin/console +14 -0
- data/countries.gemspec +15 -9
- data/lib/countries/cache/countries.json +1 -0
- data/lib/countries/cache/locales/ab.json +1 -0
- data/lib/countries/cache/locales/af.json +1 -0
- data/lib/countries/cache/locales/ak.json +1 -0
- data/lib/countries/cache/locales/am.json +1 -0
- data/lib/countries/cache/locales/an.json +1 -0
- data/lib/countries/cache/locales/ar.json +1 -0
- data/lib/countries/cache/locales/as.json +1 -0
- data/lib/countries/cache/locales/ay.json +1 -0
- data/lib/countries/cache/locales/az.json +1 -0
- data/lib/countries/cache/locales/ba.json +1 -0
- data/lib/countries/cache/locales/be.json +1 -0
- data/lib/countries/cache/locales/bg.json +1 -0
- data/lib/countries/cache/locales/bi.json +1 -0
- data/lib/countries/cache/locales/bn-in.json +1 -0
- data/lib/countries/cache/locales/bn.json +1 -0
- data/lib/countries/cache/locales/br.json +1 -0
- data/lib/countries/cache/locales/bs.json +1 -0
- data/lib/countries/cache/locales/ca.json +1 -0
- data/lib/countries/cache/locales/ce.json +1 -0
- data/lib/countries/cache/locales/ch.json +1 -0
- data/lib/countries/cache/locales/cs.json +1 -0
- data/lib/countries/cache/locales/cv.json +1 -0
- data/lib/countries/cache/locales/cy.json +1 -0
- data/lib/countries/cache/locales/da.json +1 -0
- data/lib/countries/cache/locales/de.json +1 -0
- data/lib/countries/cache/locales/dv.json +1 -0
- data/lib/countries/cache/locales/dz.json +1 -0
- data/lib/countries/cache/locales/ee.json +1 -0
- data/lib/countries/cache/locales/el.json +1 -0
- data/lib/countries/cache/locales/en.json +1 -0
- data/lib/countries/cache/locales/eo.json +1 -0
- data/lib/countries/cache/locales/es.json +1 -0
- data/lib/countries/cache/locales/et.json +1 -0
- data/lib/countries/cache/locales/eu.json +1 -0
- data/lib/countries/cache/locales/fa.json +1 -0
- data/lib/countries/cache/locales/ff.json +1 -0
- data/lib/countries/cache/locales/fi.json +1 -0
- data/lib/countries/cache/locales/fo.json +1 -0
- data/lib/countries/cache/locales/fr.json +1 -0
- data/lib/countries/cache/locales/fy.json +1 -0
- data/lib/countries/cache/locales/ga.json +1 -0
- data/lib/countries/cache/locales/gl.json +1 -0
- data/lib/countries/cache/locales/gn.json +1 -0
- data/lib/countries/cache/locales/gu.json +1 -0
- data/lib/countries/cache/locales/gv.json +1 -0
- data/lib/countries/cache/locales/ha.json +1 -0
- data/lib/countries/cache/locales/he.json +1 -0
- data/lib/countries/cache/locales/hi.json +1 -0
- data/lib/countries/cache/locales/hr.json +1 -0
- data/lib/countries/cache/locales/ht.json +1 -0
- data/lib/countries/cache/locales/hu.json +1 -0
- data/lib/countries/cache/locales/hy.json +1 -0
- data/lib/countries/cache/locales/ia.json +1 -0
- data/lib/countries/cache/locales/id.json +1 -0
- data/lib/countries/cache/locales/io.json +1 -0
- data/lib/countries/cache/locales/is.json +1 -0
- data/lib/countries/cache/locales/it.json +1 -0
- data/lib/countries/cache/locales/iu.json +1 -0
- data/lib/countries/cache/locales/ja.json +1 -0
- data/lib/countries/cache/locales/ka.json +1 -0
- data/lib/countries/cache/locales/ki.json +1 -0
- data/lib/countries/cache/locales/kk.json +1 -0
- data/lib/countries/cache/locales/kl.json +1 -0
- data/lib/countries/cache/locales/km.json +1 -0
- data/lib/countries/cache/locales/kn.json +1 -0
- data/lib/countries/cache/locales/ko.json +1 -0
- data/lib/countries/cache/locales/ku.json +1 -0
- data/lib/countries/cache/locales/kv.json +1 -0
- data/lib/countries/cache/locales/kw.json +1 -0
- data/lib/countries/cache/locales/ky.json +1 -0
- data/lib/countries/cache/locales/lo.json +1 -0
- data/lib/countries/cache/locales/lt.json +1 -0
- data/lib/countries/cache/locales/lv.json +1 -0
- data/lib/countries/cache/locales/mi.json +1 -0
- data/lib/countries/cache/locales/mk.json +1 -0
- data/lib/countries/cache/locales/ml.json +1 -0
- data/lib/countries/cache/locales/mn.json +1 -0
- data/lib/countries/cache/locales/mr.json +1 -0
- data/lib/countries/cache/locales/ms.json +1 -0
- data/lib/countries/cache/locales/mt.json +1 -0
- data/lib/countries/cache/locales/my.json +1 -0
- data/lib/countries/cache/locales/na.json +1 -0
- data/lib/countries/cache/locales/nb.json +1 -0
- data/lib/countries/cache/locales/ne.json +1 -0
- data/lib/countries/cache/locales/nl.json +1 -0
- data/lib/countries/cache/locales/nn.json +1 -0
- data/lib/countries/cache/locales/nv.json +1 -0
- data/lib/countries/cache/locales/oc.json +1 -0
- data/lib/countries/cache/locales/or.json +1 -0
- data/lib/countries/cache/locales/pa.json +1 -0
- data/lib/countries/cache/locales/pi.json +1 -0
- data/lib/countries/cache/locales/pl.json +1 -0
- data/lib/countries/cache/locales/ps.json +1 -0
- data/lib/countries/cache/locales/pt-br.json +1 -0
- data/lib/countries/cache/locales/pt.json +1 -0
- data/lib/countries/cache/locales/ro.json +1 -0
- data/lib/countries/cache/locales/ru.json +1 -0
- data/lib/countries/cache/locales/rw.json +1 -0
- data/lib/countries/cache/locales/sc.json +1 -0
- data/lib/countries/cache/locales/sd.json +1 -0
- data/lib/countries/cache/locales/si.json +1 -0
- data/lib/countries/cache/locales/sk.json +1 -0
- data/lib/countries/cache/locales/sl.json +1 -0
- data/lib/countries/cache/locales/so.json +1 -0
- data/lib/countries/cache/locales/sq.json +1 -0
- data/lib/countries/cache/locales/sr.json +1 -0
- data/lib/countries/cache/locales/sv.json +1 -0
- data/lib/countries/cache/locales/sw.json +1 -0
- data/lib/countries/cache/locales/ta.json +1 -0
- data/lib/countries/cache/locales/te.json +1 -0
- data/lib/countries/cache/locales/tg.json +1 -0
- data/lib/countries/cache/locales/th.json +1 -0
- data/lib/countries/cache/locales/ti.json +1 -0
- data/lib/countries/cache/locales/tk.json +1 -0
- data/lib/countries/cache/locales/tl.json +1 -0
- data/lib/countries/cache/locales/tr.json +1 -0
- data/lib/countries/cache/locales/tt.json +1 -0
- data/lib/countries/cache/locales/ug.json +1 -0
- data/lib/countries/cache/locales/uk.json +1 -0
- data/lib/countries/cache/locales/ur.json +1 -0
- data/lib/countries/cache/locales/uz.json +1 -0
- data/lib/countries/cache/locales/ve.json +1 -0
- data/lib/countries/cache/locales/vi.json +1 -0
- data/lib/countries/cache/locales/wa.json +1 -0
- data/lib/countries/cache/locales/wo.json +1 -0
- data/lib/countries/cache/locales/xh.json +1 -0
- data/lib/countries/cache/locales/yo.json +1 -0
- data/lib/countries/cache/locales/zh-cn.json +1 -0
- data/lib/countries/cache/locales/zh-hk.json +1 -0
- data/lib/countries/cache/locales/zh-tw.json +1 -0
- data/lib/countries/cache/locales/zh.json +1 -0
- data/lib/countries/cache/locales/zu.json +1 -0
- data/lib/countries/configuration.rb +57 -0
- data/lib/countries/country/class_methods.rb +196 -0
- data/lib/countries/country/currency_methods.rb +13 -0
- data/lib/countries/country/emoji.rb +42 -0
- data/lib/countries/country.rb +214 -158
- data/lib/countries/data/countries/AD.yaml +32 -21
- data/lib/countries/data/countries/AE.yaml +40 -25
- data/lib/countries/data/countries/AF.yaml +36 -23
- data/lib/countries/data/countries/AG.yaml +36 -25
- data/lib/countries/data/countries/AI.yaml +33 -21
- data/lib/countries/data/countries/AL.yaml +35 -24
- data/lib/countries/data/countries/AM.yaml +36 -24
- data/lib/countries/data/countries/AO.yaml +30 -20
- data/lib/countries/data/countries/AQ.yaml +31 -22
- data/lib/countries/data/countries/AR.yaml +36 -24
- data/lib/countries/data/countries/AS.yaml +38 -25
- data/lib/countries/data/countries/AT.yaml +37 -25
- data/lib/countries/data/countries/AU.yaml +39 -23
- data/lib/countries/data/countries/AW.yaml +30 -20
- data/lib/countries/data/countries/AX.yaml +33 -22
- data/lib/countries/data/countries/AZ.yaml +37 -25
- data/lib/countries/data/countries/BA.yaml +40 -27
- data/lib/countries/data/countries/BB.yaml +33 -21
- data/lib/countries/data/countries/BD.yaml +32 -21
- data/lib/countries/data/countries/BE.yaml +42 -28
- data/lib/countries/data/countries/BF.yaml +32 -21
- data/lib/countries/data/countries/BG.yaml +38 -26
- data/lib/countries/data/countries/BH.yaml +35 -24
- data/lib/countries/data/countries/BI.yaml +32 -21
- data/lib/countries/data/countries/BJ.yaml +31 -21
- data/lib/countries/data/countries/BL.yaml +33 -22
- data/lib/countries/data/countries/BM.yaml +34 -22
- data/lib/countries/data/countries/BN.yaml +32 -21
- data/lib/countries/data/countries/BO.yaml +37 -25
- data/lib/countries/data/countries/BQ.yaml +33 -22
- data/lib/countries/data/countries/BR.yaml +42 -24
- data/lib/countries/data/countries/BS.yaml +32 -21
- data/lib/countries/data/countries/BT.yaml +33 -22
- data/lib/countries/data/countries/BV.yaml +31 -22
- data/lib/countries/data/countries/BW.yaml +32 -21
- data/lib/countries/data/countries/BY.yaml +38 -26
- data/lib/countries/data/countries/BZ.yaml +34 -23
- data/lib/countries/data/countries/CA.yaml +35 -23
- data/lib/countries/data/countries/CC.yaml +34 -23
- data/lib/countries/data/countries/CD.yaml +44 -28
- data/lib/countries/data/countries/CF.yaml +36 -25
- data/lib/countries/data/countries/CG.yaml +35 -23
- data/lib/countries/data/countries/CH.yaml +47 -26
- data/lib/countries/data/countries/CI.yaml +35 -24
- data/lib/countries/data/countries/CK.yaml +34 -24
- data/lib/countries/data/countries/CL.yaml +37 -21
- data/lib/countries/data/countries/CM.yaml +36 -25
- data/lib/countries/data/countries/CN.yaml +32 -21
- data/lib/countries/data/countries/CO.yaml +33 -22
- data/lib/countries/data/countries/CR.yaml +31 -20
- data/lib/countries/data/countries/CU.yaml +32 -21
- data/lib/countries/data/countries/CV.yaml +35 -24
- data/lib/countries/data/countries/CW.yaml +31 -21
- data/lib/countries/data/countries/CX.yaml +38 -25
- data/lib/countries/data/countries/CY.yaml +42 -28
- data/lib/countries/data/countries/CZ.yaml +42 -28
- data/lib/countries/data/countries/DE.yaml +39 -27
- data/lib/countries/data/countries/DJ.yaml +34 -23
- data/lib/countries/data/countries/DK.yaml +39 -27
- data/lib/countries/data/countries/DM.yaml +31 -20
- data/lib/countries/data/countries/DO.yaml +35 -24
- data/lib/countries/data/countries/DZ.yaml +36 -25
- data/lib/countries/data/countries/EC.yaml +32 -21
- data/lib/countries/data/countries/EE.yaml +37 -26
- data/lib/countries/data/countries/EG.yaml +36 -25
- data/lib/countries/data/countries/EH.yaml +38 -26
- data/lib/countries/data/countries/ER.yaml +36 -24
- data/lib/countries/data/countries/ES.yaml +38 -26
- data/lib/countries/data/countries/ET.yaml +35 -24
- data/lib/countries/data/countries/FI.yaml +40 -27
- data/lib/countries/data/countries/FJ.yaml +38 -25
- data/lib/countries/data/countries/FK.yaml +36 -25
- data/lib/countries/data/countries/FM.yaml +34 -23
- data/lib/countries/data/countries/FO.yaml +35 -24
- data/lib/countries/data/countries/FR.yaml +38 -26
- data/lib/countries/data/countries/GA.yaml +32 -22
- data/lib/countries/data/countries/GB.yaml +46 -28
- data/lib/countries/data/countries/GD.yaml +31 -20
- data/lib/countries/data/countries/GE.yaml +34 -23
- data/lib/countries/data/countries/GF.yaml +35 -23
- data/lib/countries/data/countries/GG.yaml +38 -26
- data/lib/countries/data/countries/GH.yaml +30 -20
- data/lib/countries/data/countries/GI.yaml +32 -21
- data/lib/countries/data/countries/GL.yaml +35 -24
- data/lib/countries/data/countries/GM.yaml +30 -20
- data/lib/countries/data/countries/GN.yaml +35 -23
- data/lib/countries/data/countries/GP.yaml +33 -22
- data/lib/countries/data/countries/GQ.yaml +36 -25
- data/lib/countries/data/countries/GR.yaml +41 -29
- data/lib/countries/data/countries/GS.yaml +34 -22
- data/lib/countries/data/countries/GT.yaml +31 -20
- data/lib/countries/data/countries/GU.yaml +36 -22
- data/lib/countries/data/countries/GW.yaml +34 -22
- data/lib/countries/data/countries/GY.yaml +30 -20
- data/lib/countries/data/countries/HK.yaml +33 -22
- data/lib/countries/data/countries/HM.yaml +35 -24
- data/lib/countries/data/countries/HN.yaml +31 -20
- data/lib/countries/data/countries/HR.yaml +40 -28
- data/lib/countries/data/countries/HT.yaml +34 -22
- data/lib/countries/data/countries/HU.yaml +39 -27
- data/lib/countries/data/countries/ID.yaml +34 -23
- data/lib/countries/data/countries/IE.yaml +39 -26
- data/lib/countries/data/countries/IL.yaml +39 -22
- data/lib/countries/data/countries/IM.yaml +37 -25
- data/lib/countries/data/countries/IN.yaml +35 -23
- data/lib/countries/data/countries/IO.yaml +35 -24
- data/lib/countries/data/countries/IQ.yaml +33 -22
- data/lib/countries/data/countries/IR.yaml +34 -23
- data/lib/countries/data/countries/IS.yaml +42 -24
- data/lib/countries/data/countries/IT.yaml +38 -26
- data/lib/countries/data/countries/JE.yaml +34 -22
- data/lib/countries/data/countries/JM.yaml +33 -22
- data/lib/countries/data/countries/JO.yaml +36 -25
- data/lib/countries/data/countries/JP.yaml +33 -22
- data/lib/countries/data/countries/KE.yaml +34 -22
- data/lib/countries/data/countries/KG.yaml +38 -26
- data/lib/countries/data/countries/KH.yaml +35 -24
- data/lib/countries/data/countries/KI.yaml +30 -20
- data/lib/countries/data/countries/KM.yaml +35 -24
- data/lib/countries/data/countries/KN.yaml +38 -25
- data/lib/countries/data/countries/KP.yaml +37 -26
- data/lib/countries/data/countries/KR.yaml +37 -26
- data/lib/countries/data/countries/KW.yaml +34 -23
- data/lib/countries/data/countries/KY.yaml +36 -24
- data/lib/countries/data/countries/KZ.yaml +36 -24
- data/lib/countries/data/countries/LA.yaml +32 -21
- data/lib/countries/data/countries/LB.yaml +37 -25
- data/lib/countries/data/countries/LC.yaml +35 -22
- data/lib/countries/data/countries/LI.yaml +32 -20
- data/lib/countries/data/countries/LK.yaml +33 -21
- data/lib/countries/data/countries/LR.yaml +31 -20
- data/lib/countries/data/countries/LS.yaml +33 -21
- data/lib/countries/data/countries/LT.yaml +41 -28
- data/lib/countries/data/countries/LU.yaml +39 -25
- data/lib/countries/data/countries/LV.yaml +45 -27
- data/lib/countries/data/countries/LY.yaml +36 -26
- data/lib/countries/data/countries/MA.yaml +35 -24
- data/lib/countries/data/countries/MC.yaml +32 -21
- data/lib/countries/data/countries/MD.yaml +36 -25
- data/lib/countries/data/countries/ME.yaml +38 -24
- data/lib/countries/data/countries/MF.yaml +37 -24
- data/lib/countries/data/countries/MG.yaml +35 -23
- data/lib/countries/data/countries/MH.yaml +37 -25
- data/lib/countries/data/countries/MK.yaml +37 -25
- data/lib/countries/data/countries/ML.yaml +30 -20
- data/lib/countries/data/countries/MM.yaml +31 -20
- data/lib/countries/data/countries/MN.yaml +34 -23
- data/lib/countries/data/countries/MO.yaml +33 -22
- data/lib/countries/data/countries/MP.yaml +38 -26
- data/lib/countries/data/countries/MQ.yaml +33 -22
- data/lib/countries/data/countries/MR.yaml +36 -25
- data/lib/countries/data/countries/MS.yaml +32 -21
- data/lib/countries/data/countries/MT.yaml +38 -25
- data/lib/countries/data/countries/MU.yaml +33 -22
- data/lib/countries/data/countries/MV.yaml +34 -23
- data/lib/countries/data/countries/MW.yaml +32 -21
- data/lib/countries/data/countries/MX.yaml +39 -23
- data/lib/countries/data/countries/MY.yaml +36 -24
- data/lib/countries/data/countries/MZ.yaml +32 -21
- data/lib/countries/data/countries/NA.yaml +35 -23
- data/lib/countries/data/countries/NC.yaml +36 -25
- data/lib/countries/data/countries/NE.yaml +32 -21
- data/lib/countries/data/countries/NF.yaml +36 -25
- data/lib/countries/data/countries/NG.yaml +39 -23
- data/lib/countries/data/countries/NI.yaml +31 -20
- data/lib/countries/data/countries/NL.yaml +41 -28
- data/lib/countries/data/countries/NO.yaml +43 -25
- data/lib/countries/data/countries/NP.yaml +43 -22
- data/lib/countries/data/countries/NR.yaml +32 -21
- data/lib/countries/data/countries/NU.yaml +30 -20
- data/lib/countries/data/countries/NZ.yaml +41 -24
- data/lib/countries/data/countries/OM.yaml +33 -22
- data/lib/countries/data/countries/PA.yaml +31 -21
- data/lib/countries/data/countries/PE.yaml +33 -22
- data/lib/countries/data/countries/PF.yaml +36 -25
- data/lib/countries/data/countries/PG.yaml +35 -24
- data/lib/countries/data/countries/PH.yaml +41 -24
- data/lib/countries/data/countries/PK.yaml +34 -22
- data/lib/countries/data/countries/PL.yaml +38 -26
- data/lib/countries/data/countries/PM.yaml +36 -25
- data/lib/countries/data/countries/PN.yaml +35 -23
- data/lib/countries/data/countries/PR.yaml +33 -21
- data/lib/countries/data/countries/PS.yaml +41 -28
- data/lib/countries/data/countries/PT.yaml +34 -22
- data/lib/countries/data/countries/PW.yaml +31 -20
- data/lib/countries/data/countries/PY.yaml +33 -21
- data/lib/countries/data/countries/QA.yaml +32 -22
- data/lib/countries/data/countries/RE.yaml +34 -23
- data/lib/countries/data/countries/RO.yaml +40 -28
- data/lib/countries/data/countries/RS.yaml +34 -23
- data/lib/countries/data/countries/RU.yaml +37 -26
- data/lib/countries/data/countries/RW.yaml +35 -23
- data/lib/countries/data/countries/SA.yaml +42 -25
- data/lib/countries/data/countries/SB.yaml +35 -25
- data/lib/countries/data/countries/SC.yaml +33 -22
- data/lib/countries/data/countries/SD.yaml +37 -25
- data/lib/countries/data/countries/SE.yaml +39 -27
- data/lib/countries/data/countries/SG.yaml +38 -25
- data/lib/countries/data/countries/SH.yaml +37 -25
- data/lib/countries/data/countries/SI.yaml +39 -27
- data/lib/countries/data/countries/SJ.yaml +36 -25
- data/lib/countries/data/countries/SK.yaml +39 -27
- data/lib/countries/data/countries/SL.yaml +30 -20
- data/lib/countries/data/countries/SM.yaml +32 -21
- data/lib/countries/data/countries/SN.yaml +32 -21
- data/lib/countries/data/countries/SO.yaml +35 -23
- data/lib/countries/data/countries/SR.yaml +31 -21
- data/lib/countries/data/countries/SS.yaml +35 -23
- data/lib/countries/data/countries/ST.yaml +34 -24
- data/lib/countries/data/countries/SV.yaml +32 -21
- data/lib/countries/data/countries/SX.yaml +34 -22
- data/lib/countries/data/countries/SY.yaml +36 -26
- data/lib/countries/data/countries/SZ.yaml +35 -23
- data/lib/countries/data/countries/TC.yaml +38 -25
- data/lib/countries/data/countries/TD.yaml +36 -25
- data/lib/countries/data/countries/TF.yaml +39 -28
- data/lib/countries/data/countries/TG.yaml +30 -20
- data/lib/countries/data/countries/TH.yaml +39 -22
- data/lib/countries/data/countries/TJ.yaml +37 -25
- data/lib/countries/data/countries/TK.yaml +33 -23
- data/lib/countries/data/countries/TL.yaml +34 -24
- data/lib/countries/data/countries/TM.yaml +35 -23
- data/lib/countries/data/countries/TN.yaml +38 -26
- data/lib/countries/data/countries/TO.yaml +32 -21
- data/lib/countries/data/countries/TR.yaml +35 -24
- data/lib/countries/data/countries/TT.yaml +35 -24
- data/lib/countries/data/countries/TV.yaml +30 -20
- data/lib/countries/data/countries/TW.yaml +33 -22
- data/lib/countries/data/countries/TZ.yaml +36 -24
- data/lib/countries/data/countries/UA.yaml +42 -25
- data/lib/countries/data/countries/UG.yaml +33 -22
- data/lib/countries/data/countries/UM.yaml +37 -26
- data/lib/countries/data/countries/US.yaml +37 -24
- data/lib/countries/data/countries/UY.yaml +31 -20
- data/lib/countries/data/countries/UZ.yaml +37 -25
- data/lib/countries/data/countries/VA.yaml +39 -27
- data/lib/countries/data/countries/VC.yaml +38 -24
- data/lib/countries/data/countries/VE.yaml +31 -20
- data/lib/countries/data/countries/VG.yaml +38 -26
- data/lib/countries/data/countries/VI.yaml +37 -25
- data/lib/countries/data/countries/VN.yaml +38 -21
- data/lib/countries/data/countries/VU.yaml +34 -22
- data/lib/countries/data/countries/WF.yaml +36 -25
- data/lib/countries/data/countries/WS.yaml +32 -21
- data/lib/countries/data/countries/YE.yaml +33 -23
- data/lib/countries/data/countries/YT.yaml +32 -21
- data/lib/countries/data/countries/ZA.yaml +52 -32
- data/lib/countries/data/countries/ZM.yaml +33 -22
- data/lib/countries/data/countries/ZW.yaml +36 -24
- data/lib/countries/data/subdivisions/AD.yaml +85 -50
- data/lib/countries/data/subdivisions/AE.yaml +513 -55
- data/lib/countries/data/subdivisions/AF.yaml +2239 -234
- data/lib/countries/data/subdivisions/AG.yaml +451 -57
- data/lib/countries/data/subdivisions/AI.yaml +197 -0
- data/lib/countries/data/subdivisions/AL.yaml +746 -316
- data/lib/countries/data/subdivisions/AM.yaml +788 -68
- data/lib/countries/data/subdivisions/AO.yaml +1145 -126
- data/lib/countries/data/subdivisions/AR.yaml +1668 -168
- data/lib/countries/data/subdivisions/AT.yaml +714 -63
- data/lib/countries/data/subdivisions/AU.yaml +673 -56
- data/lib/countries/data/subdivisions/AZ.yaml +4508 -536
- data/lib/countries/data/subdivisions/BA.yaml +359 -14
- data/lib/countries/data/subdivisions/BB.yaml +589 -79
- data/lib/countries/data/subdivisions/BD.yaml +2593 -400
- data/lib/countries/data/subdivisions/BE.yaml +943 -77
- data/lib/countries/data/subdivisions/BF.yaml +2917 -311
- data/lib/countries/data/subdivisions/BG.yaml +1965 -199
- data/lib/countries/data/subdivisions/BH.yaml +184 -31
- data/lib/countries/data/subdivisions/BI.yaml +982 -112
- data/lib/countries/data/subdivisions/BJ.yaml +691 -84
- data/lib/countries/data/subdivisions/BM.yaml +155 -0
- data/lib/countries/data/subdivisions/BN.yaml +225 -24
- data/lib/countries/data/subdivisions/BO.yaml +561 -63
- data/lib/countries/data/subdivisions/BQ.yaml +217 -21
- data/lib/countries/data/subdivisions/BR.yaml +2154 -185
- data/lib/countries/data/subdivisions/BS.yaml +1821 -143
- data/lib/countries/data/subdivisions/BT.yaml +1087 -140
- data/lib/countries/data/subdivisions/BW.yaml +923 -63
- data/lib/countries/data/subdivisions/BY.yaml +528 -31
- data/lib/countries/data/subdivisions/BZ.yaml +309 -42
- data/lib/countries/data/subdivisions/CA.yaml +1105 -92
- data/lib/countries/data/subdivisions/CD.yaml +1187 -78
- data/lib/countries/data/subdivisions/CF.yaml +961 -119
- data/lib/countries/data/subdivisions/CG.yaml +640 -77
- data/lib/countries/data/subdivisions/CH.yaml +1946 -182
- data/lib/countries/data/subdivisions/CI.yaml +859 -125
- data/lib/countries/data/subdivisions/CK.yaml +155 -0
- data/lib/countries/data/subdivisions/CL.yaml +968 -105
- data/lib/countries/data/subdivisions/CM.yaml +582 -70
- data/lib/countries/data/subdivisions/CN.yaml +2618 -274
- data/lib/countries/data/subdivisions/CO.yaml +2102 -227
- data/lib/countries/data/subdivisions/CR.yaml +393 -49
- data/lib/countries/data/subdivisions/CU.yaml +926 -119
- data/lib/countries/data/subdivisions/CV.yaml +1198 -119
- data/lib/countries/data/subdivisions/CY.yaml +328 -42
- data/lib/countries/data/subdivisions/CZ.yaml +2892 -129
- data/lib/countries/data/subdivisions/DE.yaml +1420 -112
- data/lib/countries/data/subdivisions/DJ.yaml +375 -42
- data/lib/countries/data/subdivisions/DK.yaml +344 -180
- data/lib/countries/data/subdivisions/DM.yaml +512 -72
- data/lib/countries/data/subdivisions/DO.yaml +1763 -219
- data/lib/countries/data/subdivisions/DZ.yaml +2869 -334
- data/lib/countries/data/subdivisions/EC.yaml +1348 -168
- data/lib/countries/data/subdivisions/EE.yaml +1368 -118
- data/lib/countries/data/subdivisions/EG.yaml +1628 -190
- data/lib/countries/data/subdivisions/EH.yaml +48 -28
- data/lib/countries/data/subdivisions/ER.yaml +348 -42
- data/lib/countries/data/subdivisions/ES.yaml +4875 -375
- data/lib/countries/data/subdivisions/ET.yaml +735 -77
- data/lib/countries/data/subdivisions/FI.yaml +890 -36
- data/lib/countries/data/subdivisions/FJ.yaml +720 -35
- data/lib/countries/data/subdivisions/FM.yaml +202 -24
- data/lib/countries/data/subdivisions/FR.yaml +8250 -684
- data/lib/countries/data/subdivisions/GA.yaml +526 -63
- data/lib/countries/data/subdivisions/GB.yaml +12522 -1516
- data/lib/countries/data/subdivisions/GD.yaml +354 -49
- data/lib/countries/data/subdivisions/GE.yaml +833 -85
- data/lib/countries/data/subdivisions/GH.yaml +658 -70
- data/lib/countries/data/subdivisions/GL.yaml +262 -0
- data/lib/countries/data/subdivisions/GM.yaml +381 -42
- data/lib/countries/data/subdivisions/GN.yaml +1919 -234
- data/lib/countries/data/subdivisions/GQ.yaml +459 -59
- data/lib/countries/data/subdivisions/GR.yaml +871 -527
- data/lib/countries/data/subdivisions/GT.yaml +1270 -150
- data/lib/countries/data/subdivisions/GW.yaml +563 -59
- data/lib/countries/data/subdivisions/GY.yaml +498 -70
- data/lib/countries/data/subdivisions/HN.yaml +1019 -126
- data/lib/countries/data/subdivisions/HR.yaml +1419 -151
- data/lib/countries/data/subdivisions/HT.yaml +525 -63
- data/lib/countries/data/subdivisions/HU.yaml +2949 -302
- data/lib/countries/data/subdivisions/ID.yaml +2679 -243
- data/lib/countries/data/subdivisions/IE.yaml +2027 -177
- data/lib/countries/data/subdivisions/IL.yaml +376 -42
- data/lib/countries/data/subdivisions/IN.yaml +3110 -252
- data/lib/countries/data/subdivisions/IQ.yaml +1105 -126
- data/lib/countries/data/subdivisions/IR.yaml +2092 -215
- data/lib/countries/data/subdivisions/IS.yaml +830 -59
- data/lib/countries/data/subdivisions/IT.yaml +8525 -790
- data/lib/countries/data/subdivisions/JM.yaml +732 -100
- data/lib/countries/data/subdivisions/JO.yaml +662 -48
- data/lib/countries/data/subdivisions/JP.yaml +3562 -327
- data/lib/countries/data/subdivisions/KE.yaml +1449 -56
- data/lib/countries/data/subdivisions/KG.yaml +624 -57
- data/lib/countries/data/subdivisions/KH.yaml +1332 -147
- data/lib/countries/data/subdivisions/KI.yaml +163 -17
- data/lib/countries/data/subdivisions/KM.yaml +189 -21
- data/lib/countries/data/subdivisions/KN.yaml +835 -100
- data/lib/countries/data/subdivisions/KP.yaml +922 -80
- data/lib/countries/data/subdivisions/KR.yaml +1225 -88
- data/lib/countries/data/subdivisions/KW.yaml +280 -42
- data/lib/countries/data/subdivisions/KZ.yaml +1213 -122
- data/lib/countries/data/subdivisions/LA.yaml +947 -120
- data/lib/countries/data/subdivisions/LB.yaml +386 -22
- data/lib/countries/data/subdivisions/LC.yaml +470 -0
- data/lib/countries/data/subdivisions/LI.yaml +557 -39
- data/lib/countries/data/subdivisions/LK.yaml +1546 -175
- data/lib/countries/data/subdivisions/LR.yaml +857 -105
- data/lib/countries/data/subdivisions/LS.yaml +529 -70
- data/lib/countries/data/subdivisions/LT.yaml +2616 -71
- data/lib/countries/data/subdivisions/LU.yaml +490 -24
- data/lib/countries/data/subdivisions/LV.yaml +2501 -178
- data/lib/countries/data/subdivisions/LY.yaml +1188 -262
- data/lib/countries/data/subdivisions/MA.yaml +3375 -437
- data/lib/countries/data/subdivisions/MC.yaml +484 -0
- data/lib/countries/data/subdivisions/MD.yaml +2240 -71
- data/lib/countries/data/subdivisions/ME.yaml +1136 -151
- data/lib/countries/data/subdivisions/MG.yaml +253 -42
- data/lib/countries/data/subdivisions/MH.yaml +995 -151
- data/lib/countries/data/subdivisions/MK.yaml +3964 -752
- data/lib/countries/data/subdivisions/ML.yaml +569 -63
- data/lib/countries/data/subdivisions/MM.yaml +849 -98
- data/lib/countries/data/subdivisions/MN.yaml +1389 -160
- data/lib/countries/data/subdivisions/MR.yaml +702 -94
- data/lib/countries/data/subdivisions/MT.yaml +3726 -478
- data/lib/countries/data/subdivisions/MU.yaml +923 -115
- data/lib/countries/data/subdivisions/MV.yaml +1219 -148
- data/lib/countries/data/subdivisions/MW.yaml +1646 -189
- data/lib/countries/data/subdivisions/MX.yaml +2414 -222
- data/lib/countries/data/subdivisions/MY.yaml +1071 -114
- data/lib/countries/data/subdivisions/MZ.yaml +665 -77
- data/lib/countries/data/subdivisions/NA.yaml +736 -98
- data/lib/countries/data/subdivisions/NE.yaml +475 -56
- data/lib/countries/data/subdivisions/NG.yaml +2370 -259
- data/lib/countries/data/subdivisions/NI.yaml +952 -119
- data/lib/countries/data/subdivisions/NL.yaml +1205 -84
- data/lib/countries/data/subdivisions/NO.yaml +856 -164
- data/lib/countries/data/subdivisions/NP.yaml +982 -90
- data/lib/countries/data/subdivisions/NR.yaml +827 -100
- data/lib/countries/data/subdivisions/NZ.yaml +945 -121
- data/lib/countries/data/subdivisions/OM.yaml +633 -63
- data/lib/countries/data/subdivisions/PA.yaml +708 -69
- data/lib/countries/data/subdivisions/PE.yaml +1489 -179
- data/lib/countries/data/subdivisions/PG.yaml +1211 -140
- data/lib/countries/data/subdivisions/PH.yaml +5089 -572
- data/lib/countries/data/subdivisions/PK.yaml +566 -56
- data/lib/countries/data/subdivisions/PL.yaml +1042 -150
- data/lib/countries/data/subdivisions/PS.yaml +747 -0
- data/lib/countries/data/subdivisions/PT.yaml +1122 -143
- data/lib/countries/data/subdivisions/PW.yaml +832 -108
- data/lib/countries/data/subdivisions/PY.yaml +1045 -127
- data/lib/countries/data/subdivisions/QA.yaml +469 -64
- data/lib/countries/data/subdivisions/RO.yaml +2746 -294
- data/lib/countries/data/subdivisions/RS.yaml +1786 -195
- data/lib/countries/data/subdivisions/RU.yaml +6570 -655
- data/lib/countries/data/subdivisions/RW.yaml +327 -35
- data/lib/countries/data/subdivisions/SA.yaml +768 -102
- data/lib/countries/data/subdivisions/SB.yaml +550 -70
- data/lib/countries/data/subdivisions/SC.yaml +1286 -163
- data/lib/countries/data/subdivisions/SD.yaml +1002 -254
- data/lib/countries/data/subdivisions/SE.yaml +1416 -149
- data/lib/countries/data/subdivisions/SG.yaml +108 -31
- data/lib/countries/data/subdivisions/SH.yaml +197 -21
- data/lib/countries/data/subdivisions/SI.yaml +10997 -1403
- data/lib/countries/data/subdivisions/SJ.yaml +29 -0
- data/lib/countries/data/subdivisions/SK.yaml +533 -57
- data/lib/countries/data/subdivisions/SL.yaml +231 -28
- data/lib/countries/data/subdivisions/SM.yaml +577 -65
- data/lib/countries/data/subdivisions/SN.yaml +761 -77
- data/lib/countries/data/subdivisions/SO.yaml +914 -126
- data/lib/countries/data/subdivisions/SR.yaml +512 -70
- data/lib/countries/data/subdivisions/SS.yaml +624 -0
- data/lib/countries/data/subdivisions/ST.yaml +73 -14
- data/lib/countries/data/subdivisions/SV.yaml +747 -98
- data/lib/countries/data/subdivisions/SY.yaml +806 -91
- data/lib/countries/data/subdivisions/SZ.yaml +217 -28
- data/lib/countries/data/subdivisions/TD.yaml +1242 -126
- data/lib/countries/data/subdivisions/TG.yaml +264 -35
- data/lib/countries/data/subdivisions/TH.yaml +4535 -539
- data/lib/countries/data/subdivisions/TJ.yaml +356 -0
- data/lib/countries/data/subdivisions/TK.yaml +43 -0
- data/lib/countries/data/subdivisions/TL.yaml +682 -91
- data/lib/countries/data/subdivisions/TM.yaml +390 -46
- data/lib/countries/data/subdivisions/TN.yaml +1301 -168
- data/lib/countries/data/subdivisions/TO.yaml +260 -36
- data/lib/countries/data/subdivisions/TR.yaml +5858 -624
- data/lib/countries/data/subdivisions/TT.yaml +865 -112
- data/lib/countries/data/subdivisions/TV.yaml +382 -44
- data/lib/countries/data/subdivisions/TW.yaml +1281 -145
- data/lib/countries/data/subdivisions/TZ.yaml +1868 -184
- data/lib/countries/data/subdivisions/UA.yaml +1988 -192
- data/lib/countries/data/subdivisions/UG.yaml +6150 -544
- data/lib/countries/data/subdivisions/UM.yaml +710 -59
- data/lib/countries/data/subdivisions/US.yaml +4789 -404
- data/lib/countries/data/subdivisions/UY.yaml +1163 -112
- data/lib/countries/data/subdivisions/UZ.yaml +902 -99
- data/lib/countries/data/subdivisions/VC.yaml +289 -38
- data/lib/countries/data/subdivisions/VE.yaml +1559 -175
- data/lib/countries/data/subdivisions/VN.yaml +3799 -550
- data/lib/countries/data/subdivisions/VU.yaml +333 -43
- data/lib/countries/data/subdivisions/WF.yaml +201 -0
- data/lib/countries/data/subdivisions/WS.yaml +587 -77
- data/lib/countries/data/subdivisions/YE.yaml +1262 -135
- data/lib/countries/data/subdivisions/ZA.yaml +712 -63
- data/lib/countries/data/subdivisions/ZM.yaml +568 -65
- data/lib/countries/data/subdivisions/ZW.yaml +520 -70
- data/lib/countries/data/translation_corrections.yaml +35 -5
- data/lib/countries/data.rb +161 -16
- data/lib/countries/global.rb +13 -3
- data/lib/countries/iso3166.rb +9 -2
- data/lib/countries/kwarg_struct.rb +12 -0
- data/lib/countries/mongoid.rb +25 -22
- data/lib/countries/setup.rb +7 -7
- data/lib/countries/sources/cldr/downloader.rb +37 -0
- data/lib/countries/sources/cldr/subdivision.rb +35 -0
- data/lib/countries/sources/cldr/subdivision_updater.rb +35 -0
- data/lib/countries/sources/local/cached_loader.rb +29 -0
- data/lib/countries/sources/local/subdivision.rb +33 -0
- data/lib/countries/sources.rb +6 -0
- data/lib/countries/structure.rb +72 -0
- data/lib/countries/subdivision.rb +10 -0
- data/lib/countries/tasks/geocoding.rake +97 -0
- data/lib/countries/tasks/postal_codes.rake +48 -0
- data/lib/countries/timezones.rb +13 -0
- data/lib/countries/translations.rb +11 -0
- data/lib/countries/version.rb +1 -1
- data/lib/countries.rb +2 -0
- data/spec/00_global_spec.rb +56 -0
- data/spec/configuration_spec.rb +54 -0
- data/spec/country_spec.rb +473 -87
- data/spec/data_spec.rb +181 -0
- data/spec/mongoid_spec.rb +2 -2
- data/spec/perf_spec.rb +74 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/subdivision_spec.rb +32 -0
- data/spec/thread_safety_spec.rb +46 -0
- data/spec/timezone_spec.rb +32 -0
- metadata +206 -30
- data/.travis.yml +0 -11
- data/lib/countries/cache/countries +0 -0
- data/lib/countries/data/countries/AN.yaml +0 -42
- data/lib/countries/data/countries.yaml +0 -251
- data/lib/countries/data/subdivisions/Ky.yaml +0 -55
- data/lib/countries/data/subdivisions/TF.yaml +0 -27
- data/lib/countries/data/subdivisions/Tj.yaml +0 -38
- data/spec/setup_spec.rb +0 -14
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.markdown
CHANGED
@@ -1,200 +1,338 @@
|
|
1
|
-
Countries
|
2
|
-
=========
|
1
|
+
# Countries
|
3
2
|
|
4
|
-
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.
|
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.
|
5
4
|
|
6
|
-
[![
|
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)
|
7
6
|
|
8
|
-
Installation
|
9
|
-
------------
|
7
|
+
## Installation
|
10
8
|
|
11
|
-
|
9
|
+
```bash
|
10
|
+
gem install countries
|
11
|
+
```
|
12
12
|
|
13
|
-
|
13
|
+
Or you can install via Bundler if you are using Rails:
|
14
14
|
|
15
|
-
|
15
|
+
```bash
|
16
|
+
bundle add countries
|
17
|
+
```
|
16
18
|
|
17
|
-
|
19
|
+
## Basic Usage
|
18
20
|
|
19
|
-
|
21
|
+
Simply load a new country object using Country.new(*alpha2*) or the shortcut Country[*alpha2*]. An example works best.
|
20
22
|
|
21
|
-
|
23
|
+
```ruby
|
24
|
+
c = ISO3166::Country.new('US')
|
25
|
+
```
|
22
26
|
|
23
|
-
|
27
|
+
## Configuration
|
24
28
|
|
25
|
-
|
26
|
-
-----------
|
29
|
+
### Country Helper
|
27
30
|
|
28
|
-
|
31
|
+
Some apps might not want to constantly call `ISO3166::Country` this gem has a
|
32
|
+
helper that can provide a `Country` class
|
29
33
|
|
30
|
-
|
34
|
+
```ruby
|
35
|
+
# With global Country Helper
|
36
|
+
c = Country['US']
|
37
|
+
```
|
31
38
|
|
32
|
-
|
39
|
+
**This will conflict with any existing `Country` constant**
|
33
40
|
|
41
|
+
To Use
|
34
42
|
|
35
|
-
|
36
|
-
|
43
|
+
```ruby
|
44
|
+
gem 'countries', require: 'countries/global'
|
45
|
+
```
|
37
46
|
|
38
|
-
|
39
|
-
(is inherited from ISO3166::Country to keep backward compatibility).
|
47
|
+
## Upgrading to 4.2 and 5.x
|
40
48
|
|
41
|
-
|
49
|
+
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.
|
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.
|
64
|
+
|
65
|
+
You can add all the locales like this.
|
42
66
|
|
43
|
-
|
67
|
+
```ruby
|
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
|
+
```
|
44
72
|
|
45
|
-
|
46
|
-
|
73
|
+
or something a bit more simple
|
74
|
+
```ruby
|
75
|
+
ISO3166.configure do |config|
|
76
|
+
config.locales = [:en, :de, :fr, :es]
|
77
|
+
end
|
78
|
+
```
|
47
79
|
|
48
|
-
Attribute-Based Finder Methods
|
49
|
-
------------
|
80
|
+
## Attribute-Based Finder Methods
|
50
81
|
|
51
82
|
You can lookup a country or an array of countries using any of the data attributes via the find\_country\_by_*attribute* dynamic methods:
|
52
83
|
|
53
|
-
|
54
|
-
|
55
|
-
|
84
|
+
```ruby
|
85
|
+
c = ISO3166::Country.find_country_by_iso_short_name('united states')
|
86
|
+
h = ISO3166::Country.find_all_by(:translated_names, 'França')
|
87
|
+
list = ISO3166::Country.find_all_countries_by_region('Americas')
|
88
|
+
c = ISO3166::Country.find_country_by_alpha3('can')
|
89
|
+
```
|
90
|
+
|
91
|
+
For a list of available attributes please see `ISO3166::DEFAULT_COUNTRY_HASH`.
|
92
|
+
Note: searches are *case insensitive and ignore accents*.
|
93
|
+
|
94
|
+
_Please note that `find_by_name`, `find_by_names`, `find_*_by_name` and `find_*_by_names` methods are deprecated and will be removed in 5.0. See [Upgrading to 4.2 and 5.x](#upgrading-to-4-2-and-5-x) above_
|
95
|
+
|
96
|
+
|
97
|
+
## Country Info
|
98
|
+
|
99
|
+
### Identification Codes
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
c.number # => "840"
|
103
|
+
c.alpha2 # => "US"
|
104
|
+
c.alpha3 # => "USA"
|
105
|
+
c.gec # => "US"
|
106
|
+
```
|
107
|
+
|
108
|
+
### Names & Translations
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
c.iso_long_name # => "The United States of America"
|
112
|
+
c.iso_short_name # => "United States of America"
|
113
|
+
c.common_name # => "United States" (This is a shortcut for c.translations('en'))
|
114
|
+
c.unofficial_names # => ["United States of America", "Vereinigte Staaten von Amerika", "États-Unis", "Estados Unidos"]
|
115
|
+
|
116
|
+
# Get the names for a country translated to its local languages
|
117
|
+
c = Country[:BE]
|
118
|
+
c.local_names # => ["België", "Belgique", "Belgien"]
|
119
|
+
c.local_name # => "België"
|
56
120
|
|
57
|
-
|
58
|
-
|
121
|
+
# Get a specific translation
|
122
|
+
c.translation('de') # => 'Vereinigte Staaten von Amerika'
|
123
|
+
c.translations['fr'] # => "États-Unis"
|
59
124
|
|
60
|
-
Country
|
61
|
-
|
125
|
+
ISO3166::Country.translations # {"DE"=>"Germany",...}
|
126
|
+
ISO3166::Country.translations('DE') # {"DE"=>"Deutschland",...}
|
127
|
+
ISO3166::Country.all_translated # ['Germany', ...]
|
128
|
+
ISO3166::Country.all_translated('DE') # ['Deutschland', ...]
|
62
129
|
|
63
|
-
|
130
|
+
# Nationality
|
131
|
+
c.nationality # => "American"
|
132
|
+
```
|
64
133
|
|
65
|
-
|
66
|
-
c.alpha2 #=> "US"
|
67
|
-
c.alpha3 #=> "USA"
|
68
|
-
c.gec #=> "US"
|
134
|
+
### Subdivisions & States
|
69
135
|
|
70
|
-
|
136
|
+
```ruby
|
137
|
+
c.subdivisions # => {"CO" => {"name" => "Colorado", "names" => "Colorado"}, ... }
|
138
|
+
c.states # => {"CO" => {"name" => "Colorado", "names" => "Colorado"}, ... }
|
139
|
+
```
|
71
140
|
|
72
|
-
|
73
|
-
c.names #=> ["United States of America", "Vereinigte Staaten von Amerika", "États-Unis", "Estados Unidos"]
|
141
|
+
### Location
|
74
142
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
c.local_name #=> "België"
|
143
|
+
```ruby
|
144
|
+
c.latitude # => "37.09024"
|
145
|
+
c.longitude # => "-95.712891"
|
79
146
|
|
80
|
-
|
81
|
-
|
82
|
-
|
147
|
+
c.world_region # => "AMER"
|
148
|
+
c.region # => "Americas"
|
149
|
+
c.subregion # => "Northern America"
|
150
|
+
```
|
83
151
|
|
84
|
-
|
85
|
-
ISO3166::Country.translations('DE') # {"DE"=>"Deutschland",...}
|
86
|
-
ISO3166::Country.all_translated # ['Germany', ...]
|
87
|
-
ISO3166::Country.all_translated('DE') # ['Deutschland', ...]
|
152
|
+
Please note that `latitude_dec` and `longitude_dec` was be deprecated on release 4.2 and will be deleted in 5.0. These attributes have been redundant for several years, since the `latitude` and `longitude` fields have been switched decimal coordinates.
|
88
153
|
|
89
|
-
|
154
|
+
### Timezones **(optional)**
|
90
155
|
|
91
|
-
|
92
|
-
c.states #=> {"CO" => {"name" => "Colorado", "names" => "Colorado"}, ... }
|
156
|
+
Add `tzinfo` to your Gemfile and ensure it's required, Countries will not do this for you.
|
93
157
|
|
94
|
-
|
158
|
+
```ruby
|
159
|
+
gem 'tzinfo', '~> 1.2', '>= 1.2.2'
|
160
|
+
```
|
95
161
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
162
|
+
```ruby
|
163
|
+
c.timezones.zone_identifiers # => ["America/New_York", "America/Detroit", "America/Kentucky/Louisville", ...]
|
164
|
+
c.timezones.zone_info # see [tzinfo docs](https://www.rubydoc.info/gems/tzinfo/TZInfo/CountryTimezone)
|
165
|
+
c.timezones # see [tzinfo docs](https://www.rubydoc.info/gems/tzinfo/TZInfo/Country)
|
166
|
+
```
|
100
167
|
|
101
|
-
|
102
|
-
c.subregion #=> "Northern America"
|
168
|
+
### Telephone Routing (E164)
|
103
169
|
|
104
|
-
|
170
|
+
```ruby
|
171
|
+
c.country_code # => "1"
|
172
|
+
c.national_destination_code_lengths # => 3
|
173
|
+
c.national_number_lengths # => 10
|
174
|
+
c.international_prefix # => "011"
|
175
|
+
c.national_prefix # => "1"
|
176
|
+
```
|
105
177
|
|
106
|
-
|
107
|
-
c.national_destination_code_lengths #=> 3
|
108
|
-
c.national_number_lengths #=> 10
|
109
|
-
c.international_prefix #=> "011"
|
110
|
-
c.national_prefix #=> "1"
|
178
|
+
### Boundary Boxes
|
111
179
|
|
112
|
-
|
180
|
+
```ruby
|
181
|
+
c.min_longitude # => '45'
|
182
|
+
c.min_latitude # => '22.166667'
|
183
|
+
c.max_longitude # => '58'
|
184
|
+
c.max_latitude # => '26.133333'
|
113
185
|
|
114
|
-
|
115
|
-
|
116
|
-
c.max_longitude #=> '58'
|
117
|
-
c.max_latitude #=> '26.133333'
|
186
|
+
c.bounds #> {"northeast"=>{"lat"=>22.166667, "lng"=>58}, "southwest"=>{"lat"=>26.133333, "lng"=>45}}
|
187
|
+
```
|
118
188
|
|
119
|
-
|
189
|
+
### European Union Membership
|
120
190
|
|
121
|
-
|
191
|
+
```ruby
|
192
|
+
c.in_eu? # => false
|
193
|
+
```
|
122
194
|
|
123
|
-
|
124
|
-
----------
|
195
|
+
### European Economic Area Membership
|
125
196
|
|
126
|
-
|
197
|
+
```ruby
|
198
|
+
c.in_eea? # => false
|
199
|
+
```
|
127
200
|
|
128
|
-
c.currency['code'] #=> 'USD'
|
129
|
-
c.currency['name'] #=> 'Dollars'
|
130
|
-
c.currency['symbol'] #=> '$'
|
131
201
|
|
132
|
-
|
133
|
-
------------------
|
202
|
+
### European Single Market Membership
|
134
203
|
|
135
|
-
|
204
|
+
```ruby
|
205
|
+
c.in_esm? # => false
|
206
|
+
```
|
136
207
|
|
137
|
-
|
208
|
+
### Plucking multiple attributes
|
138
209
|
|
139
|
-
|
140
|
-
|
210
|
+
```ruby
|
211
|
+
ISO3166::Country.pluck(:alpha2, :iso_short_name) # => [["AD", "Andorra"], ["AE", "United Arab Emirates"], ...
|
212
|
+
```
|
213
|
+
|
214
|
+
## Currencies
|
215
|
+
|
216
|
+
To enable currencies extension please add the following to countries initializer.
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
ISO3166.configuration.enable_currency_extension!
|
220
|
+
```
|
221
|
+
|
222
|
+
Please note that it requires you to add "money" dependency to your gemfile.
|
223
|
+
|
224
|
+
```ruby
|
225
|
+
gem "money", "~> 6.9"
|
226
|
+
```
|
227
|
+
|
228
|
+
Countries now uses the [Money](https://github.com/RubyMoney/money) gem. What this means is you now get back a `Money::Currency` object that gives you access to all the currency information.
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
c = ISO3166::Country['us']
|
232
|
+
c.currency.iso_code # => 'USD'
|
233
|
+
c.currency.name # => 'United States Dollar'
|
234
|
+
c.currency.symbol # => '$'
|
235
|
+
```
|
236
|
+
|
237
|
+
## Address Formatting
|
238
|
+
|
239
|
+
A template for formatting addresses is available through the address_format method. These templates are compatible with the [Liquid](https://shopify.github.io/liquid/) template system.
|
240
|
+
|
241
|
+
```ruby
|
242
|
+
c.address_format # => "{{recipient}}\n{{street}}\n{{city}} {{region}} {{postalcode}}\n{{country}}"
|
243
|
+
```
|
244
|
+
|
245
|
+
## Loading Custom Data
|
246
|
+
|
247
|
+
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!
|
248
|
+
|
249
|
+
Any country registered this way will have its data available for searching etc... If you are overriding an existing country, for cultural reasons, our code uses a simple merge, not a deep merge so you will need to __bring in all data you wish to be available__. Bringing in an existing country will also remove it from the internal management of translations, __all registered countries will remain in memory__.
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
ISO3166::Data.register(
|
253
|
+
alpha2: 'LOL',
|
254
|
+
iso_short_name: 'Happy Country',
|
255
|
+
translations: {
|
256
|
+
'en' => 'Happy Country',
|
257
|
+
'de' => 'glückliches Land'
|
258
|
+
}
|
259
|
+
)
|
260
|
+
|
261
|
+
ISO3166::Country.new('LOL').iso_short_name == 'Happy Country'
|
262
|
+
```
|
263
|
+
|
264
|
+
## Mongoid
|
141
265
|
|
142
266
|
Mongoid support has been added. It is required automatically if Mongoid is defined in your project.
|
143
267
|
|
144
268
|
Use native country fields in your model:
|
145
269
|
|
146
|
-
|
270
|
+
```ruby
|
271
|
+
field :country, type: Country
|
272
|
+
```
|
147
273
|
|
148
274
|
Adds native support for searching/saving by a country object or alpha2 code.
|
149
275
|
|
150
276
|
Searching:
|
151
277
|
|
152
|
-
|
153
|
-
|
154
|
-
|
278
|
+
```ruby
|
279
|
+
# By alpha2
|
280
|
+
spanish_things = Things.where(country: 'ES')
|
281
|
+
spanish_things.first.country.iso_short_name # => "Spain"
|
155
282
|
|
156
|
-
|
157
|
-
|
158
|
-
|
283
|
+
# By object
|
284
|
+
spanish_things = Things.where(country: Country.find_by_iso_short_name('Spain')[1])
|
285
|
+
spanish_things.first.country.iso_short_name # => "Spain"
|
286
|
+
```
|
159
287
|
|
160
288
|
Saving:
|
161
289
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
290
|
+
```ruby
|
291
|
+
# By alpha2
|
292
|
+
spanish_things = Thing.new(country: 'ES')
|
293
|
+
spanish_things.save!
|
294
|
+
spanish_things.country.iso_short_name # => "Spain"
|
166
295
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
296
|
+
# By object
|
297
|
+
spanish_things = Thing.new(country: Country.find_by_iso_short_name('Spain')[1])
|
298
|
+
spanish_things.save!
|
299
|
+
spanish_things.country.iso_short_name # => "Spain"
|
300
|
+
```
|
171
301
|
|
172
302
|
Note that the database stores only the alpha2 code and rebuilds the object when queried. To return the country name by default you can override the reader method in your model:
|
173
303
|
|
174
|
-
|
175
|
-
|
176
|
-
|
304
|
+
```ruby
|
305
|
+
def country
|
306
|
+
super.iso_short_name
|
307
|
+
end
|
308
|
+
```
|
309
|
+
|
310
|
+
## Country Code in Emoji
|
177
311
|
|
178
|
-
|
179
|
-
|
312
|
+
```ruby
|
313
|
+
c = Country['MY']
|
314
|
+
c.emoji_flag # => "🇲🇾"
|
315
|
+
```
|
180
316
|
|
181
|
-
|
182
|
-
* Class methods for looking up information
|
183
|
-
* Default country
|
184
|
-
* Exclude countries
|
185
|
-
* Preferred countries
|
186
|
-
* Whitelist countries
|
317
|
+
## Note on Patches/Pull Requests
|
187
318
|
|
188
|
-
|
189
|
-
-----------------------------
|
319
|
+
### Please do not submit pull requests on `cache/**/*`
|
190
320
|
|
191
|
-
|
192
|
-
Any additions should be directed upstream to (pkg-isocodes)[http://anonscm.debian.org/cgit/pkg-isocodes/iso-codes.git/]
|
321
|
+
Any additions should be directed upstream to [pkg-isocodes](https://salsa.debian.org/iso-codes-team/iso-codes)
|
193
322
|
|
194
|
-
|
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
|
+
```
|
195
333
|
|
196
334
|
Any corrections can be applied in translations_corrections.yaml these will be injected during
|
197
|
-
the next
|
335
|
+
the next `rake update_cache`.
|
198
336
|
|
199
337
|
* Fork the project.
|
200
338
|
* Make your feature addition or bug fix.
|
@@ -205,16 +343,10 @@ the next ```rake update_cache```
|
|
205
343
|
bump version in a commit by itself I can ignore when I pull)
|
206
344
|
* Send me a pull request. Bonus points for topic branches.
|
207
345
|
|
208
|
-
Copyright
|
209
|
-
---------
|
210
|
-
|
211
|
-
Copyright (c) 2015 hexorx. See LICENSE for details.
|
346
|
+
## Copyright
|
212
347
|
|
348
|
+
Copyright (c) 2012-2015 hexorx
|
349
|
+
Copyright (c) 2015-2021 hexorx, rposborne
|
350
|
+
Copyright (c) 2022 hexorx, rposborne, pmor
|
213
351
|
|
214
|
-
|
215
|
-
[Centrex]: http://en.wikipedia.org/wiki/Centrex
|
216
|
-
[CommonDataHub]: http://commondatahub.com
|
217
|
-
[Currencies]: http://gemcutter.org/gems/currencies
|
218
|
-
[Money]: http://gemcutter.org/gems/money
|
219
|
-
[Liquid]: http://www.liquidmarkup.org/
|
220
|
-
[country_select]: https://github.com/stefanpenner/country_select
|
352
|
+
See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -3,28 +3,27 @@ require 'bundler/gem_tasks'
|
|
3
3
|
|
4
4
|
require 'rake'
|
5
5
|
require 'rspec/core/rake_task'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
ISO3166_ROOT_PATH = File.dirname(__FILE__)
|
9
|
+
|
10
|
+
# Enter your API Key enabled for Geocoding API and Places API
|
11
|
+
GOOGLE_API_KEY = 'ENTER API KEY'
|
12
|
+
|
13
|
+
Dir.glob('lib/countries/tasks/*.rake').each { |r| load r }
|
6
14
|
|
7
15
|
desc 'Run all examples'
|
8
16
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
9
|
-
t.rspec_opts = %w
|
17
|
+
t.rspec_opts = %w[--color --warnings]
|
10
18
|
end
|
11
19
|
|
12
20
|
task default: [:spec]
|
13
21
|
|
14
|
-
desc '
|
15
|
-
task :
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
d.each do |file|
|
20
|
-
begin
|
21
|
-
puts "checking : #{file}"
|
22
|
-
data = YAML.load_file(file)
|
23
|
-
File.open(file, 'w') { |f| f.write data.to_yaml }
|
24
|
-
rescue
|
25
|
-
puts "failed to read #{file}: #{$ERROR_INFO}"
|
26
|
-
end
|
27
|
-
end
|
22
|
+
desc 'Update CLDR subdivison data set'
|
23
|
+
task :update_cldr_subdivison_data do
|
24
|
+
require_relative './lib/countries/sources'
|
25
|
+
Sources::CLDR::Downloader.subdivisions
|
26
|
+
Sources::CLDR::SubdivisionUpdater.new.call
|
28
27
|
end
|
29
28
|
|
30
29
|
desc 'Update Cache'
|
@@ -32,12 +31,15 @@ task :update_cache do
|
|
32
31
|
require 'yaml'
|
33
32
|
require 'i18n_data'
|
34
33
|
|
35
|
-
codes =
|
34
|
+
codes = Dir['lib/countries/data/countries/*.yaml'].map { |x| File.basename(x, File.extname(x)) }.uniq.sort
|
36
35
|
data = {}
|
37
|
-
|
36
|
+
|
38
37
|
corrections = YAML.load_file(File.join(File.dirname(__FILE__), 'lib', 'countries', 'data', 'translation_corrections.yaml')) || {}
|
39
38
|
|
40
|
-
I18nData.languages.keys
|
39
|
+
language_keys = I18nData.languages.keys + ['zh_CN', 'zh_TW', 'zh_HK','bn_IN','pt_BR']
|
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|
|
41
43
|
locale = locale.downcase
|
42
44
|
begin
|
43
45
|
local_names = I18nData.countries(locale)
|
@@ -52,66 +54,34 @@ task :update_cache do
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
|
56
|
-
data[alpha2] ||= YAML.load_file(File.join(File.dirname(__FILE__), 'lib', 'countries', 'data', 'countries', "#{alpha2}.yaml"))[alpha2]
|
57
|
-
data[alpha2]['translations'] ||= empty_translations_hash.dup
|
58
|
-
data[alpha2]['translations'][locale] = local_names[alpha2]
|
59
|
-
data[alpha2]['translated_names'] ||= []
|
60
|
-
data[alpha2]['translated_names'] << local_names[alpha2]
|
61
|
-
data[alpha2]['translated_names'] = data[alpha2]['translated_names'].uniq
|
62
|
-
end
|
57
|
+
File.open(File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'locales', "#{locale.gsub(/_/, '-')}.json"), 'wb') { |f| f.write(local_names.to_json) }
|
63
58
|
end
|
64
59
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
require 'geocoder'
|
69
|
-
require 'retryable'
|
70
|
-
# raise on geocoding errors such as query limit exceeded
|
71
|
-
Geocoder.configure(always_raise: :all)
|
72
|
-
# Try to geocode a given query, on exceptions it retries up to 3 times then gives up.
|
73
|
-
# @param [String] query string to geocode
|
74
|
-
# @return [Hash] first valid result or nil
|
75
|
-
def geocode(query)
|
76
|
-
Retryable.retryable(tries: 3, sleep: lambda { |n| 2**n }) do
|
77
|
-
Geocoder.search(query).first
|
60
|
+
codes.each do |alpha2|
|
61
|
+
data[alpha2] ||= YAML.load_file(File.join(File.dirname(__FILE__), 'lib', 'countries', 'data', 'countries', "#{alpha2}.yaml"))[alpha2]
|
78
62
|
end
|
79
|
-
|
80
|
-
|
81
|
-
nil
|
63
|
+
|
64
|
+
File.open(File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'countries.json'), 'wb') { |f| f.write(data.to_json) }
|
82
65
|
end
|
83
66
|
|
84
|
-
|
85
|
-
task :
|
86
|
-
require '
|
87
|
-
|
88
|
-
ISO3166::Country.all.select(&:subdivisions?).each do |c|
|
89
|
-
# Iterate subdivisions
|
90
|
-
state_data = c.subdivisions.dup
|
91
|
-
state_data.reject { |_, data| data['latitude'] }.each do |code, data|
|
92
|
-
location = "#{data['name']}, #{c.name}"
|
93
|
-
|
94
|
-
# Handle special geocoding cases where Google defaults to well known
|
95
|
-
# cities, instead of the states.
|
96
|
-
if c.alpha2 == 'US' && %w(NY WA OK).include?(code)
|
97
|
-
location = "#{data['name']} State, United States"
|
98
|
-
end
|
67
|
+
# Temporary task to update YAML file structure with iso_long_name and iso_short_name attributes
|
68
|
+
task :update_iso_names do
|
69
|
+
require 'csv'
|
70
|
+
isodata = CSV.read 'isonames.csv', headers: true
|
99
71
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
# Write updated YAML for current country
|
115
|
-
File.open(File.join(File.dirname(__FILE__), 'lib', 'data', 'subdivisions', "#{c.alpha2}.yaml"), 'w+') { |f| f.write state_data.to_yaml }
|
72
|
+
d = Dir['lib/countries/data/countries/*.yaml']
|
73
|
+
d.each do |file|
|
74
|
+
puts "checking : #{file}"
|
75
|
+
data = YAML.load_file(file)
|
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 }
|
116
86
|
end
|
117
|
-
end
|
87
|
+
end
|