countries 1.2.2 β 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 +4 -1
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +52 -0
- data/CHANGELOG.md +570 -1
- data/Gemfile +7 -0
- data/LICENSE +3 -1
- data/README.markdown +261 -136
- 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 +32 -23
- 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 +946 -122
- 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 +1124 -145
- 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 +38 -1
- 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 -6
- 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/spec/country_spec.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'spec_helper'
|
4
|
+
NUM_OF_COUNTRIES = 249
|
5
5
|
describe ISO3166::Country do
|
6
|
+
before { ISO3166.configuration.enable_currency_extension! }
|
6
7
|
let(:country) { ISO3166::Country.search('US') }
|
7
8
|
|
8
9
|
it 'allows to create a country object from a symbol representation of the alpha2 code' do
|
@@ -15,6 +16,21 @@ describe ISO3166::Country do
|
|
15
16
|
expect(country.data).not_to be_nil
|
16
17
|
end
|
17
18
|
|
19
|
+
it 'allows countries to be compared' do
|
20
|
+
c1 = ISO3166::Country.new('US')
|
21
|
+
c2 = ISO3166::Country.new('US')
|
22
|
+
c3 = ISO3166::Country.new('AU')
|
23
|
+
expect(c1).to eq(c2)
|
24
|
+
expect(c1).to_not eq(nil)
|
25
|
+
expect(c1.hash).to eq(c2.hash)
|
26
|
+
expect(c3.hash).to_not eq(c2.hash)
|
27
|
+
|
28
|
+
hsh = {}
|
29
|
+
hsh[c1] = 1
|
30
|
+
hsh[c2] = 2
|
31
|
+
expect(hsh.keys.count).to eq 1
|
32
|
+
end
|
33
|
+
|
18
34
|
it 'should return 3166 number' do
|
19
35
|
expect(country.number).to eq('840')
|
20
36
|
end
|
@@ -27,12 +43,12 @@ describe ISO3166::Country do
|
|
27
43
|
expect(country.alpha3).to eq('USA')
|
28
44
|
end
|
29
45
|
|
30
|
-
it 'should return 3166
|
31
|
-
expect(country.
|
46
|
+
it 'should return 3166 iso_short_name' do
|
47
|
+
expect(country.iso_short_name).to eq('United States of America')
|
32
48
|
end
|
33
49
|
|
34
50
|
it 'should return alternate names' do
|
35
|
-
expect(country.
|
51
|
+
expect(country.unofficial_names).to eq(['United States', 'USA', 'Murica', 'Vereinigte Staaten von Amerika', 'Γtats-Unis', 'Estados Unidos', 'γ’γ‘γͺγ«εθ‘ε½', 'Verenigde Staten'])
|
36
52
|
end
|
37
53
|
|
38
54
|
it 'should return translations' do
|
@@ -41,19 +57,15 @@ describe ISO3166::Country do
|
|
41
57
|
end
|
42
58
|
|
43
59
|
it 'should return latitude' do
|
44
|
-
expect(country.latitude).to eq(
|
60
|
+
expect(country.latitude).to eq(37.09024)
|
45
61
|
end
|
46
62
|
|
47
63
|
it 'should return longitude' do
|
48
|
-
expect(country.longitude).to eq(
|
64
|
+
expect(country.longitude).to eq(-95.712891)
|
49
65
|
end
|
50
66
|
|
51
|
-
it 'should return
|
52
|
-
expect(country.
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should return the decimal Longitude' do
|
56
|
-
expect(country.longitude_dec).to eq('-98.95733642578125')
|
67
|
+
it 'should return bounds' do
|
68
|
+
expect(country.bounds['northeast']['lat']).to eq(71.3577635769)
|
57
69
|
end
|
58
70
|
|
59
71
|
it 'should return continent' do
|
@@ -65,8 +77,18 @@ describe ISO3166::Country do
|
|
65
77
|
end
|
66
78
|
|
67
79
|
it 'knows when a country does not require postal codes' do
|
68
|
-
|
69
|
-
expect(
|
80
|
+
antarctica = ISO3166::Country.search('AQ')
|
81
|
+
expect(antarctica.postal_code).to eq(false)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'knows about the country postal code format' do
|
85
|
+
expect(country.postal_code_format).to_not be_nil
|
86
|
+
|
87
|
+
regex = Regexp.new(country.postal_code_format)
|
88
|
+
expect(regex).to match("12345-6789")
|
89
|
+
|
90
|
+
antarctica = ISO3166::Country.search('AQ')
|
91
|
+
expect(antarctica.postal_code_format).to be_nil
|
70
92
|
end
|
71
93
|
|
72
94
|
it 'should return region' do
|
@@ -109,6 +131,55 @@ describe ISO3166::Country do
|
|
109
131
|
end
|
110
132
|
end
|
111
133
|
|
134
|
+
context 'with Brazil' do
|
135
|
+
context 'with pt-BR translation' do
|
136
|
+
before do
|
137
|
+
ISO3166::Data.register(
|
138
|
+
alpha2: 'BR2',
|
139
|
+
iso_short_name: 'Brazil',
|
140
|
+
languages_official: %w(pt-BR),
|
141
|
+
translations: {
|
142
|
+
'pt-BR' => 'Translation for pt-BR',
|
143
|
+
'pt' => 'Translation for pt'
|
144
|
+
}
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
let(:country) { ISO3166::Country.search('BR2') }
|
149
|
+
|
150
|
+
it 'should return its local name based on its language' do
|
151
|
+
expect(country.local_names).to match_array(['Translation for pt-BR'])
|
152
|
+
end
|
153
|
+
|
154
|
+
after do
|
155
|
+
ISO3166::Data.unregister('BR2')
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'without pt-BR translation' do
|
160
|
+
before do
|
161
|
+
ISO3166::Data.register(
|
162
|
+
alpha2: 'BR2',
|
163
|
+
iso_short_name: 'Brazil',
|
164
|
+
languages_official: %w(pt-BR),
|
165
|
+
translations: {
|
166
|
+
'pt' => 'Translation for pt'
|
167
|
+
}
|
168
|
+
)
|
169
|
+
end
|
170
|
+
|
171
|
+
let(:country) { ISO3166::Country.search('BR2') }
|
172
|
+
|
173
|
+
it 'should return its local name based on its language' do
|
174
|
+
expect(country.local_names).to match_array(['Translation for pt'])
|
175
|
+
end
|
176
|
+
|
177
|
+
after do
|
178
|
+
ISO3166::Data.unregister('BR2')
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
112
183
|
it 'should return ioc code' do
|
113
184
|
expect(country.ioc).to eq('USA')
|
114
185
|
end
|
@@ -148,16 +219,53 @@ describe ISO3166::Country do
|
|
148
219
|
end
|
149
220
|
|
150
221
|
describe 'subdivisions' do
|
222
|
+
let(:virginia) { country.states['VA'] }
|
151
223
|
it 'should return an empty hash for a country with no ISO3166-2' do
|
152
224
|
expect(ISO3166::Country.search('VA').subdivisions.size).to eq(0)
|
153
225
|
end
|
154
226
|
|
155
227
|
it 'should return a hash with all sub divisions' do
|
156
|
-
expect(country.subdivisions.size).to eq(
|
228
|
+
expect(country.subdivisions.size).to eq(57)
|
157
229
|
end
|
158
230
|
|
159
231
|
it 'should be available through states' do
|
160
|
-
expect(country.states.size).to eq(
|
232
|
+
expect(country.states.size).to eq(57)
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'should be a subdivision object' do
|
236
|
+
expect(virginia).to be_a(ISO3166::Subdivision)
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'should have a name' do
|
240
|
+
expect(virginia.name).to eq('Virginia')
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'should have a code' do
|
244
|
+
expect(virginia.code).to eq('VA')
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should behave like a hash' do
|
248
|
+
expect(virginia['name']).to eq('Virginia')
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe 'subdivision_names_with_codes' do
|
253
|
+
it 'should return an alphabetized list of all subdivisions names with codes' do
|
254
|
+
subdivisions = ISO3166::Country.search('EG').subdivision_names_with_codes
|
255
|
+
expect(subdivisions).to be_an(Array)
|
256
|
+
expect(subdivisions.first[0]).to be_a(String)
|
257
|
+
expect(subdivisions.size).to eq(27)
|
258
|
+
expect(subdivisions.first[0]).to eq('Alexandria')
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'should return an alphabetized list of subdivision names translated to current locale with codes' do
|
262
|
+
ISO3166.configuration.locales = [:es, :de, :en]
|
263
|
+
|
264
|
+
subdivisions = ISO3166::Country.search('EG').subdivision_names_with_codes(:es)
|
265
|
+
expect(subdivisions).to be_an(Array)
|
266
|
+
expect(subdivisions.first[0]).to be_a(String)
|
267
|
+
expect(subdivisions.size).to eq(27)
|
268
|
+
expect(subdivisions.first[0]).to eq('Al Iskandariyah')
|
161
269
|
end
|
162
270
|
end
|
163
271
|
|
@@ -203,15 +311,15 @@ describe ISO3166::Country do
|
|
203
311
|
countries = ISO3166::Country.all
|
204
312
|
expect(countries).to be_an(Array)
|
205
313
|
expect(countries.first).to be_an(ISO3166::Country)
|
206
|
-
expect(countries.size).to eq(
|
314
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
207
315
|
end
|
208
316
|
|
209
317
|
it 'should allow to customize each country representation passing a block to the method' do
|
210
|
-
countries = ISO3166::Country.all { |country, data| [data['
|
318
|
+
countries = ISO3166::Country.all { |country, data| [data['iso_short_name'], country, data['country_code']] }
|
211
319
|
expect(countries).to be_an(Array)
|
212
320
|
expect(countries.first).to be_an(Array)
|
213
321
|
expect(countries.first.size).to eq(3)
|
214
|
-
expect(countries.size).to eq(
|
322
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
215
323
|
end
|
216
324
|
end
|
217
325
|
|
@@ -220,18 +328,38 @@ describe ISO3166::Country do
|
|
220
328
|
countries = ISO3166::Country.all_translated('fr')
|
221
329
|
expect(countries).to be_an(Array)
|
222
330
|
expect(countries.first).to be_a(String)
|
223
|
-
expect(countries.first).to eq('
|
331
|
+
expect(countries.first).to eq('Aruba')
|
224
332
|
# countries missing the desired locale will not be added to the list
|
225
333
|
# so all 250 countries may not be returned, 'fr' returns 249, for example
|
226
|
-
expect(countries.size).to eq(
|
334
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
227
335
|
end
|
228
336
|
|
229
337
|
it 'should return an alphabetized list of all country names in English if no locale is passed' do
|
230
338
|
countries = ISO3166::Country.all_translated
|
231
339
|
expect(countries).to be_an(Array)
|
232
340
|
expect(countries.first).to be_a(String)
|
233
|
-
expect(countries.first).to eq('
|
234
|
-
expect(countries.size).to eq(
|
341
|
+
expect(countries.first).to eq('Aruba')
|
342
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
343
|
+
end
|
344
|
+
|
345
|
+
context 'with custom countries' do
|
346
|
+
before do
|
347
|
+
ISO3166::Data.register(
|
348
|
+
alpha2: 'XX',
|
349
|
+
iso_short_name: 'Custom Country',
|
350
|
+
translations: { 'en' => 'Custom Country' }
|
351
|
+
)
|
352
|
+
end
|
353
|
+
|
354
|
+
it 'should include custom registered countries' do
|
355
|
+
custom_country = ISO3166::Country.find_by_alpha2('XX')[1]
|
356
|
+
countries = ISO3166::Country.all_translated
|
357
|
+
expect(countries).to include(custom_country['iso_short_name'])
|
358
|
+
end
|
359
|
+
|
360
|
+
after do
|
361
|
+
ISO3166::Data.unregister('XX')
|
362
|
+
end
|
235
363
|
end
|
236
364
|
end
|
237
365
|
|
@@ -242,12 +370,44 @@ describe ISO3166::Country do
|
|
242
370
|
expect(countries).to be_an(Array)
|
243
371
|
expect(countries.first[0]).to be_a(String)
|
244
372
|
expect(countries.first[0]).to eq('Afghanistan')
|
245
|
-
expect(countries.size).to eq(
|
373
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
374
|
+
expect(countries.any?{|pair| !pair[0].html_safe?}).to eq(false)
|
375
|
+
end
|
376
|
+
|
377
|
+
it 'should return an alphabetized list of all country names translated to current locale with ISOCODE alpha2' do
|
378
|
+
ISO3166.configuration.locales = [:es, :de, :en]
|
379
|
+
|
380
|
+
countries = ISO3166::Country.all_names_with_codes(:es)
|
381
|
+
expect(countries).to be_an(Array)
|
382
|
+
expect(countries.first[0]).to be_a(String)
|
383
|
+
expect(countries.first[0]).to eq('AfganistΓ‘n')
|
384
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe 'all_names_with_codes_without_active_support' do
|
389
|
+
it 'should return an alphabetized list of all country names with ISOCODE alpha2' do
|
390
|
+
countries = ISO3166::Country.all_names_with_codes
|
391
|
+
expect(countries).to be_an(Array)
|
392
|
+
expect(countries.first[0]).to be_a(String)
|
393
|
+
expect(countries.first[0]).to eq('Afghanistan')
|
394
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'should return an alphabetized list of all country names translated to current locale with ISOCODE alpha2' do
|
398
|
+
ISO3166.configuration.locales = [:es, :de, :en]
|
399
|
+
|
400
|
+
countries = ISO3166::Country.all_names_with_codes(:es)
|
401
|
+
expect(countries).to be_an(Array)
|
402
|
+
expect(countries.first[0]).to be_a(String)
|
403
|
+
expect(countries.first[0]).to eq('AfganistΓ‘n')
|
404
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
246
405
|
end
|
247
406
|
end
|
248
407
|
|
249
408
|
describe 'translation' do
|
250
409
|
it 'should return the localized name for a country to the selected locale' do
|
410
|
+
ISO3166.configuration.locales = [:es, :de, :en]
|
251
411
|
countries = ISO3166::Country.new(:de).translation('de')
|
252
412
|
expect(countries).to be_an(String)
|
253
413
|
expect(countries).to eq('Deutschland')
|
@@ -263,25 +423,42 @@ describe ISO3166::Country do
|
|
263
423
|
countries = ISO3166::Country.new(:de).translation('xxx')
|
264
424
|
expect(countries).to be_nil
|
265
425
|
end
|
426
|
+
|
427
|
+
context 'should return variant locales' do
|
428
|
+
it 'should return different value for Chinese variants' do
|
429
|
+
ISO3166.configuration.locales = [:'zh-cn', :'zh-hk', :'zh-tw']
|
430
|
+
name_cn = ISO3166::Country['TW'].translation('zh-cn')
|
431
|
+
name_hk = ISO3166::Country['TW'].translation('zh-hk')
|
432
|
+
name_tw = ISO3166::Country['TW'].translation('zh-tw')
|
433
|
+
expect([name_cn, name_hk, name_tw].uniq.size).to eql 3
|
434
|
+
end
|
435
|
+
|
436
|
+
it 'should return different value for Portuguese variants' do
|
437
|
+
ISO3166.configuration.locales = [:pt, :'pt-br']
|
438
|
+
name_pt = ISO3166::Country['SG'].translation('pt')
|
439
|
+
name_br = ISO3166::Country['SG'].translation('pt-br')
|
440
|
+
expect([name_pt, name_br].uniq.size).to eql 2
|
441
|
+
end
|
442
|
+
end
|
266
443
|
end
|
267
444
|
|
268
445
|
describe 'translations' do
|
269
446
|
it 'should return an hash of all country names translated to the selected locale' do
|
270
447
|
countries = ISO3166::Country.translations('fr')
|
271
448
|
expect(countries).to be_an(Hash)
|
272
|
-
expect(countries.first[0]).to eq('
|
273
|
-
expect(countries.first).to eq(%w(
|
449
|
+
expect(countries.first[0]).to eq('AW')
|
450
|
+
expect(countries.first).to eq(%w(AW Aruba))
|
274
451
|
# countries missing the desired locale will not be added to the list
|
275
452
|
# so all 250 countries may not be returned, 'fr' returns 249, for example
|
276
|
-
expect(countries.size).to eq(
|
453
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
277
454
|
end
|
278
455
|
|
279
456
|
it 'should return an hash of all country names in English if no locale is passed' do
|
280
457
|
countries = ISO3166::Country.translations
|
281
458
|
expect(countries).to be_an(Hash)
|
282
|
-
expect(countries.first[0]).to eq('
|
283
|
-
expect(countries.first).to eq(%w(
|
284
|
-
expect(countries.size).to eq(
|
459
|
+
expect(countries.first[0]).to eq('AW')
|
460
|
+
expect(countries.first).to eq(%w(AW Aruba))
|
461
|
+
expect(countries.size).to eq(NUM_OF_COUNTRIES)
|
285
462
|
end
|
286
463
|
end
|
287
464
|
|
@@ -311,48 +488,18 @@ describe ISO3166::Country do
|
|
311
488
|
|
312
489
|
describe 'currency' do
|
313
490
|
it 'should return an instance of Currency' do
|
314
|
-
expect(country.currency).to be_a(
|
491
|
+
expect(country.currency).to be_a(Money::Currency)
|
315
492
|
end
|
316
493
|
|
317
494
|
it 'should allow access to symbol' do
|
318
|
-
expect(country.currency
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
describe 'Country class' do
|
323
|
-
context "when loaded via 'iso3166' existance" do
|
324
|
-
subject { defined?(Country) }
|
325
|
-
|
326
|
-
it { is_expected.to be_falsey }
|
327
|
-
end
|
328
|
-
|
329
|
-
context "when loaded via 'global'" do
|
330
|
-
before { require 'countries/global' }
|
331
|
-
|
332
|
-
describe 'existance' do
|
333
|
-
subject { defined?(Country) }
|
334
|
-
|
335
|
-
it { is_expected.to be_truthy }
|
336
|
-
end
|
337
|
-
|
338
|
-
describe 'superclass' do
|
339
|
-
subject { Country.superclass }
|
340
|
-
|
341
|
-
it { is_expected.to eq(ISO3166::Country) }
|
342
|
-
end
|
343
|
-
|
344
|
-
describe 'to_s' do
|
345
|
-
it 'should return the country name' do
|
346
|
-
expect(Country.new('GB').to_s).to eq('United Kingdom')
|
347
|
-
end
|
348
|
-
end
|
495
|
+
expect(country.currency.symbol).to eq('$')
|
349
496
|
end
|
350
497
|
end
|
351
498
|
|
352
499
|
describe 'codes' do
|
353
500
|
it 'returns a hash with the data of the country' do
|
354
501
|
expect(ISO3166::Country.codes).to be_a Array
|
355
|
-
expect(ISO3166::Country.codes.size).to eq(
|
502
|
+
expect(ISO3166::Country.codes.size).to eq(NUM_OF_COUNTRIES)
|
356
503
|
end
|
357
504
|
end
|
358
505
|
|
@@ -394,29 +541,106 @@ describe ISO3166::Country do
|
|
394
541
|
end
|
395
542
|
|
396
543
|
it 'also performs searches with regexps and forces it to ignore case' do
|
397
|
-
spain_data = ISO3166::Country.find_all_by(:
|
544
|
+
spain_data = ISO3166::Country.find_all_by(:unofficial_names, /EspaΓ±/)
|
398
545
|
expect(spain_data).to be_a Hash
|
399
546
|
expect(spain_data.keys).to eq(['ES'])
|
400
547
|
end
|
548
|
+
|
549
|
+
it 'performs reasonably' do
|
550
|
+
start = Time.now
|
551
|
+
250.times do
|
552
|
+
lookup = ['ZM', 'ZMB', 'Zambia', 'US', 'USA', 'United States'].sample
|
553
|
+
case lookup.length
|
554
|
+
when 2 then ISO3166::Country.find_all_by(:alpha2, lookup)
|
555
|
+
when 3 then ISO3166::Country.find_all_by(:alpha3, lookup)
|
556
|
+
else ISO3166::Country.find_all_by(:iso_short_name, lookup)
|
557
|
+
end
|
558
|
+
end
|
559
|
+
expect(Time.now - start).to be < 1
|
560
|
+
end
|
401
561
|
end
|
402
562
|
|
403
563
|
describe 'hash finder methods' do
|
404
|
-
context "when search name in '
|
405
|
-
subject { ISO3166::Country.
|
564
|
+
context "when search name in 'iso_short_name'" do
|
565
|
+
subject { ISO3166::Country.find_by_iso_short_name('Poland') }
|
566
|
+
it 'should return' do
|
567
|
+
expect(subject.first).to eq('PL')
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
context "when search lowercase name in 'iso_short_name'" do
|
572
|
+
subject { ISO3166::Country.find_by_iso_short_name('poland') }
|
406
573
|
it 'should return' do
|
407
574
|
expect(subject.first).to eq('PL')
|
408
575
|
end
|
409
576
|
end
|
410
577
|
|
411
|
-
context "when search
|
412
|
-
subject { ISO3166::Country.
|
578
|
+
context "when search name with comma in 'iso_short_name'" do
|
579
|
+
subject { ISO3166::Country.find_by_iso_short_name(country_name) }
|
580
|
+
|
581
|
+
context 'with Republic of Korea' do
|
582
|
+
let(:country_name) { 'Korea, Republic of' }
|
583
|
+
it 'should return' do
|
584
|
+
expect(subject.first).to eq('KR')
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
context 'with Bolivia' do
|
589
|
+
let(:country_name) { 'Bolivia, Plurinational State of' }
|
590
|
+
it 'should return' do
|
591
|
+
expect(subject.first).to eq('BO')
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
595
|
+
context 'with Bonaire' do
|
596
|
+
let(:country_name) { 'Bonaire, Sint Eustatius and Saba' }
|
597
|
+
it 'should return' do
|
598
|
+
expect(subject.first).to eq('BQ')
|
599
|
+
end
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
context 'when search lowercase multibyte name found' do
|
604
|
+
subject { ISO3166::Country.find_country_by_unofficial_names('ΡΠΎΡΡΠΈΡ') }
|
605
|
+
|
606
|
+
it 'should be a country instance' do
|
607
|
+
expect(subject).to be_a(ISO3166::Country)
|
608
|
+
expect(subject.alpha2).to eq('RU')
|
609
|
+
end
|
610
|
+
end
|
611
|
+
|
612
|
+
context 'when search lowercase multibyte name found' do
|
613
|
+
subject { ISO3166::Country.find_country_by_unofficial_names(/ΡΠΎΡΡΠΈΡ/) }
|
614
|
+
|
615
|
+
it 'should be a country instance' do
|
616
|
+
expect(subject).to be_a(ISO3166::Country)
|
617
|
+
expect(subject.alpha2).to eq('RU')
|
618
|
+
end
|
619
|
+
end
|
620
|
+
|
621
|
+
context 'when accents are not used' do
|
622
|
+
subject { ISO3166::Country.find_country_by_unofficial_names('emirats Arabes Unis') }
|
623
|
+
|
624
|
+
it 'should be a country instance' do
|
625
|
+
expect(subject).to be_a(ISO3166::Country)
|
626
|
+
expect(subject.alpha2).to eq('AE')
|
627
|
+
end
|
628
|
+
end
|
629
|
+
|
630
|
+
context "when search name in 'unofficial_names'" do
|
631
|
+
subject { ISO3166::Country.find_by_unofficial_names('Polonia') }
|
413
632
|
it 'should return' do
|
414
633
|
expect(subject.first).to eq('PL')
|
415
634
|
end
|
416
635
|
end
|
417
636
|
|
418
|
-
context "when search name in '
|
419
|
-
|
637
|
+
context "when search name in 'translated_names'" do
|
638
|
+
before do
|
639
|
+
ISO3166.configure do |config|
|
640
|
+
config.locales = [:bs]
|
641
|
+
end
|
642
|
+
end
|
643
|
+
subject { ISO3166::Country.find_by_translated_names('Poljska') }
|
420
644
|
it 'should return' do
|
421
645
|
expect(subject.first).to eq('PL')
|
422
646
|
end
|
@@ -449,7 +673,7 @@ describe ISO3166::Country do
|
|
449
673
|
|
450
674
|
describe 'country finder methods' do
|
451
675
|
context 'when search name found' do
|
452
|
-
let(:uk) { ISO3166::Country.
|
676
|
+
let(:uk) { ISO3166::Country.find_country_by_unofficial_names('United Kingdom') }
|
453
677
|
|
454
678
|
it 'should be a country instance' do
|
455
679
|
expect(uk).to be_a(ISO3166::Country)
|
@@ -458,7 +682,7 @@ describe ISO3166::Country do
|
|
458
682
|
end
|
459
683
|
|
460
684
|
context 'when search lowercase name found' do
|
461
|
-
let(:uk) { ISO3166::Country.
|
685
|
+
let(:uk) { ISO3166::Country.find_country_by_unofficial_names('united kingdom') }
|
462
686
|
|
463
687
|
it 'should be a country instance' do
|
464
688
|
expect(uk).to be_a(ISO3166::Country)
|
@@ -466,7 +690,21 @@ describe ISO3166::Country do
|
|
466
690
|
end
|
467
691
|
end
|
468
692
|
|
693
|
+
context 'when the search term contains comma' do
|
694
|
+
let(:korea) { ISO3166::Country.find_country_by_unofficial_names('Korea, Republic of') }
|
695
|
+
|
696
|
+
it 'should be a country instance' do
|
697
|
+
expect(korea).to be_a(ISO3166::Country)
|
698
|
+
expect(korea.alpha2).to eq('KR')
|
699
|
+
end
|
700
|
+
end
|
701
|
+
|
469
702
|
context 'when search translation found' do
|
703
|
+
before do
|
704
|
+
ISO3166.configure do |config|
|
705
|
+
config.locales = [:bs]
|
706
|
+
end
|
707
|
+
end
|
470
708
|
let(:uk) { ISO3166::Country.find_country_by_translated_names('Velika Britanija') }
|
471
709
|
|
472
710
|
it 'should be a country instance' do
|
@@ -475,8 +713,24 @@ describe ISO3166::Country do
|
|
475
713
|
end
|
476
714
|
end
|
477
715
|
|
716
|
+
context 'regression test for #388' do
|
717
|
+
let(:no_country) { ISO3166::Country.find_country_by_translated_names(nil) }
|
718
|
+
|
719
|
+
it 'should be a country instance' do
|
720
|
+
expect(no_country).to_not be_a(ISO3166::Country)
|
721
|
+
expect(no_country).to eq nil
|
722
|
+
end
|
723
|
+
end
|
724
|
+
|
725
|
+
context 'when attempting to search by translations hash' do
|
726
|
+
let(:uk) { ISO3166::Country.find_country_by_translations({}) }
|
727
|
+
|
728
|
+
it 'should be a country instance' do
|
729
|
+
expect { uk }.to raise_error(RuntimeError)
|
730
|
+
end
|
731
|
+
end
|
478
732
|
context 'when search name not found' do
|
479
|
-
let(:bogus) { ISO3166::Country.
|
733
|
+
let(:bogus) { ISO3166::Country.find_country_by_unofficial_names('Does not exist') }
|
480
734
|
|
481
735
|
it 'should be a country instance' do
|
482
736
|
expect(bogus).to eq(nil)
|
@@ -485,7 +739,7 @@ describe ISO3166::Country do
|
|
485
739
|
|
486
740
|
# Spot checks #243
|
487
741
|
context 'when search name not found' do
|
488
|
-
let(:belgium) { ISO3166::Country.
|
742
|
+
let(:belgium) { ISO3166::Country.find_country_by_unofficial_names('Belgium') }
|
489
743
|
|
490
744
|
it 'should be a country instance' do
|
491
745
|
expect(belgium.alpha2).to eq('BE')
|
@@ -494,7 +748,7 @@ describe ISO3166::Country do
|
|
494
748
|
|
495
749
|
# Spot checks #240
|
496
750
|
context 'when search name not found' do
|
497
|
-
let(:canada) { ISO3166::Country.
|
751
|
+
let(:canada) { ISO3166::Country.find_country_by_unofficial_names('Canada') }
|
498
752
|
|
499
753
|
it 'should be a country instance' do
|
500
754
|
expect(canada.alpha2).to eq('CA')
|
@@ -503,7 +757,7 @@ describe ISO3166::Country do
|
|
503
757
|
|
504
758
|
# Spot checks #241
|
505
759
|
context 'when search name not found' do
|
506
|
-
let(:israel) { ISO3166::Country.
|
760
|
+
let(:israel) { ISO3166::Country.find_country_by_unofficial_names('Israel') }
|
507
761
|
|
508
762
|
it 'should be a country instance' do
|
509
763
|
expect(israel.alpha2).to eq('IL')
|
@@ -512,7 +766,7 @@ describe ISO3166::Country do
|
|
512
766
|
|
513
767
|
# Spot checks #241
|
514
768
|
context 'when search name not found' do
|
515
|
-
let(:israel) { ISO3166::Country.
|
769
|
+
let(:israel) { ISO3166::Country.find_by_iso_short_name('Israel') }
|
516
770
|
|
517
771
|
it 'should be a country instance' do
|
518
772
|
expect(israel[0]).to eq('IL')
|
@@ -521,7 +775,7 @@ describe ISO3166::Country do
|
|
521
775
|
|
522
776
|
# Spot checks #241
|
523
777
|
context 'when search name not found' do
|
524
|
-
let(:israel) { ISO3166::Country.find_all_by(:
|
778
|
+
let(:israel) { ISO3166::Country.find_all_by(:iso_short_name, 'Israel') }
|
525
779
|
|
526
780
|
it 'should be a country instance' do
|
527
781
|
expect(israel.size).to eq(1)
|
@@ -554,10 +808,49 @@ describe ISO3166::Country do
|
|
554
808
|
end
|
555
809
|
end
|
556
810
|
|
811
|
+
describe 'finder methods respond_to_missing?' do
|
812
|
+
subject { ISO3166::Country.respond_to?(method_name) }
|
813
|
+
describe 'find_all_by' do
|
814
|
+
context 'find by a valid Country attribute' do
|
815
|
+
let(:method_name) { :find_all_by_currency }
|
816
|
+
it { is_expected.to be true }
|
817
|
+
end
|
818
|
+
|
819
|
+
context 'find by an invalid attribute' do
|
820
|
+
let(:method_name) { :find_all_by_invalid }
|
821
|
+
it { is_expected.to be false }
|
822
|
+
end
|
823
|
+
end
|
824
|
+
|
825
|
+
describe 'hash finder methods' do
|
826
|
+
context 'find by a valid Country attribute' do
|
827
|
+
let(:method_name) { :find_by_iso_short_name }
|
828
|
+
it { is_expected.to be true }
|
829
|
+
end
|
830
|
+
|
831
|
+
context 'find by an invalid attribute' do
|
832
|
+
let(:method_name) { :find_by_invalid }
|
833
|
+
it { is_expected.to be false }
|
834
|
+
end
|
835
|
+
end
|
836
|
+
|
837
|
+
describe 'country finder methods' do
|
838
|
+
context 'find country by a valid Country attribute' do
|
839
|
+
let(:method_name) { :find_country_by_alpha3 }
|
840
|
+
it { is_expected.to be true }
|
841
|
+
end
|
842
|
+
|
843
|
+
context 'find by an invalid attribute' do
|
844
|
+
let(:method_name) { :find_country_by_invalid }
|
845
|
+
it { is_expected.to be false }
|
846
|
+
end
|
847
|
+
end
|
848
|
+
end
|
849
|
+
|
557
850
|
describe 'names in Data' do
|
558
851
|
it 'should be unique (to allow .find_by_name work properly)' do
|
559
|
-
names = ISO3166::
|
560
|
-
[v['
|
852
|
+
names = ISO3166::Data.cache.map do |_k, v|
|
853
|
+
[v['iso_short_name'], v['unofficial_names']].flatten.uniq
|
561
854
|
end.flatten
|
562
855
|
|
563
856
|
expect(names.size).to eq(names.uniq.size)
|
@@ -568,7 +861,7 @@ describe ISO3166::Country do
|
|
568
861
|
let(:norway) { ISO3166::Country.search('NO') }
|
569
862
|
|
570
863
|
it 'should have a currency' do
|
571
|
-
expect(norway.currency).to be_a(
|
864
|
+
expect(norway.currency).to be_a(Money::Currency)
|
572
865
|
end
|
573
866
|
end
|
574
867
|
|
@@ -576,7 +869,7 @@ describe ISO3166::Country do
|
|
576
869
|
let(:guernsey) { ISO3166::Country.search('GG') }
|
577
870
|
|
578
871
|
it 'should have a currency' do
|
579
|
-
expect(guernsey.currency.
|
872
|
+
expect(guernsey.currency.iso_code).to eq('GBP')
|
580
873
|
end
|
581
874
|
end
|
582
875
|
|
@@ -600,19 +893,48 @@ describe ISO3166::Country do
|
|
600
893
|
end
|
601
894
|
end
|
602
895
|
|
896
|
+
describe 'in_eea?' do
|
897
|
+
let(:netherlands) { ISO3166::Country.search('NL') }
|
898
|
+
|
899
|
+
it 'should return false for countries without eea_member flag' do
|
900
|
+
expect(country.in_eea?).to be_falsey
|
901
|
+
end
|
902
|
+
|
903
|
+
it 'should return true for countries with eea_member flag set to true' do
|
904
|
+
expect(netherlands.in_eea?).to be_truthy
|
905
|
+
end
|
906
|
+
end
|
907
|
+
|
908
|
+
describe 'in_esm?' do
|
909
|
+
let(:netherlands) { ISO3166::Country.search('NL') }
|
910
|
+
let(:switzerland) { ISO3166::Country.search('CH') }
|
911
|
+
|
912
|
+
it 'should return false for countries without esm_member or eea_member flag' do
|
913
|
+
expect(country.in_esm?).to be_falsey
|
914
|
+
end
|
915
|
+
|
916
|
+
it 'should return true for countries with eea_member flag set to true' do
|
917
|
+
expect(netherlands.in_esm?).to be_truthy
|
918
|
+
end
|
919
|
+
|
920
|
+
it 'should return true for countries with esm_member flag set to true' do
|
921
|
+
expect(switzerland.in_esm?).to be_truthy
|
922
|
+
end
|
923
|
+
end
|
924
|
+
|
603
925
|
describe 'gec' do
|
604
926
|
it 'should return the country\'s GEC code' do
|
605
927
|
expect(ISO3166::Country.new('NA').gec).to eql 'WA'
|
606
928
|
end
|
607
929
|
|
608
930
|
it 'should return nil if the country does not have a GEC code' do
|
609
|
-
expect(ISO3166::Country.new('
|
931
|
+
expect(ISO3166::Country.new('UM').gec).to eql nil
|
610
932
|
end
|
611
933
|
end
|
612
934
|
|
613
935
|
describe 'to_s' do
|
614
|
-
it 'should return the country
|
615
|
-
expect(ISO3166::Country.new('GB').to_s).to eq('United Kingdom')
|
936
|
+
it 'should return the country iso_short_name' do
|
937
|
+
expect(ISO3166::Country.new('GB').to_s).to eq('United Kingdom of Great Britain and Northern Ireland')
|
616
938
|
end
|
617
939
|
end
|
618
940
|
|
@@ -646,7 +968,71 @@ describe ISO3166::Country do
|
|
646
968
|
it 'should return country if not convertable input given' do
|
647
969
|
expect do
|
648
970
|
ISO3166::Country(42)
|
649
|
-
end.to raise_error(TypeError,
|
971
|
+
end.to raise_error(TypeError, /can't convert ([A-z]+) into ISO3166::Country/)
|
972
|
+
end
|
973
|
+
end
|
974
|
+
|
975
|
+
describe 'Added country names to search by' do
|
976
|
+
it 'should return country code for Democratic Republic of the Congo' do
|
977
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('Democratic Republic of the Congo').alpha2).to eq 'CD'
|
978
|
+
end
|
979
|
+
it 'should return country code for Ivory Coast' do
|
980
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('Ivory Coast').alpha2).to eq 'CI'
|
981
|
+
end
|
982
|
+
it 'should return Pakistan code for Guinea Bissau' do
|
983
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('Guinea Bissau').alpha2).to eq 'GW'
|
984
|
+
end
|
985
|
+
it 'should return Pakistan code for St Kitts and Nevis' do
|
986
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('St Kitts and Nevis').alpha2).to eq 'KN'
|
987
|
+
end
|
988
|
+
it 'should return Pakistan code for St Lucia' do
|
989
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('St Lucia').alpha2).to eq 'LC'
|
990
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('St. Lucia').alpha2).to eq 'LC'
|
991
|
+
end
|
992
|
+
it 'should return Pakistan code for Turks and Caicos' do
|
993
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('Turks and Caicos').alpha2).to eq 'TC'
|
994
|
+
end
|
995
|
+
it 'should return Pakistan code for St Vincent Grenadines' do
|
996
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('St Vincent Grenadines').alpha2).to eq 'VC'
|
997
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('St. Vincent Grenadines').alpha2).to eq 'VC'
|
998
|
+
end
|
999
|
+
it 'should return country code for Palestinian Authority' do
|
1000
|
+
expect(ISO3166::Country.find_country_by_unofficial_names('Palestinian Authority').alpha2).to eq 'PS'
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
describe 'Emoji' do
|
1005
|
+
it 'has an emoji flag' do
|
1006
|
+
expect(country.emoji_flag).to eq 'πΊπΈ'
|
1007
|
+
end
|
1008
|
+
end
|
1009
|
+
|
1010
|
+
describe '#un_locode' do
|
1011
|
+
let(:countries) { ISO3166::Country.all }
|
1012
|
+
|
1013
|
+
it 'should have two letter un_locode for each country' do
|
1014
|
+
expect(countries.all? { |country| !country.un_locode.nil? }).to be
|
1015
|
+
expect(countries.all? { |country| country.un_locode.length == 2 }).to be
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
describe '.pluck' do
|
1020
|
+
let(:args) { [] }
|
1021
|
+
|
1022
|
+
subject { ISO3166::Country.pluck(*args) }
|
1023
|
+
|
1024
|
+
it "returns empty arrays" do
|
1025
|
+
expect(subject.first).to be_empty
|
1026
|
+
expect(subject.last).to be_empty
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
context "when asking for alpha2, alpha3 and iso_short_name" do
|
1030
|
+
let(:args) { [:alpha2, :alpha3, :iso_short_name] }
|
1031
|
+
|
1032
|
+
it "returns the correct values" do
|
1033
|
+
expect(subject.first).to eq(["AD", "AND", "Andorra"])
|
1034
|
+
expect(subject.last).to eq(["ZW", "ZWE", "Zimbabwe"])
|
1035
|
+
end
|
650
1036
|
end
|
651
1037
|
end
|
652
1038
|
end
|