countries 0.10.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -2
- data/README.markdown +35 -11
- data/Rakefile +41 -9
- data/countries.gemspec +12 -11
- data/lib/cache/translations.yaml +38121 -0
- data/lib/countries.rb +2 -2
- data/lib/countries/country.rb +58 -21
- data/lib/countries/mongoid.rb +3 -12
- data/lib/countries/version.rb +1 -1
- data/lib/data/countries.yaml +250 -11206
- data/lib/data/countries/AD.yaml +40 -0
- data/lib/data/countries/AE.yaml +48 -0
- data/lib/data/countries/AF.yaml +40 -0
- data/lib/data/countries/AG.yaml +40 -0
- data/lib/data/countries/AI.yaml +36 -0
- data/lib/data/countries/AL.yaml +41 -0
- data/lib/data/countries/AM.yaml +40 -0
- data/lib/data/countries/AN.yaml +42 -0
- data/lib/data/countries/AO.yaml +36 -0
- data/lib/data/countries/AQ.yaml +36 -0
- data/lib/data/countries/AR.yaml +47 -0
- data/lib/data/countries/AS.yaml +41 -0
- data/lib/data/countries/AT.yaml +59 -0
- data/lib/data/countries/AU.yaml +44 -0
- data/lib/data/countries/AW.yaml +36 -0
- data/lib/data/countries/AX.yaml +36 -0
- data/lib/data/countries/AZ.yaml +42 -0
- data/lib/data/countries/BA.yaml +48 -0
- data/lib/data/countries/BB.yaml +37 -0
- data/lib/data/countries/BD.yaml +37 -0
- data/lib/data/countries/BE.yaml +56 -0
- data/lib/data/countries/BF.yaml +37 -0
- data/lib/data/countries/BG.yaml +53 -0
- data/lib/data/countries/BH.yaml +44 -0
- data/lib/data/countries/BI.yaml +37 -0
- data/lib/data/countries/BJ.yaml +37 -0
- data/lib/data/countries/BL.yaml +35 -0
- data/lib/data/countries/BM.yaml +38 -0
- data/lib/data/countries/BN.yaml +36 -0
- data/lib/data/countries/BO.yaml +40 -0
- data/lib/data/countries/BQ.yaml +37 -0
- data/lib/data/countries/BR.yaml +46 -0
- data/lib/data/countries/BS.yaml +37 -0
- data/lib/data/countries/BT.yaml +39 -0
- data/lib/data/countries/BV.yaml +35 -0
- data/lib/data/countries/BW.yaml +37 -0
- data/lib/data/countries/BY.yaml +42 -0
- data/lib/data/countries/BZ.yaml +38 -0
- data/lib/data/countries/CA.yaml +44 -0
- data/lib/data/countries/CC.yaml +38 -0
- data/lib/data/countries/CD.yaml +44 -0
- data/lib/data/countries/CF.yaml +41 -0
- data/lib/data/countries/CG.yaml +39 -0
- data/lib/data/countries/CH.yaml +48 -0
- data/lib/data/countries/CI.yaml +40 -0
- data/lib/data/countries/CK.yaml +40 -0
- data/lib/data/countries/CL.yaml +38 -0
- data/lib/data/countries/CM.yaml +41 -0
- data/lib/data/countries/CN.yaml +46 -0
- data/lib/data/countries/CO.yaml +39 -0
- data/lib/data/countries/CR.yaml +36 -0
- data/lib/data/countries/CU.yaml +37 -0
- data/lib/data/countries/CV.yaml +40 -0
- data/lib/data/countries/CW.yaml +36 -0
- data/lib/data/countries/CX.yaml +38 -0
- data/lib/data/countries/CY.yaml +49 -0
- data/lib/data/countries/CZ.yaml +53 -0
- data/lib/data/countries/DE.yaml +60 -0
- data/lib/data/countries/DJ.yaml +39 -0
- data/lib/data/countries/DK.yaml +52 -0
- data/lib/data/countries/DM.yaml +36 -0
- data/lib/data/countries/DO.yaml +40 -0
- data/lib/data/countries/DZ.yaml +41 -0
- data/lib/data/countries/EC.yaml +38 -0
- data/lib/data/countries/EE.yaml +47 -0
- data/lib/data/countries/EG.yaml +46 -0
- data/lib/data/countries/EH.yaml +39 -0
- data/lib/data/countries/ER.yaml +40 -0
- data/lib/data/countries/ES.yaml +53 -0
- data/lib/data/countries/ET.yaml +40 -0
- data/lib/data/countries/FI.yaml +53 -0
- data/lib/data/countries/FJ.yaml +41 -0
- data/lib/data/countries/FK.yaml +40 -0
- data/lib/data/countries/FM.yaml +39 -0
- data/lib/data/countries/FO.yaml +40 -0
- data/lib/data/countries/FR.yaml +54 -0
- data/lib/data/countries/GA.yaml +40 -0
- data/lib/data/countries/GB.yaml +56 -0
- data/lib/data/countries/GD.yaml +36 -0
- data/lib/data/countries/GE.yaml +39 -0
- data/lib/data/countries/GF.yaml +38 -0
- data/lib/data/countries/GG.yaml +39 -0
- data/lib/data/countries/GH.yaml +39 -0
- data/lib/data/countries/GI.yaml +36 -0
- data/lib/data/countries/GL.yaml +44 -0
- data/lib/data/countries/GM.yaml +36 -0
- data/lib/data/countries/GN.yaml +39 -0
- data/lib/data/countries/GP.yaml +37 -0
- data/lib/data/countries/GQ.yaml +41 -0
- data/lib/data/countries/GR.yaml +53 -0
- data/lib/data/countries/GS.yaml +36 -0
- data/lib/data/countries/GT.yaml +36 -0
- data/lib/data/countries/GU.yaml +38 -0
- data/lib/data/countries/GW.yaml +38 -0
- data/lib/data/countries/GY.yaml +37 -0
- data/lib/data/countries/HK.yaml +43 -0
- data/lib/data/countries/HM.yaml +37 -0
- data/lib/data/countries/HN.yaml +37 -0
- data/lib/data/countries/HR.yaml +54 -0
- data/lib/data/countries/HT.yaml +38 -0
- data/lib/data/countries/HU.yaml +55 -0
- data/lib/data/countries/ID.yaml +48 -0
- data/lib/data/countries/IE.yaml +54 -0
- data/lib/data/countries/IL.yaml +45 -0
- data/lib/data/countries/IM.yaml +38 -0
- data/lib/data/countries/IN.yaml +45 -0
- data/lib/data/countries/IO.yaml +36 -0
- data/lib/data/countries/IQ.yaml +40 -0
- data/lib/data/countries/IR.yaml +39 -0
- data/lib/data/countries/IS.yaml +47 -0
- data/lib/data/countries/IT.yaml +52 -0
- data/lib/data/countries/JE.yaml +35 -0
- data/lib/data/countries/JM.yaml +38 -0
- data/lib/data/countries/JO.yaml +47 -0
- data/lib/data/countries/JP.yaml +44 -0
- data/lib/data/countries/KE.yaml +38 -0
- data/lib/data/countries/KG.yaml +42 -0
- data/lib/data/countries/KH.yaml +40 -0
- data/lib/data/countries/KI.yaml +36 -0
- data/lib/data/countries/KM.yaml +40 -0
- data/lib/data/countries/KN.yaml +41 -0
- data/lib/data/countries/KP.yaml +43 -0
- data/lib/data/countries/KR.yaml +48 -0
- data/lib/data/countries/KW.yaml +45 -0
- data/lib/data/countries/KY.yaml +40 -0
- data/lib/data/countries/KZ.yaml +40 -0
- data/lib/data/countries/LA.yaml +37 -0
- data/lib/data/countries/LB.yaml +46 -0
- data/lib/data/countries/LC.yaml +38 -0
- data/lib/data/countries/LI.yaml +36 -0
- data/lib/data/countries/LK.yaml +37 -0
- data/lib/data/countries/LR.yaml +38 -0
- data/lib/data/countries/LS.yaml +38 -0
- data/lib/data/countries/LT.yaml +49 -0
- data/lib/data/countries/LU.yaml +53 -0
- data/lib/data/countries/LV.yaml +47 -0
- data/lib/data/countries/LY.yaml +43 -0
- data/lib/data/countries/MA.yaml +40 -0
- data/lib/data/countries/MC.yaml +38 -0
- data/lib/data/countries/MD.yaml +41 -0
- data/lib/data/countries/ME.yaml +40 -0
- data/lib/data/countries/MF.yaml +37 -0
- data/lib/data/countries/MG.yaml +39 -0
- data/lib/data/countries/MH.yaml +41 -0
- data/lib/data/countries/MK.yaml +47 -0
- data/lib/data/countries/ML.yaml +36 -0
- data/lib/data/countries/MM.yaml +37 -0
- data/lib/data/countries/MN.yaml +42 -0
- data/lib/data/countries/MO.yaml +37 -0
- data/lib/data/countries/MP.yaml +41 -0
- data/lib/data/countries/MQ.yaml +37 -0
- data/lib/data/countries/MR.yaml +41 -0
- data/lib/data/countries/MS.yaml +36 -0
- data/lib/data/countries/MT.yaml +46 -0
- data/lib/data/countries/MU.yaml +38 -0
- data/lib/data/countries/MV.yaml +39 -0
- data/lib/data/countries/MW.yaml +37 -0
- data/lib/data/countries/MX.yaml +46 -0
- data/lib/data/countries/MY.yaml +41 -0
- data/lib/data/countries/MZ.yaml +38 -0
- data/lib/data/countries/NA.yaml +41 -0
- data/lib/data/countries/NC.yaml +40 -0
- data/lib/data/countries/NE.yaml +37 -0
- data/lib/data/countries/NF.yaml +40 -0
- data/lib/data/countries/NG.yaml +39 -0
- data/lib/data/countries/NI.yaml +36 -0
- data/lib/data/countries/NL.yaml +52 -0
- data/lib/data/countries/NO.yaml +45 -0
- data/lib/data/countries/NP.yaml +39 -0
- data/lib/data/countries/NR.yaml +37 -0
- data/lib/data/countries/NU.yaml +36 -0
- data/lib/data/countries/NZ.yaml +47 -0
- data/lib/data/countries/OM.yaml +44 -0
- data/lib/data/countries/PA.yaml +38 -0
- data/lib/data/countries/PE.yaml +39 -0
- data/lib/data/countries/PF.yaml +40 -0
- data/lib/data/countries/PG.yaml +40 -0
- data/lib/data/countries/PH.yaml +47 -0
- data/lib/data/countries/PK.yaml +39 -0
- data/lib/data/countries/PL.yaml +53 -0
- data/lib/data/countries/PM.yaml +40 -0
- data/lib/data/countries/PN.yaml +36 -0
- data/lib/data/countries/PR.yaml +37 -0
- data/lib/data/countries/PS.yaml +44 -0
- data/lib/data/countries/PT.yaml +49 -0
- data/lib/data/countries/PW.yaml +36 -0
- data/lib/data/countries/PY.yaml +37 -0
- data/lib/data/countries/QA.yaml +43 -0
- data/lib/data/countries/RE.yaml +38 -0
- data/lib/data/countries/RO.yaml +53 -0
- data/lib/data/countries/RS.yaml +39 -0
- data/lib/data/countries/RU.yaml +47 -0
- data/lib/data/countries/RW.yaml +40 -0
- data/lib/data/countries/SA.yaml +47 -0
- data/lib/data/countries/SB.yaml +40 -0
- data/lib/data/countries/SC.yaml +38 -0
- data/lib/data/countries/SD.yaml +41 -0
- data/lib/data/countries/SE.yaml +53 -0
- data/lib/data/countries/SG.yaml +46 -0
- data/lib/data/countries/SH.yaml +40 -0
- data/lib/data/countries/SI.yaml +52 -0
- data/lib/data/countries/SJ.yaml +40 -0
- data/lib/data/countries/SK.yaml +52 -0
- data/lib/data/countries/SL.yaml +36 -0
- data/lib/data/countries/SM.yaml +40 -0
- data/lib/data/countries/SN.yaml +37 -0
- data/lib/data/countries/SO.yaml +40 -0
- data/lib/data/countries/SR.yaml +37 -0
- data/lib/data/countries/SS.yaml +38 -0
- data/lib/data/countries/ST.yaml +41 -0
- data/lib/data/countries/SV.yaml +37 -0
- data/lib/data/countries/SX.yaml +37 -0
- data/lib/data/countries/SY.yaml +48 -0
- data/lib/data/countries/SZ.yaml +39 -0
- data/lib/data/countries/TC.yaml +40 -0
- data/lib/data/countries/TD.yaml +41 -0
- data/lib/data/countries/TF.yaml +38 -0
- data/lib/data/countries/TG.yaml +36 -0
- data/lib/data/countries/TH.yaml +39 -0
- data/lib/data/countries/TJ.yaml +42 -0
- data/lib/data/countries/TK.yaml +38 -0
- data/lib/data/countries/TL.yaml +40 -0
- data/lib/data/countries/TM.yaml +39 -0
- data/lib/data/countries/TN.yaml +42 -0
- data/lib/data/countries/TO.yaml +39 -0
- data/lib/data/countries/TR.yaml +45 -0
- data/lib/data/countries/TT.yaml +40 -0
- data/lib/data/countries/TV.yaml +36 -0
- data/lib/data/countries/TW.yaml +43 -0
- data/lib/data/countries/TZ.yaml +40 -0
- data/lib/data/countries/UA.yaml +48 -0
- data/lib/data/countries/UG.yaml +38 -0
- data/lib/data/countries/UM.yaml +38 -0
- data/lib/data/countries/US.yaml +45 -0
- data/lib/data/countries/UY.yaml +37 -0
- data/lib/data/countries/UZ.yaml +41 -0
- data/lib/data/countries/VA.yaml +42 -0
- data/lib/data/countries/VC.yaml +40 -0
- data/lib/data/countries/VE.yaml +36 -0
- data/lib/data/countries/VG.yaml +41 -0
- data/lib/data/countries/VI.yaml +41 -0
- data/lib/data/countries/VN.yaml +40 -0
- data/lib/data/countries/VU.yaml +40 -0
- data/lib/data/countries/WF.yaml +40 -0
- data/lib/data/countries/WS.yaml +38 -0
- data/lib/data/countries/YE.yaml +46 -0
- data/lib/data/countries/YT.yaml +36 -0
- data/lib/data/countries/ZA.yaml +56 -0
- data/lib/data/countries/ZM.yaml +38 -0
- data/lib/data/countries/ZW.yaml +43 -0
- data/lib/data/subdivisions/AD.yaml +14 -20
- data/lib/data/subdivisions/AE.yaml +29 -31
- data/lib/data/subdivisions/AF.yaml +100 -100
- data/lib/data/subdivisions/AG.yaml +18 -24
- data/lib/data/subdivisions/AL.yaml +7 -7
- data/lib/data/subdivisions/AM.yaml +8 -8
- data/lib/data/subdivisions/AO.yaml +11 -11
- data/lib/data/subdivisions/AR.yaml +26 -28
- data/lib/data/subdivisions/AT.yaml +17 -26
- data/lib/data/subdivisions/AU.yaml +10 -10
- data/lib/data/subdivisions/AZ.yaml +8 -8
- data/lib/data/subdivisions/BA.yaml +4 -4
- data/lib/data/subdivisions/BB.yaml +31 -40
- data/lib/data/subdivisions/BD.yaml +292 -354
- data/lib/data/subdivisions/BE.yaml +40 -40
- data/lib/data/subdivisions/BF.yaml +4 -4
- data/lib/data/subdivisions/BG.yaml +32 -58
- data/lib/data/subdivisions/BH.yaml +27 -32
- data/lib/data/subdivisions/BI.yaml +4 -4
- data/lib/data/subdivisions/BJ.yaml +2 -2
- data/lib/data/subdivisions/BO.yaml +7 -8
- data/lib/data/subdivisions/BQ.yaml +2 -2
- data/lib/data/subdivisions/BR.yaml +20 -20
- data/lib/data/subdivisions/BS.yaml +33 -33
- data/lib/data/subdivisions/BT.yaml +69 -87
- data/lib/data/subdivisions/BW.yaml +2 -2
- data/lib/data/subdivisions/BY.yaml +59 -59
- data/lib/data/subdivisions/BZ.yaml +4 -4
- data/lib/data/subdivisions/CA.yaml +22 -23
- data/lib/data/subdivisions/CD.yaml +6 -6
- data/lib/data/subdivisions/CF.yaml +10 -10
- data/lib/data/subdivisions/CG.yaml +12 -22
- data/lib/data/subdivisions/CH.yaml +67 -67
- data/lib/data/subdivisions/CI.yaml +55 -72
- data/lib/data/subdivisions/CL.yaml +18 -18
- data/lib/data/subdivisions/CM.yaml +5 -6
- data/lib/data/subdivisions/CN.yaml +52 -86
- data/lib/data/subdivisions/CO.yaml +10 -10
- data/lib/data/subdivisions/CR.yaml +2 -2
- data/lib/data/subdivisions/CU.yaml +33 -48
- data/lib/data/subdivisions/CV.yaml +20 -20
- data/lib/data/subdivisions/CY.yaml +6 -12
- data/lib/data/subdivisions/CZ.yaml +31 -31
- data/lib/data/subdivisions/DE.yaml +20 -20
- data/lib/data/subdivisions/DJ.yaml +11 -11
- data/lib/data/subdivisions/DK.yaml +34 -54
- data/lib/data/subdivisions/DM.yaml +28 -36
- data/lib/data/subdivisions/DO.yaml +67 -96
- data/lib/data/subdivisions/DZ.yaml +162 -208
- data/lib/data/subdivisions/EC.yaml +10 -12
- data/lib/data/subdivisions/EE.yaml +22 -37
- data/lib/data/subdivisions/EG.yaml +116 -116
- data/lib/data/subdivisions/EH.yaml +25 -25
- data/lib/data/subdivisions/ER.yaml +6 -6
- data/lib/data/subdivisions/ES.yaml +33 -29
- data/lib/data/subdivisions/ET.yaml +13 -13
- data/lib/data/subdivisions/FI.yaml +17 -17
- data/lib/data/subdivisions/FJ.yaml +1 -2
- data/lib/data/subdivisions/FM.yaml +6 -6
- data/lib/data/subdivisions/FR.yaml +107 -199
- data/lib/data/subdivisions/GA.yaml +11 -20
- data/lib/data/subdivisions/GB.yaml +155 -155
- data/lib/data/subdivisions/GD.yaml +21 -28
- data/lib/data/subdivisions/GE.yaml +17 -17
- data/lib/data/subdivisions/GH.yaml +7 -7
- data/lib/data/subdivisions/GM.yaml +10 -11
- data/lib/data/subdivisions/GN.yaml +1 -1
- data/lib/data/subdivisions/GQ.yaml +10 -10
- data/lib/data/subdivisions/GR.yaml +123 -174
- data/lib/data/subdivisions/GT.yaml +11 -11
- data/lib/data/subdivisions/GW.yaml +1 -1
- data/lib/data/subdivisions/GY.yaml +8 -8
- data/lib/data/subdivisions/HN.yaml +12 -12
- data/lib/data/subdivisions/HR.yaml +82 -103
- data/lib/data/subdivisions/HT.yaml +3 -4
- data/lib/data/subdivisions/HU.yaml +3 -3
- data/lib/data/subdivisions/ID.yaml +48 -48
- data/lib/data/subdivisions/IE.yaml +35 -35
- data/lib/data/subdivisions/IL.yaml +13 -13
- data/lib/data/subdivisions/IN.yaml +30 -27
- data/lib/data/subdivisions/IQ.yaml +41 -41
- data/lib/data/subdivisions/IR.yaml +63 -92
- data/lib/data/subdivisions/IS.yaml +15 -24
- data/lib/data/subdivisions/IT.yaml +29 -30
- data/lib/data/subdivisions/JM.yaml +26 -38
- data/lib/data/subdivisions/JO.yaml +32 -32
- data/lib/data/subdivisions/JP.yaml +129 -174
- data/lib/data/subdivisions/KE.yaml +12 -20
- data/lib/data/subdivisions/KG.yaml +14 -16
- data/lib/data/subdivisions/KH.yaml +186 -210
- data/lib/data/subdivisions/KI.yaml +18 -18
- data/lib/data/subdivisions/KM.yaml +9 -9
- data/lib/data/subdivisions/KN.yaml +40 -52
- data/lib/data/subdivisions/KP.yaml +21 -21
- data/lib/data/subdivisions/KR.yaml +54 -70
- data/lib/data/subdivisions/KW.yaml +19 -19
- data/lib/data/subdivisions/KZ.yaml +78 -78
- data/lib/data/subdivisions/Ky.yaml +12 -12
- data/lib/data/subdivisions/LA.yaml +45 -45
- data/lib/data/subdivisions/LB.yaml +16 -16
- data/lib/data/subdivisions/LI.yaml +10 -19
- data/lib/data/subdivisions/LK.yaml +53 -78
- data/lib/data/subdivisions/LR.yaml +10 -10
- data/lib/data/subdivisions/LS.yaml +4 -4
- data/lib/data/subdivisions/LT.yaml +19 -19
- data/lib/data/subdivisions/LU.yaml +2 -2
- data/lib/data/subdivisions/LV.yaml +52 -52
- data/lib/data/subdivisions/LY.yaml +39 -39
- data/lib/data/subdivisions/MA.yaml +42 -42
- data/lib/data/subdivisions/MD.yaml +8 -8
- data/lib/data/subdivisions/ME.yaml +25 -44
- data/lib/data/subdivisions/MG.yaml +8 -8
- data/lib/data/subdivisions/MH.yaml +15 -15
- data/lib/data/subdivisions/MK.yaml +42 -42
- data/lib/data/subdivisions/ML.yaml +8 -16
- data/lib/data/subdivisions/MM.yaml +24 -38
- data/lib/data/subdivisions/MN.yaml +45 -63
- data/lib/data/subdivisions/MR.yaml +39 -49
- data/lib/data/subdivisions/MT.yaml +207 -275
- data/lib/data/subdivisions/MU.yaml +22 -22
- data/lib/data/subdivisions/MV.yaml +126 -144
- data/lib/data/subdivisions/MW.yaml +4 -4
- data/lib/data/subdivisions/MX.yaml +12 -12
- data/lib/data/subdivisions/MY.yaml +24 -38
- data/lib/data/subdivisions/MZ.yaml +5 -6
- data/lib/data/subdivisions/NA.yaml +4 -5
- data/lib/data/subdivisions/NE.yaml +9 -17
- data/lib/data/subdivisions/NG.yaml +11 -12
- data/lib/data/subdivisions/NI.yaml +12 -12
- data/lib/data/subdivisions/NL.yaml +3 -3
- data/lib/data/subdivisions/NO.yaml +11 -11
- data/lib/data/subdivisions/NP.yaml +2 -2
- data/lib/data/subdivisions/NR.yaml +13 -25
- data/lib/data/subdivisions/NZ.yaml +9 -9
- data/lib/data/subdivisions/OM.yaml +18 -18
- data/lib/data/subdivisions/PA.yaml +16 -26
- data/lib/data/subdivisions/PE.yaml +16 -16
- data/lib/data/subdivisions/PG.yaml +33 -33
- data/lib/data/subdivisions/PH.yaml +73 -73
- data/lib/data/subdivisions/PK.yaml +12 -12
- data/lib/data/subdivisions/PL.yaml +53 -27
- data/lib/data/subdivisions/PT.yaml +30 -48
- data/lib/data/subdivisions/PW.yaml +18 -34
- data/lib/data/subdivisions/PY.yaml +29 -46
- data/lib/data/subdivisions/QA.yaml +32 -32
- data/lib/data/subdivisions/RO.yaml +36 -36
- data/lib/data/subdivisions/RS.yaml +44 -72
- data/lib/data/subdivisions/RW.yaml +7 -12
- data/lib/data/subdivisions/SA.yaml +40 -51
- data/lib/data/subdivisions/SB.yaml +8 -8
- data/lib/data/subdivisions/SC.yaml +59 -80
- data/lib/data/subdivisions/SD.yaml +112 -136
- data/lib/data/subdivisions/SE.yaml +42 -44
- data/lib/data/subdivisions/SG.yaml +10 -10
- data/lib/data/subdivisions/SH.yaml +4 -4
- data/lib/data/subdivisions/SI.yaml +261 -418
- data/lib/data/subdivisions/SK.yaml +14 -14
- data/lib/data/subdivisions/SL.yaml +3 -4
- data/lib/data/subdivisions/SM.yaml +12 -19
- data/lib/data/subdivisions/SO.yaml +10 -10
- data/lib/data/subdivisions/ST.yaml +2 -2
- data/lib/data/subdivisions/SV.yaml +14 -14
- data/lib/data/subdivisions/SY.yaml +47 -47
- data/lib/data/subdivisions/SZ.yaml +1 -1
- data/lib/data/subdivisions/TD.yaml +4 -4
- data/lib/data/subdivisions/TF.yaml +6 -6
- data/lib/data/subdivisions/TG.yaml +2 -2
- data/lib/data/subdivisions/TH.yaml +161 -237
- data/lib/data/subdivisions/TL.yaml +8 -8
- data/lib/data/subdivisions/TM.yaml +15 -15
- data/lib/data/subdivisions/TN.yaml +84 -108
- data/lib/data/subdivisions/TO.yaml +7 -12
- data/lib/data/subdivisions/TR.yaml +115 -194
- data/lib/data/subdivisions/TT.yaml +20 -20
- data/lib/data/subdivisions/TV.yaml +2 -2
- data/lib/data/subdivisions/TW.yaml +17 -17
- data/lib/data/subdivisions/TZ.yaml +40 -64
- data/lib/data/subdivisions/Tj.yaml +10 -10
- data/lib/data/subdivisions/UA.yaml +162 -188
- data/lib/data/subdivisions/UG.yaml +80 -160
- data/lib/data/subdivisions/UM.yaml +27 -36
- data/lib/data/subdivisions/US.yaml +46 -46
- data/lib/data/subdivisions/UY.yaml +13 -13
- data/lib/data/subdivisions/UZ.yaml +53 -53
- data/lib/data/subdivisions/VC.yaml +14 -20
- data/lib/data/subdivisions/VE.yaml +10 -12
- data/lib/data/subdivisions/VN.yaml +191 -254
- data/lib/data/subdivisions/VU.yaml +16 -16
- data/lib/data/subdivisions/YE.yaml +38 -38
- data/lib/data/subdivisions/ZA.yaml +11 -11
- data/lib/data/subdivisions/ZM.yaml +7 -14
- data/lib/data/subdivisions/ZW.yaml +10 -10
- data/lib/iso3166.rb +2 -1
- data/spec/country_spec.rb +269 -157
- data/spec/mongoid_spec.rb +14 -18
- metadata +271 -6
@@ -3,83 +3,83 @@ AB:
|
|
3
3
|
name: Abyan
|
4
4
|
names: Abyan
|
5
5
|
AD:
|
6
|
-
name: ʿAdan
|
6
|
+
name: "ʿAdan"
|
7
7
|
names:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
- Adan
|
9
|
+
- "ʿAdan"
|
10
|
+
- Aden
|
11
|
+
- Aden
|
12
|
+
- Adén
|
13
13
|
AM:
|
14
14
|
name: "'Amran"
|
15
15
|
names: "'Amran"
|
16
16
|
BA:
|
17
|
-
name:
|
17
|
+
name: Al Bay?a'
|
18
18
|
names:
|
19
|
-
|
19
|
+
- Al Baida
|
20
20
|
DA:
|
21
|
-
name:
|
22
|
-
names:
|
21
|
+
name: Ad¸ D¸ali'
|
22
|
+
names: Ad¸ D¸ali'
|
23
23
|
DH:
|
24
24
|
name: Dhamar
|
25
25
|
names:
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
- Dhamar
|
27
|
+
- Dhomar
|
28
|
+
- "Đomar"
|
29
29
|
HD:
|
30
30
|
name: Hadramawt
|
31
31
|
names:
|
32
|
-
|
32
|
+
- Hadramout
|
33
33
|
HJ:
|
34
34
|
name: Hajjah
|
35
35
|
names: Hajjah
|
36
36
|
HU:
|
37
|
-
name:
|
37
|
+
name: Al ?udaydah
|
38
38
|
names:
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
- Hodeida
|
40
|
+
- Hodeidah
|
41
|
+
- Hodeïah
|
42
|
+
- H̨udaydah
|
43
|
+
- al-Hudaydah
|
44
44
|
IB:
|
45
45
|
name: Ibb
|
46
46
|
names: Ibb
|
47
47
|
JA:
|
48
|
-
name:
|
49
|
-
names:
|
48
|
+
name: Al Jawf
|
49
|
+
names: Al Jawf
|
50
50
|
LA:
|
51
51
|
name: La?ij
|
52
52
|
names:
|
53
|
-
|
54
|
-
|
53
|
+
- Lahej
|
54
|
+
- Lahj
|
55
55
|
MA:
|
56
56
|
name: Ma'rib
|
57
57
|
names:
|
58
|
-
|
59
|
-
|
58
|
+
- Marab
|
59
|
+
- Mareb
|
60
60
|
MR:
|
61
|
-
name:
|
62
|
-
names:
|
61
|
+
name: Al Mahrah
|
62
|
+
names: Al Mahrah
|
63
63
|
MW:
|
64
|
-
name:
|
65
|
-
names:
|
64
|
+
name: Al Mahwit
|
65
|
+
names: Al Mahwit
|
66
66
|
SD:
|
67
67
|
name: Sa`dah
|
68
68
|
names:
|
69
|
-
|
69
|
+
- Saʿadah
|
70
70
|
SH:
|
71
71
|
name: Shabwah
|
72
72
|
names:
|
73
|
-
|
73
|
+
- Shabwah
|
74
74
|
SN:
|
75
75
|
name: Sanʿā
|
76
76
|
names:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
- Sana
|
78
|
+
- Sanaa
|
79
|
+
- Sanaʿa
|
80
|
+
- Sanaʿa City
|
81
|
+
- Sanʿaʿ
|
82
82
|
TA:
|
83
83
|
name: Taʿizz
|
84
84
|
names:
|
85
|
-
|
85
|
+
- Taiz
|
@@ -1,27 +1,27 @@
|
|
1
1
|
---
|
2
2
|
EC:
|
3
|
-
name:
|
3
|
+
name: Eastern Cape
|
4
4
|
names:
|
5
|
-
|
5
|
+
- Oos Kaap
|
6
6
|
FS:
|
7
|
-
name:
|
7
|
+
name: Free State
|
8
8
|
names:
|
9
|
-
|
10
|
-
|
9
|
+
- Foreistata
|
10
|
+
- Vrystaat
|
11
11
|
GT:
|
12
12
|
name: Gauteng
|
13
13
|
names:
|
14
|
-
|
14
|
+
- Pretoria-Witwatersrand-Vereeniging
|
15
15
|
LP:
|
16
16
|
name: Limpopo
|
17
17
|
names: Limpopo
|
18
18
|
MP:
|
19
19
|
name: Mpumalanga
|
20
20
|
names:
|
21
|
-
|
21
|
+
- eMpumalanga
|
22
22
|
NC:
|
23
|
-
name:
|
24
|
-
names:
|
23
|
+
name: Northern Cape
|
24
|
+
names: Northern Cape
|
25
25
|
NL:
|
26
26
|
name: Kwazulu-Natal
|
27
27
|
names: Kwazulu-Natal
|
@@ -29,6 +29,6 @@ NW:
|
|
29
29
|
name: North-West
|
30
30
|
names: North-West
|
31
31
|
WC:
|
32
|
-
name:
|
32
|
+
name: Western Cape
|
33
33
|
names:
|
34
|
-
|
34
|
+
- Wes Kaap
|
@@ -1,30 +1,23 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
:
|
2
|
+
'01':
|
4
3
|
name: Western
|
5
4
|
names: Western
|
6
|
-
|
7
|
-
:
|
5
|
+
'02':
|
8
6
|
name: Central
|
9
7
|
names: Central
|
10
|
-
|
11
|
-
:
|
8
|
+
'03':
|
12
9
|
name: Eastern
|
13
10
|
names: Eastern
|
14
|
-
|
15
|
-
:
|
11
|
+
'04':
|
16
12
|
name: Luapula
|
17
13
|
names: Luapula
|
18
|
-
|
19
|
-
:
|
14
|
+
'05':
|
20
15
|
name: Northern
|
21
16
|
names: Northern
|
22
|
-
|
23
|
-
:
|
17
|
+
'06':
|
24
18
|
name: North-Western
|
25
19
|
names: North-Western
|
26
|
-
|
27
|
-
:
|
20
|
+
'07':
|
28
21
|
name: Southern
|
29
22
|
names: Southern
|
30
23
|
08:
|
@@ -9,23 +9,23 @@ MA:
|
|
9
9
|
name: Manicaland
|
10
10
|
names: Manicaland
|
11
11
|
MC:
|
12
|
-
name:
|
13
|
-
names:
|
12
|
+
name: Mashonaland Central
|
13
|
+
names: Mashonaland Central
|
14
14
|
ME:
|
15
|
-
name:
|
16
|
-
names:
|
15
|
+
name: Mashonaland East
|
16
|
+
names: Mashonaland East
|
17
17
|
MI:
|
18
18
|
name: Midlands
|
19
19
|
names: Midlands
|
20
20
|
MN:
|
21
|
-
name:
|
22
|
-
names:
|
21
|
+
name: Matabeleland North
|
22
|
+
names: Matabeleland North
|
23
23
|
MS:
|
24
|
-
name:
|
25
|
-
names:
|
24
|
+
name: Matabeleland South
|
25
|
+
names: Matabeleland South
|
26
26
|
MV:
|
27
27
|
name: Masvingo
|
28
28
|
names: Masvingo
|
29
29
|
MW:
|
30
|
-
name:
|
31
|
-
names:
|
30
|
+
name: Mashonaland West
|
31
|
+
names: Mashonaland West
|
data/lib/iso3166.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'iso4217'
|
3
|
+
require 'i18n_data'
|
3
4
|
|
4
5
|
require 'countries/country'
|
5
6
|
|
6
7
|
if defined?(ActionView::Helpers::FormOptionsHelper)
|
7
|
-
ActionView::Helpers::FormOptionsHelper::COUNTRIES = ISO3166::Country::Names.map{ |(name,alpha2)| [name.html_safe,alpha2] }
|
8
|
+
ActionView::Helpers::FormOptionsHelper::COUNTRIES = ISO3166::Country::Names.map { |(name, alpha2)| [name.html_safe, alpha2] }
|
8
9
|
end
|
data/spec/country_spec.rb
CHANGED
@@ -8,77 +8,85 @@ describe ISO3166::Country do
|
|
8
8
|
|
9
9
|
it 'allows to create a country object from a symbol representation of the alpha2 code' do
|
10
10
|
country = described_class.new(:us)
|
11
|
-
country.data.
|
11
|
+
expect(country.data).not_to be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'allows to create a country object from a lowercase alpha2 code' do
|
15
|
-
country = described_class.new(
|
16
|
-
country.data.
|
15
|
+
country = described_class.new('us')
|
16
|
+
expect(country.data).not_to be_nil
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should return 3166 number' do
|
20
|
-
country.number.
|
20
|
+
expect(country.number).to eq('840')
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should return 3166 alpha2 code' do
|
24
|
-
country.alpha2.
|
24
|
+
expect(country.alpha2).to eq('US')
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should return 3166 alpha3 code' do
|
28
|
-
country.alpha3.
|
28
|
+
expect(country.alpha3).to eq('USA')
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should return 3166 name' do
|
32
|
-
country.name.
|
32
|
+
expect(country.name).to eq('United States')
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should return alternate names' do
|
36
|
-
country.names.
|
36
|
+
expect(country.names).to eq(['United States of America', 'Vereinigte Staaten von Amerika', 'États-Unis', 'Estados Unidos', 'アメリカ合衆国', 'Verenigde Staten'])
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'should return translations' do
|
40
|
-
country.translations.
|
41
|
-
country.translations[
|
40
|
+
expect(country.translations).to be
|
41
|
+
expect(country.translations['en']).to eq('United States')
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should return latitude' do
|
45
|
-
country.latitude.
|
45
|
+
expect(country.latitude).to eq('38 00 N')
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should return longitude' do
|
49
|
-
country.longitude.
|
49
|
+
expect(country.longitude).to eq('97 00 W')
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
53
|
-
country.
|
52
|
+
it 'should return the decimal Latitude' do
|
53
|
+
expect(country.latitude_dec).to eq('39.44325637817383')
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should return the decimal Longitude' do
|
57
|
+
expect(country.longitude_dec).to eq('-98.95733642578125')
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should return continent' do
|
61
|
+
expect(country.continent).to eq('North America')
|
54
62
|
end
|
55
63
|
|
56
64
|
it 'knows about whether or not the country uses postal codes' do
|
57
|
-
country.zip.
|
65
|
+
expect(country.zip).to be_truthy
|
58
66
|
end
|
59
67
|
|
60
68
|
it 'knows when a country does not require postal codes' do
|
61
69
|
ireland = ISO3166::Country.search('IE')
|
62
|
-
ireland.postal_code.
|
70
|
+
expect(ireland.postal_code).to eq(false)
|
63
71
|
end
|
64
72
|
|
65
73
|
it 'should return region' do
|
66
|
-
country.region.
|
74
|
+
expect(country.region).to eq('Americas')
|
67
75
|
end
|
68
76
|
|
69
77
|
it 'should return subregion' do
|
70
|
-
country.subregion.
|
78
|
+
expect(country.subregion).to eq('Northern America')
|
71
79
|
end
|
72
80
|
|
73
81
|
it 'should return world region' do
|
74
|
-
country.world_region.
|
82
|
+
expect(country.world_region).to eq('AMER')
|
75
83
|
end
|
76
84
|
|
77
85
|
context 'with Turkey' do
|
78
86
|
let(:country) { ISO3166::Country.search('TR') }
|
79
87
|
|
80
88
|
it 'should indicate EMEA as the world region' do
|
81
|
-
country.world_region.
|
89
|
+
expect(country.world_region).to eq('EMEA')
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
@@ -86,336 +94,415 @@ describe ISO3166::Country do
|
|
86
94
|
let(:country) { ISO3166::Country.search('JP') }
|
87
95
|
|
88
96
|
it 'should indicate APAC as the world region' do
|
89
|
-
country.world_region.
|
97
|
+
expect(country.world_region).to eq('APAC')
|
90
98
|
end
|
91
99
|
end
|
92
100
|
|
93
101
|
it 'should return ioc code' do
|
94
|
-
country.ioc.
|
102
|
+
expect(country.ioc).to eq('USA')
|
95
103
|
end
|
96
104
|
|
97
105
|
it 'should return UN/LOCODE' do
|
98
|
-
country.un_locode.
|
106
|
+
expect(country.un_locode).to eq('US')
|
99
107
|
end
|
100
108
|
|
101
109
|
it 'should be identical to itself' do
|
102
|
-
country.
|
110
|
+
expect(country).to eq(ISO3166::Country.search('US'))
|
103
111
|
end
|
104
112
|
|
105
113
|
it 'should return language' do
|
106
|
-
country.languages[0].
|
114
|
+
expect(country.languages[0]).to eq('en')
|
107
115
|
end
|
108
116
|
|
109
117
|
describe 'e164' do
|
110
118
|
it 'should return country_code' do
|
111
|
-
country.country_code.
|
119
|
+
expect(country.country_code).to eq('1')
|
112
120
|
end
|
113
121
|
|
114
122
|
it 'should return national_destination_code_lengths' do
|
115
|
-
country.national_destination_code_lengths.
|
123
|
+
expect(country.national_destination_code_lengths).to eq([3])
|
116
124
|
end
|
117
125
|
|
118
126
|
it 'should return national_number_lengths' do
|
119
|
-
country.national_number_lengths.
|
127
|
+
expect(country.national_number_lengths).to eq([10])
|
120
128
|
end
|
121
129
|
|
122
130
|
it 'should return international_prefix' do
|
123
|
-
country.international_prefix.
|
131
|
+
expect(country.international_prefix).to eq('011')
|
124
132
|
end
|
125
133
|
|
126
134
|
it 'should return national_prefix' do
|
127
|
-
country.national_prefix.
|
135
|
+
expect(country.national_prefix).to eq('1')
|
128
136
|
end
|
129
137
|
end
|
130
138
|
|
131
139
|
describe 'subdivisions' do
|
132
140
|
it 'should return an empty hash for a country with no ISO3166-2' do
|
133
|
-
ISO3166::Country.search('VA').subdivisions.
|
141
|
+
expect(ISO3166::Country.search('VA').subdivisions.size).to eq(0)
|
134
142
|
end
|
135
143
|
|
136
144
|
it 'should return a hash with all sub divisions' do
|
137
|
-
country.subdivisions.
|
145
|
+
expect(country.subdivisions.size).to eq(60)
|
138
146
|
end
|
139
147
|
|
140
148
|
it 'should be available through states' do
|
141
|
-
country.states.
|
149
|
+
expect(country.states.size).to eq(60)
|
142
150
|
end
|
143
151
|
end
|
144
152
|
|
145
153
|
describe 'valid?' do
|
146
154
|
it 'should return true if country is valid' do
|
147
|
-
ISO3166::Country.new('US').
|
155
|
+
expect(ISO3166::Country.new('US')).to be_valid
|
148
156
|
end
|
149
157
|
|
150
158
|
it 'should return false if country is invalid' do
|
151
|
-
ISO3166::Country.new({}).
|
159
|
+
expect(ISO3166::Country.new({})).not_to be_valid
|
152
160
|
end
|
153
161
|
end
|
154
162
|
|
155
163
|
describe 'new' do
|
156
164
|
it 'should return new country object when a valid alpha2 string is passed' do
|
157
|
-
ISO3166::Country.new('US').
|
165
|
+
expect(ISO3166::Country.new('US')).to be_a(ISO3166::Country)
|
158
166
|
end
|
159
167
|
|
160
168
|
it 'should return nil when an invalid alpha2 string is passed' do
|
161
|
-
ISO3166::Country.new('fubar').
|
169
|
+
expect(ISO3166::Country.new('fubar')).to be_nil
|
162
170
|
end
|
163
171
|
|
164
172
|
it 'should return new country object when a valid alpha2 symbol is passed' do
|
165
|
-
ISO3166::Country.new(:us).
|
173
|
+
expect(ISO3166::Country.new(:us)).to be_a(ISO3166::Country)
|
166
174
|
end
|
167
175
|
|
168
176
|
it 'should return nil when an invalid alpha2 symbol is passed' do
|
169
|
-
ISO3166::Country.new(:fubar).
|
177
|
+
expect(ISO3166::Country.new(:fubar)).to be_nil
|
170
178
|
end
|
171
179
|
end
|
172
180
|
|
173
181
|
describe 'all' do
|
174
182
|
it 'should return an arry list of all countries' do
|
175
183
|
countries = ISO3166::Country.all
|
176
|
-
countries.
|
177
|
-
countries.first.
|
178
|
-
countries.
|
184
|
+
expect(countries).to be_an(Array)
|
185
|
+
expect(countries.first).to be_an(Array)
|
186
|
+
expect(countries.size).to eq(250)
|
179
187
|
end
|
180
188
|
|
181
|
-
it
|
182
|
-
countries = ISO3166::Country.all { |country, data| [data['name'], country, data['country_code']
|
183
|
-
countries.
|
184
|
-
countries.first.
|
185
|
-
countries.first.
|
186
|
-
countries.
|
189
|
+
it 'should allow to customize each country representation passing a block to the method' do
|
190
|
+
countries = ISO3166::Country.all { |country, data| [data['name'], country, data['country_code']] }
|
191
|
+
expect(countries).to be_an(Array)
|
192
|
+
expect(countries.first).to be_an(Array)
|
193
|
+
expect(countries.first.size).to eq(3)
|
194
|
+
expect(countries.size).to eq(250)
|
187
195
|
end
|
188
196
|
end
|
189
197
|
|
190
198
|
describe 'all_translated' do
|
191
199
|
it 'should return an alphabetized list of all country names translated to the selected locale' do
|
192
200
|
countries = ISO3166::Country.all_translated('fr')
|
193
|
-
countries.
|
194
|
-
countries.first.
|
195
|
-
countries.first.
|
201
|
+
expect(countries).to be_an(Array)
|
202
|
+
expect(countries.first).to be_a(String)
|
203
|
+
expect(countries.first).to eq('Afghanistan')
|
196
204
|
# countries missing the desired locale will not be added to the list
|
197
205
|
# so all 250 countries may not be returned, 'fr' returns 249, for example
|
198
|
-
countries.
|
206
|
+
expect(countries.size).to eq(249)
|
199
207
|
end
|
200
208
|
|
201
209
|
it 'should return an alphabetized list of all country names in English if no locale is passed' do
|
202
210
|
countries = ISO3166::Country.all_translated
|
203
|
-
countries.
|
204
|
-
countries.first.
|
205
|
-
countries.first.
|
206
|
-
countries.
|
211
|
+
expect(countries).to be_an(Array)
|
212
|
+
expect(countries.first).to be_a(String)
|
213
|
+
expect(countries.first).to eq('Afghanistan')
|
214
|
+
expect(countries.size).to eq(249)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe 'translation' do
|
219
|
+
it 'should return the localized name for a country to the selected locale' do
|
220
|
+
countries = ISO3166::Country.new(:de).translation('de')
|
221
|
+
expect(countries).to be_an(String)
|
222
|
+
expect(countries).to eq('Deutschland')
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should return the localized name for a country in English' do
|
226
|
+
countries = ISO3166::Country.new(:de).translation
|
227
|
+
expect(countries).to be_an(String)
|
228
|
+
expect(countries).to eq('Germany')
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should return nil when a translation is not found' do
|
232
|
+
countries = ISO3166::Country.new(:de).translation('xxx')
|
233
|
+
expect(countries).to be_nil
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe 'translations' do
|
238
|
+
it 'should return an hash of all country names translated to the selected locale' do
|
239
|
+
countries = ISO3166::Country.translations('fr')
|
240
|
+
expect(countries).to be_an(Hash)
|
241
|
+
expect(countries.first[0]).to eq('AF')
|
242
|
+
expect(countries.first).to eq(%w(AF Afghanistan))
|
243
|
+
# countries missing the desired locale will not be added to the list
|
244
|
+
# so all 250 countries may not be returned, 'fr' returns 249, for example
|
245
|
+
expect(countries.size).to eq(249)
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'should return an hash of all country names in English if no locale is passed' do
|
249
|
+
countries = ISO3166::Country.translations
|
250
|
+
expect(countries).to be_an(Hash)
|
251
|
+
expect(countries.first[0]).to eq('AF')
|
252
|
+
expect(countries.first).to eq(%w(AF Afghanistan))
|
253
|
+
expect(countries.size).to eq(249)
|
207
254
|
end
|
208
255
|
end
|
209
256
|
|
210
257
|
describe 'countries' do
|
211
258
|
it 'should be the same as all' do
|
212
|
-
ISO3166::Country.countries.
|
259
|
+
expect(ISO3166::Country.countries).to eq(ISO3166::Country.all)
|
213
260
|
end
|
214
261
|
end
|
215
262
|
|
216
263
|
describe 'search' do
|
217
264
|
it 'should return new country object when a valid alpha2 string is passed' do
|
218
|
-
ISO3166::Country.search('US').
|
265
|
+
expect(ISO3166::Country.search('US')).to be_a(ISO3166::Country)
|
219
266
|
end
|
220
267
|
|
221
268
|
it 'should return nil when an invalid alpha2 string is passed' do
|
222
|
-
ISO3166::Country.search('fubar').
|
269
|
+
expect(ISO3166::Country.search('fubar')).to be_nil
|
223
270
|
end
|
224
271
|
|
225
272
|
it 'should return new country object when a valid alpha2 symbol is passed' do
|
226
|
-
ISO3166::Country.search(:us).
|
273
|
+
expect(ISO3166::Country.search(:us)).to be_a(ISO3166::Country)
|
227
274
|
end
|
228
275
|
|
229
276
|
it 'should return nil when an invalid alpha2 symbol is passed' do
|
230
|
-
ISO3166::Country.search(:fubar).
|
277
|
+
expect(ISO3166::Country.search(:fubar)).to be_nil
|
231
278
|
end
|
232
279
|
end
|
233
280
|
|
234
281
|
describe 'currency' do
|
235
282
|
it 'should return an instance of Currency' do
|
236
|
-
country.currency.
|
283
|
+
expect(country.currency).to be_a(ISO4217::Currency)
|
237
284
|
end
|
238
285
|
|
239
286
|
it 'should allow access to symbol' do
|
240
|
-
country.currency[:symbol].
|
287
|
+
expect(country.currency[:symbol]).to eq('$')
|
241
288
|
end
|
242
289
|
end
|
243
290
|
|
244
|
-
describe
|
291
|
+
describe 'Country class' do
|
245
292
|
context "when loaded via 'iso3166' existance" do
|
246
293
|
subject { defined?(Country) }
|
247
294
|
|
248
|
-
it {
|
295
|
+
it { is_expected.to be_falsey }
|
249
296
|
end
|
250
297
|
|
251
298
|
context "when loaded via 'countries'" do
|
252
299
|
before { require 'countries' }
|
253
300
|
|
254
|
-
describe
|
301
|
+
describe 'existance' do
|
255
302
|
subject { defined?(Country) }
|
256
303
|
|
257
|
-
it {
|
304
|
+
it { is_expected.to be_truthy }
|
258
305
|
end
|
259
306
|
|
260
|
-
describe
|
307
|
+
describe 'superclass' do
|
261
308
|
subject { Country.superclass }
|
262
309
|
|
263
|
-
it {
|
310
|
+
it { is_expected.to eq(ISO3166::Country) }
|
264
311
|
end
|
265
312
|
|
266
313
|
describe 'to_s' do
|
267
314
|
it 'should return the country name' do
|
268
|
-
Country.new('GB').to_s.
|
315
|
+
expect(Country.new('GB').to_s).to eq('United Kingdom')
|
269
316
|
end
|
270
317
|
end
|
271
318
|
end
|
272
319
|
end
|
273
320
|
|
274
321
|
describe 'find_all_by' do
|
275
|
-
context
|
276
|
-
let(:spain_data) { ISO3166::Country.find_all_by('alpha2',
|
322
|
+
context 'when searchead attribute equals the given value' do
|
323
|
+
let(:spain_data) { ISO3166::Country.find_all_by('alpha2', 'ES') }
|
277
324
|
|
278
|
-
it
|
279
|
-
spain_data.
|
280
|
-
spain_data.
|
325
|
+
it 'returns a hash with the data of the country' do
|
326
|
+
expect(spain_data).to be_a Hash
|
327
|
+
expect(spain_data.keys.size).to eq(1)
|
281
328
|
end
|
282
329
|
end
|
283
330
|
|
284
|
-
context
|
285
|
-
let(:spain_data) { ISO3166::Country.find_all_by('languages',
|
331
|
+
context 'when searchead attribute is list and one of its elements equals the given value' do
|
332
|
+
let(:spain_data) { ISO3166::Country.find_all_by('languages', 'en') }
|
286
333
|
|
287
|
-
it
|
288
|
-
spain_data.
|
289
|
-
spain_data.size.
|
334
|
+
it 'returns a hash with the data of the country' do
|
335
|
+
expect(spain_data).to be_a Hash
|
336
|
+
expect(spain_data.size).to be > 1
|
290
337
|
end
|
291
338
|
end
|
292
339
|
|
293
|
-
it
|
294
|
-
spain_data = ISO3166::Country.find_all_by('alpha2',
|
295
|
-
spain_data.
|
296
|
-
spain_data.
|
340
|
+
it 'also finds results if the given values is not upcased/downcased properly' do
|
341
|
+
spain_data = ISO3166::Country.find_all_by('alpha2', 'es')
|
342
|
+
expect(spain_data).to be_a Hash
|
343
|
+
expect(spain_data.keys.size).to eq(1)
|
297
344
|
end
|
298
345
|
|
299
|
-
it
|
300
|
-
spain_data = ISO3166::Country.find_all_by(:alpha2,
|
301
|
-
spain_data.
|
302
|
-
spain_data.
|
346
|
+
it 'also finds results if the attribute is given as a symbol' do
|
347
|
+
spain_data = ISO3166::Country.find_all_by(:alpha2, 'ES')
|
348
|
+
expect(spain_data).to be_a Hash
|
349
|
+
expect(spain_data.keys.size).to eq(1)
|
303
350
|
end
|
304
351
|
|
305
|
-
it
|
352
|
+
it 'casts the given value to a string to perform the search' do
|
306
353
|
spain_data = ISO3166::Country.find_all_by(:country_code, 34)
|
307
|
-
spain_data.
|
308
|
-
spain_data.keys.
|
354
|
+
expect(spain_data).to be_a Hash
|
355
|
+
expect(spain_data.keys).to eq(['ES'])
|
309
356
|
end
|
310
357
|
|
311
|
-
it
|
358
|
+
it 'also performs searches with regexps and forces it to ignore case' do
|
312
359
|
spain_data = ISO3166::Country.find_all_by(:names, /Españ/)
|
313
|
-
spain_data.
|
314
|
-
spain_data.keys.
|
360
|
+
expect(spain_data).to be_a Hash
|
361
|
+
expect(spain_data.keys).to eq(['ES'])
|
315
362
|
end
|
316
363
|
end
|
317
364
|
|
318
|
-
describe
|
365
|
+
describe 'hash finder methods' do
|
319
366
|
context "when search name in 'name'" do
|
320
|
-
subject { ISO3166::Country.find_by_name(
|
321
|
-
|
322
|
-
|
367
|
+
subject { ISO3166::Country.find_by_name('Poland') }
|
368
|
+
it 'should return' do
|
369
|
+
expect(subject.first).to eq('PL')
|
370
|
+
end
|
323
371
|
end
|
324
372
|
|
325
373
|
context "when search lowercase name in 'name'" do
|
326
|
-
subject { ISO3166::Country.find_by_name(
|
327
|
-
|
328
|
-
|
374
|
+
subject { ISO3166::Country.find_by_name('poland') }
|
375
|
+
it 'should return' do
|
376
|
+
expect(subject.first).to eq('PL')
|
377
|
+
end
|
329
378
|
end
|
330
379
|
|
331
380
|
context "when search name in 'names'" do
|
332
|
-
subject { ISO3166::Country.find_by_name(
|
333
|
-
|
334
|
-
|
381
|
+
subject { ISO3166::Country.find_by_name('Polonia') }
|
382
|
+
it 'should return' do
|
383
|
+
expect(subject.first).to eq('PL')
|
384
|
+
end
|
335
385
|
end
|
336
386
|
|
337
|
-
context
|
338
|
-
it
|
339
|
-
|
387
|
+
context 'when finding by invalid attribute' do
|
388
|
+
it 'should raise an error' do
|
389
|
+
expect { ISO3166::Country.find_by_invalid('invalid') }.to raise_error
|
340
390
|
end
|
341
391
|
end
|
342
392
|
|
343
|
-
context
|
393
|
+
context 'when using find_all method' do
|
344
394
|
let(:list) { ISO3166::Country.find_all_by_currency('USD') }
|
345
395
|
|
346
|
-
it
|
347
|
-
list.
|
348
|
-
list.first.
|
396
|
+
it 'should be an Array of Arrays' do
|
397
|
+
expect(list).to be_a(Array)
|
398
|
+
expect(list.first).to be_a(Array)
|
349
399
|
end
|
350
400
|
end
|
351
401
|
|
352
|
-
context
|
402
|
+
context 'when using find_by method' do
|
353
403
|
subject { ISO3166::Country.find_by_alpha3('CAN') }
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
404
|
+
it 'should return' do
|
405
|
+
expect(subject.length).to eq 2
|
406
|
+
expect(subject.first).to be_a(String)
|
407
|
+
expect(subject.last).to be_a(Hash)
|
408
|
+
end
|
358
409
|
end
|
359
410
|
end
|
360
411
|
|
361
|
-
describe
|
362
|
-
context
|
363
|
-
let(:uk) { ISO3166::Country.find_country_by_name(
|
412
|
+
describe 'country finder methods' do
|
413
|
+
context 'when search name found' do
|
414
|
+
let(:uk) { ISO3166::Country.find_country_by_name('United Kingdom') }
|
364
415
|
|
365
|
-
it
|
366
|
-
uk.
|
367
|
-
uk.alpha2.
|
416
|
+
it 'should be a country instance' do
|
417
|
+
expect(uk).to be_a(ISO3166::Country)
|
418
|
+
expect(uk.alpha2).to eq('GB')
|
368
419
|
end
|
369
420
|
end
|
370
421
|
|
371
|
-
context
|
372
|
-
let(:uk) { ISO3166::Country.find_country_by_name(
|
422
|
+
context 'when search lowercase name found' do
|
423
|
+
let(:uk) { ISO3166::Country.find_country_by_name('united kingdom') }
|
373
424
|
|
374
|
-
it
|
375
|
-
uk.
|
376
|
-
uk.alpha2.
|
425
|
+
it 'should be a country instance' do
|
426
|
+
expect(uk).to be_a(ISO3166::Country)
|
427
|
+
expect(uk.alpha2).to eq('GB')
|
377
428
|
end
|
378
429
|
end
|
379
430
|
|
380
|
-
context
|
381
|
-
let(:
|
431
|
+
context 'when search translation found' do
|
432
|
+
let(:uk) { ISO3166::Country.find_country_by_name('Velika Britanija') }
|
382
433
|
|
383
|
-
it
|
384
|
-
|
434
|
+
it 'should be a country instance' do
|
435
|
+
expect(uk).to be_a(ISO3166::Country)
|
436
|
+
expect(uk.alpha2).to eq('GB')
|
385
437
|
end
|
386
438
|
end
|
387
439
|
|
388
|
-
context
|
389
|
-
|
390
|
-
|
440
|
+
context 'when search name not found' do
|
441
|
+
let(:bogus) { ISO3166::Country.find_country_by_name('Does not exist') }
|
442
|
+
|
443
|
+
it 'should be a country instance' do
|
444
|
+
expect(bogus).to eq(nil)
|
391
445
|
end
|
392
446
|
end
|
393
447
|
|
394
|
-
|
448
|
+
# Spot checks #243
|
449
|
+
context 'when search name not found' do
|
450
|
+
let(:belgium) { ISO3166::Country.find_country_by_name('Belgium') }
|
451
|
+
|
452
|
+
it 'should be a country instance' do
|
453
|
+
expect(belgium.alpha2).to eq('BE')
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
# Spot checks #240
|
458
|
+
context 'when search name not found' do
|
459
|
+
let(:canada) { ISO3166::Country.find_country_by_name('Canada') }
|
460
|
+
|
461
|
+
it 'should be a country instance' do
|
462
|
+
expect(canada.alpha2).to eq('CA')
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
# Spot checks #241
|
467
|
+
context 'when search name not found' do
|
468
|
+
let(:iraq) { ISO3166::Country.find_country_by_name('Israel') }
|
469
|
+
|
470
|
+
it 'should be a country instance' do
|
471
|
+
expect(iraq.alpha2).to eq('IL')
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
context 'when finding by invalid attribute' do
|
476
|
+
it 'should raise an error' do
|
477
|
+
expect { ISO3166::Country.find_country_by_invalid('invalid') }.to raise_error
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
context 'when using find_all method' do
|
395
482
|
let(:list) { ISO3166::Country.find_all_countries_by_currency('USD') }
|
396
483
|
|
397
|
-
it
|
398
|
-
list.
|
399
|
-
list.first.
|
484
|
+
it 'should be an Array of Country objects' do
|
485
|
+
expect(list).to be_a(Array)
|
486
|
+
expect(list.first).to be_a(ISO3166::Country)
|
400
487
|
end
|
401
488
|
end
|
402
489
|
|
403
|
-
context
|
490
|
+
context 'when using find_by method' do
|
404
491
|
let(:country) { ISO3166::Country.find_country_by_alpha3('CAN') }
|
405
492
|
|
406
493
|
it 'should be a single country object' do
|
407
|
-
country.
|
494
|
+
expect(country).to be_a(ISO3166::Country)
|
408
495
|
end
|
409
496
|
end
|
410
497
|
end
|
411
498
|
|
412
|
-
describe
|
413
|
-
it
|
414
|
-
names = ISO3166::Country::Data.
|
415
|
-
[v[
|
499
|
+
describe 'names in Data' do
|
500
|
+
it 'should be unique (to allow .find_by_name work properly)' do
|
501
|
+
names = ISO3166::Country::Data.map do |_k, v|
|
502
|
+
[v['name'], v['names']].flatten.uniq
|
416
503
|
end.flatten
|
417
504
|
|
418
|
-
names.size.
|
505
|
+
expect(names.size).to eq(names.uniq.size)
|
419
506
|
end
|
420
507
|
end
|
421
508
|
|
@@ -423,7 +510,7 @@ describe ISO3166::Country do
|
|
423
510
|
let(:norway) { ISO3166::Country.search('NO') }
|
424
511
|
|
425
512
|
it 'should have a currency' do
|
426
|
-
norway.currency.
|
513
|
+
expect(norway.currency).to be_a(ISO4217::Currency)
|
427
514
|
end
|
428
515
|
end
|
429
516
|
|
@@ -431,15 +518,15 @@ describe ISO3166::Country do
|
|
431
518
|
let(:guernsey) { ISO3166::Country.search('GG') }
|
432
519
|
|
433
520
|
it 'should have a currency' do
|
434
|
-
guernsey.currency.code.
|
521
|
+
expect(guernsey.currency.code).to eq('GBP')
|
435
522
|
end
|
436
523
|
end
|
437
524
|
|
438
525
|
describe 'Languages' do
|
439
526
|
let(:german_speaking_countries) { ISO3166::Country.find_all_countries_by_languages('de') }
|
440
527
|
|
441
|
-
it
|
442
|
-
german_speaking_countries.size.
|
528
|
+
it 'should find countries by language' do
|
529
|
+
expect(german_speaking_countries.size).to eq(6)
|
443
530
|
end
|
444
531
|
end
|
445
532
|
|
@@ -447,17 +534,27 @@ describe ISO3166::Country do
|
|
447
534
|
let(:netherlands) { ISO3166::Country.search('NL') }
|
448
535
|
|
449
536
|
it 'should return false for countries without eu_member flag' do
|
450
|
-
country.in_eu
|
537
|
+
expect(country.in_eu?).to be_falsey
|
451
538
|
end
|
452
539
|
|
453
540
|
it 'should return true for countries with eu_member flag set to true' do
|
454
|
-
netherlands.in_eu
|
541
|
+
expect(netherlands.in_eu?).to be_truthy
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
describe 'gec' do
|
546
|
+
it 'should return the country\'s GEC code' do
|
547
|
+
expect(ISO3166::Country.new('NA').gec).to eql 'WA'
|
548
|
+
end
|
549
|
+
|
550
|
+
it 'should return nil if the country does not have a GEC code' do
|
551
|
+
expect(ISO3166::Country.new('AN').gec).to eql nil
|
455
552
|
end
|
456
553
|
end
|
457
554
|
|
458
555
|
describe 'to_s' do
|
459
556
|
it 'should return the country name' do
|
460
|
-
ISO3166::Country.new('GB').to_s.
|
557
|
+
expect(ISO3166::Country.new('GB').to_s).to eq('United Kingdom')
|
461
558
|
end
|
462
559
|
end
|
463
560
|
|
@@ -465,18 +562,33 @@ describe ISO3166::Country do
|
|
465
562
|
let(:belgium) { ISO3166::Country.search('BE') }
|
466
563
|
|
467
564
|
it 'should not return a vat_rate for countries without federal VAT' do
|
468
|
-
country.vat_rates.
|
565
|
+
expect(country.vat_rates).to eq(nil)
|
469
566
|
end
|
470
567
|
|
471
568
|
it 'should contain all keys for vat_rates' do
|
472
|
-
belgium.vat_rates.
|
473
|
-
belgium.vat_rates.keys.
|
569
|
+
expect(belgium.vat_rates).to be_a(Hash)
|
570
|
+
expect(belgium.vat_rates.keys).to eq(%w(standard reduced super_reduced parking))
|
474
571
|
end
|
475
572
|
|
476
573
|
it 'should return an array of reduced vat rates' do
|
477
|
-
belgium.vat_rates[
|
478
|
-
belgium.vat_rates[
|
574
|
+
expect(belgium.vat_rates['reduced']).to be_an(Array)
|
575
|
+
expect(belgium.vat_rates['reduced']).to eq([6, 12])
|
479
576
|
end
|
480
577
|
end
|
481
578
|
|
579
|
+
describe 'ISO3166::Country()' do
|
580
|
+
it 'should return same object if instance of ISO3166::Country given' do
|
581
|
+
expect(ISO3166::Country(country)).to eq country
|
582
|
+
end
|
583
|
+
|
584
|
+
it 'should return country if instance of String given' do
|
585
|
+
expect(ISO3166::Country('us')).to eq country
|
586
|
+
end
|
587
|
+
|
588
|
+
it 'should return country if not convertable input given' do
|
589
|
+
expect do
|
590
|
+
ISO3166::Country(42)
|
591
|
+
end.to raise_error(TypeError, "can't convert Fixnum into ISO3166::Country")
|
592
|
+
end
|
593
|
+
end
|
482
594
|
end
|