countries 5.0.1 → 5.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (498) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -3
  3. data/README.markdown +51 -74
  4. data/Rakefile +15 -21
  5. data/UPGRADE.md +39 -0
  6. data/countries.gemspec +0 -1
  7. data/lib/countries/cache/countries.json +1 -1
  8. data/lib/countries/cache/locales/ab.json +1 -1
  9. data/lib/countries/cache/locales/af.json +1 -1
  10. data/lib/countries/cache/locales/ak.json +1 -1
  11. data/lib/countries/cache/locales/am.json +1 -1
  12. data/lib/countries/cache/locales/an.json +1 -1
  13. data/lib/countries/cache/locales/ar.json +1 -1
  14. data/lib/countries/cache/locales/as.json +1 -1
  15. data/lib/countries/cache/locales/ay.json +1 -1
  16. data/lib/countries/cache/locales/az.json +1 -1
  17. data/lib/countries/cache/locales/ba.json +1 -1
  18. data/lib/countries/cache/locales/be.json +1 -1
  19. data/lib/countries/cache/locales/bg.json +1 -1
  20. data/lib/countries/cache/locales/bi.json +1 -1
  21. data/lib/countries/cache/locales/bn-in.json +1 -1
  22. data/lib/countries/cache/locales/bn.json +1 -1
  23. data/lib/countries/cache/locales/br.json +1 -1
  24. data/lib/countries/cache/locales/bs.json +1 -1
  25. data/lib/countries/cache/locales/ca.json +1 -1
  26. data/lib/countries/cache/locales/ce.json +1 -1
  27. data/lib/countries/cache/locales/ch.json +1 -1
  28. data/lib/countries/cache/locales/cs.json +1 -1
  29. data/lib/countries/cache/locales/cv.json +1 -1
  30. data/lib/countries/cache/locales/cy.json +1 -1
  31. data/lib/countries/cache/locales/da.json +1 -1
  32. data/lib/countries/cache/locales/de.json +1 -1
  33. data/lib/countries/cache/locales/dv.json +1 -1
  34. data/lib/countries/cache/locales/dz.json +1 -1
  35. data/lib/countries/cache/locales/ee.json +1 -1
  36. data/lib/countries/cache/locales/el.json +1 -1
  37. data/lib/countries/cache/locales/en.json +1 -1
  38. data/lib/countries/cache/locales/eo.json +1 -1
  39. data/lib/countries/cache/locales/es.json +1 -1
  40. data/lib/countries/cache/locales/et.json +1 -1
  41. data/lib/countries/cache/locales/eu.json +1 -1
  42. data/lib/countries/cache/locales/fa.json +1 -1
  43. data/lib/countries/cache/locales/ff.json +1 -1
  44. data/lib/countries/cache/locales/fi.json +1 -1
  45. data/lib/countries/cache/locales/fo.json +1 -1
  46. data/lib/countries/cache/locales/fr.json +1 -1
  47. data/lib/countries/cache/locales/fy.json +1 -1
  48. data/lib/countries/cache/locales/ga.json +1 -1
  49. data/lib/countries/cache/locales/gl.json +1 -1
  50. data/lib/countries/cache/locales/gn.json +1 -1
  51. data/lib/countries/cache/locales/gu.json +1 -1
  52. data/lib/countries/cache/locales/gv.json +1 -1
  53. data/lib/countries/cache/locales/ha.json +1 -1
  54. data/lib/countries/cache/locales/he.json +1 -1
  55. data/lib/countries/cache/locales/hi.json +1 -1
  56. data/lib/countries/cache/locales/hr.json +1 -1
  57. data/lib/countries/cache/locales/ht.json +1 -1
  58. data/lib/countries/cache/locales/hu.json +1 -1
  59. data/lib/countries/cache/locales/hy.json +1 -1
  60. data/lib/countries/cache/locales/ia.json +1 -1
  61. data/lib/countries/cache/locales/id.json +1 -1
  62. data/lib/countries/cache/locales/io.json +1 -1
  63. data/lib/countries/cache/locales/is.json +1 -1
  64. data/lib/countries/cache/locales/it.json +1 -1
  65. data/lib/countries/cache/locales/iu.json +1 -1
  66. data/lib/countries/cache/locales/ja.json +1 -1
  67. data/lib/countries/cache/locales/ka.json +1 -1
  68. data/lib/countries/cache/locales/ki.json +1 -1
  69. data/lib/countries/cache/locales/kk.json +1 -1
  70. data/lib/countries/cache/locales/kl.json +1 -1
  71. data/lib/countries/cache/locales/km.json +1 -1
  72. data/lib/countries/cache/locales/kn.json +1 -1
  73. data/lib/countries/cache/locales/ko.json +1 -1
  74. data/lib/countries/cache/locales/kv.json +1 -1
  75. data/lib/countries/cache/locales/kw.json +1 -1
  76. data/lib/countries/cache/locales/ky.json +1 -1
  77. data/lib/countries/cache/locales/lo.json +1 -1
  78. data/lib/countries/cache/locales/lt.json +1 -1
  79. data/lib/countries/cache/locales/lv.json +1 -1
  80. data/lib/countries/cache/locales/mi.json +1 -1
  81. data/lib/countries/cache/locales/mk.json +1 -1
  82. data/lib/countries/cache/locales/ml.json +1 -1
  83. data/lib/countries/cache/locales/mn.json +1 -1
  84. data/lib/countries/cache/locales/mr.json +1 -1
  85. data/lib/countries/cache/locales/ms.json +1 -1
  86. data/lib/countries/cache/locales/mt.json +1 -1
  87. data/lib/countries/cache/locales/my.json +1 -1
  88. data/lib/countries/cache/locales/na.json +1 -1
  89. data/lib/countries/cache/locales/nb.json +1 -1
  90. data/lib/countries/cache/locales/ne.json +1 -1
  91. data/lib/countries/cache/locales/nl.json +1 -1
  92. data/lib/countries/cache/locales/nn.json +1 -1
  93. data/lib/countries/cache/locales/nv.json +1 -1
  94. data/lib/countries/cache/locales/oc.json +1 -1
  95. data/lib/countries/cache/locales/or.json +1 -1
  96. data/lib/countries/cache/locales/pa.json +1 -1
  97. data/lib/countries/cache/locales/pi.json +1 -1
  98. data/lib/countries/cache/locales/pl.json +1 -1
  99. data/lib/countries/cache/locales/ps.json +1 -1
  100. data/lib/countries/cache/locales/pt-br.json +1 -1
  101. data/lib/countries/cache/locales/pt.json +1 -1
  102. data/lib/countries/cache/locales/ro.json +1 -1
  103. data/lib/countries/cache/locales/ru.json +1 -1
  104. data/lib/countries/cache/locales/rw.json +1 -1
  105. data/lib/countries/cache/locales/sc.json +1 -1
  106. data/lib/countries/cache/locales/sd.json +1 -1
  107. data/lib/countries/cache/locales/si.json +1 -1
  108. data/lib/countries/cache/locales/sk.json +1 -1
  109. data/lib/countries/cache/locales/sl.json +1 -1
  110. data/lib/countries/cache/locales/so.json +1 -1
  111. data/lib/countries/cache/locales/sq.json +1 -1
  112. data/lib/countries/cache/locales/sr.json +1 -1
  113. data/lib/countries/cache/locales/sv.json +1 -1
  114. data/lib/countries/cache/locales/sw.json +1 -1
  115. data/lib/countries/cache/locales/ta.json +1 -1
  116. data/lib/countries/cache/locales/te.json +1 -1
  117. data/lib/countries/cache/locales/tg.json +1 -1
  118. data/lib/countries/cache/locales/th.json +1 -1
  119. data/lib/countries/cache/locales/ti.json +1 -1
  120. data/lib/countries/cache/locales/tk.json +1 -1
  121. data/lib/countries/cache/locales/tl.json +1 -1
  122. data/lib/countries/cache/locales/tr.json +1 -1
  123. data/lib/countries/cache/locales/tt.json +1 -1
  124. data/lib/countries/cache/locales/ug.json +1 -1
  125. data/lib/countries/cache/locales/uk.json +1 -1
  126. data/lib/countries/cache/locales/ur.json +1 -1
  127. data/lib/countries/cache/locales/uz.json +1 -1
  128. data/lib/countries/cache/locales/ve.json +1 -1
  129. data/lib/countries/cache/locales/vi.json +1 -1
  130. data/lib/countries/cache/locales/wa.json +1 -1
  131. data/lib/countries/cache/locales/wo.json +1 -1
  132. data/lib/countries/cache/locales/xh.json +1 -1
  133. data/lib/countries/cache/locales/yo.json +1 -1
  134. data/lib/countries/cache/locales/zh-cn.json +1 -1
  135. data/lib/countries/cache/locales/zh-hk.json +1 -1
  136. data/lib/countries/cache/locales/zh-tw.json +1 -1
  137. data/lib/countries/cache/locales/zu.json +1 -1
  138. data/lib/countries/country/class_methods.rb +8 -26
  139. data/lib/countries/country.rb +31 -5
  140. data/lib/countries/data/countries/AU.yaml +1 -1
  141. data/lib/countries/data/countries/BS.yaml +1 -2
  142. data/lib/countries/data/countries/CZ.yaml +1 -0
  143. data/lib/countries/data/countries/GB.yaml +3 -0
  144. data/lib/countries/data/countries/GM.yaml +1 -1
  145. data/lib/countries/data/countries/MK.yaml +1 -0
  146. data/lib/countries/data/countries/MM.yaml +1 -1
  147. data/lib/countries/data/countries/NL.yaml +1 -0
  148. data/lib/countries/data/countries/TH.yaml +1 -0
  149. data/lib/countries/data/countries/TW.yaml +1 -1
  150. data/lib/countries/data/countries/US.yaml +1 -1
  151. data/lib/countries/data/countries/VI.yaml +1 -0
  152. data/lib/countries/data/subdivisions/AD.yaml +14 -7
  153. data/lib/countries/data/subdivisions/AE.yaml +14 -7
  154. data/lib/countries/data/subdivisions/AF.yaml +196 -201
  155. data/lib/countries/data/subdivisions/AG.yaml +16 -22
  156. data/lib/countries/data/subdivisions/AL.yaml +24 -12
  157. data/lib/countries/data/subdivisions/AM.yaml +22 -11
  158. data/lib/countries/data/subdivisions/AO.yaml +36 -18
  159. data/lib/countries/data/subdivisions/AR.yaml +48 -24
  160. data/lib/countries/data/subdivisions/AT.yaml +18 -9
  161. data/lib/countries/data/subdivisions/AU.yaml +16 -8
  162. data/lib/countries/data/subdivisions/AZ.yaml +434 -412
  163. data/lib/countries/data/subdivisions/BA.yaml +75 -223
  164. data/lib/countries/data/subdivisions/BB.yaml +22 -11
  165. data/lib/countries/data/subdivisions/BD.yaml +188 -116
  166. data/lib/countries/data/subdivisions/BE.yaml +174 -161
  167. data/lib/countries/data/subdivisions/BF.yaml +2918 -2860
  168. data/lib/countries/data/subdivisions/BG.yaml +56 -28
  169. data/lib/countries/data/subdivisions/BH.yaml +8 -21
  170. data/lib/countries/data/subdivisions/BI.yaml +176 -157
  171. data/lib/countries/data/subdivisions/BJ.yaml +24 -12
  172. data/lib/countries/data/subdivisions/BN.yaml +8 -4
  173. data/lib/countries/data/subdivisions/BO.yaml +18 -9
  174. data/lib/countries/data/subdivisions/BQ.yaml +6 -3
  175. data/lib/countries/data/subdivisions/BR.yaml +54 -27
  176. data/lib/countries/data/subdivisions/BS.yaml +575 -697
  177. data/lib/countries/data/subdivisions/BT.yaml +40 -20
  178. data/lib/countries/data/subdivisions/BW.yaml +337 -321
  179. data/lib/countries/data/subdivisions/BY.yaml +106 -116
  180. data/lib/countries/data/subdivisions/BZ.yaml +12 -6
  181. data/lib/countries/data/subdivisions/CA.yaml +26 -13
  182. data/lib/countries/data/subdivisions/CD.yaml +488 -525
  183. data/lib/countries/data/subdivisions/CF.yaml +34 -17
  184. data/lib/countries/data/subdivisions/CG.yaml +40 -28
  185. data/lib/countries/data/subdivisions/CH.yaml +52 -26
  186. data/lib/countries/data/subdivisions/CI.yaml +244 -516
  187. data/lib/countries/data/subdivisions/CL.yaml +81 -65
  188. data/lib/countries/data/subdivisions/CM.yaml +20 -10
  189. data/lib/countries/data/subdivisions/CN.yaml +2152 -2084
  190. data/lib/countries/data/subdivisions/CO.yaml +66 -33
  191. data/lib/countries/data/subdivisions/CR.yaml +14 -7
  192. data/lib/countries/data/subdivisions/CU.yaml +32 -16
  193. data/lib/countries/data/subdivisions/CV.yaml +427 -401
  194. data/lib/countries/data/subdivisions/CY.yaml +12 -6
  195. data/lib/countries/data/subdivisions/CZ.yaml +1116 -85
  196. data/lib/countries/data/subdivisions/DE.yaml +32 -16
  197. data/lib/countries/data/subdivisions/DJ.yaml +12 -6
  198. data/lib/countries/data/subdivisions/DK.yaml +25 -17
  199. data/lib/countries/data/subdivisions/DM.yaml +20 -10
  200. data/lib/countries/data/subdivisions/DO.yaml +84 -42
  201. data/lib/countries/data/subdivisions/DZ.yaml +96 -48
  202. data/lib/countries/data/subdivisions/EC.yaml +158 -134
  203. data/lib/countries/data/subdivisions/EE.yaml +501 -334
  204. data/lib/countries/data/subdivisions/EG.yaml +54 -27
  205. data/lib/countries/data/subdivisions/ER.yaml +12 -6
  206. data/lib/countries/data/subdivisions/ES.yaml +1459 -1390
  207. data/lib/countries/data/subdivisions/ET.yaml +22 -11
  208. data/lib/countries/data/subdivisions/FI.yaml +185 -1
  209. data/lib/countries/data/subdivisions/FJ.yaml +443 -424
  210. data/lib/countries/data/subdivisions/FM.yaml +8 -4
  211. data/lib/countries/data/subdivisions/FR.yaml +438 -275
  212. data/lib/countries/data/subdivisions/GA.yaml +18 -9
  213. data/lib/countries/data/subdivisions/GB.yaml +1185 -1708
  214. data/lib/countries/data/subdivisions/GD.yaml +14 -7
  215. data/lib/countries/data/subdivisions/GE.yaml +24 -12
  216. data/lib/countries/data/subdivisions/GH.yaml +114 -155
  217. data/lib/countries/data/subdivisions/GL.yaml +24 -79
  218. data/lib/countries/data/subdivisions/GM.yaml +12 -6
  219. data/lib/countries/data/subdivisions/GN.yaml +444 -403
  220. data/lib/countries/data/subdivisions/GQ.yaml +24 -13
  221. data/lib/countries/data/subdivisions/GR.yaml +114 -73
  222. data/lib/countries/data/subdivisions/GT.yaml +44 -22
  223. data/lib/countries/data/subdivisions/GW.yaml +69 -57
  224. data/lib/countries/data/subdivisions/GY.yaml +20 -10
  225. data/lib/countries/data/subdivisions/HN.yaml +36 -18
  226. data/lib/countries/data/subdivisions/HR.yaml +42 -21
  227. data/lib/countries/data/subdivisions/HT.yaml +73 -63
  228. data/lib/countries/data/subdivisions/HU.yaml +106 -63
  229. data/lib/countries/data/subdivisions/ID.yaml +229 -188
  230. data/lib/countries/data/subdivisions/IE.yaml +128 -97
  231. data/lib/countries/data/subdivisions/IL.yaml +12 -6
  232. data/lib/countries/data/subdivisions/IN.yaml +245 -396
  233. data/lib/countries/data/subdivisions/IQ.yaml +111 -91
  234. data/lib/countries/data/subdivisions/IR.yaml +1463 -1451
  235. data/lib/countries/data/subdivisions/IS.yaml +160 -25
  236. data/lib/countries/data/subdivisions/IT.yaml +8740 -8292
  237. data/lib/countries/data/subdivisions/JM.yaml +28 -14
  238. data/lib/countries/data/subdivisions/JO.yaml +24 -12
  239. data/lib/countries/data/subdivisions/JP.yaml +94 -47
  240. data/lib/countries/data/subdivisions/KE.yaml +95 -48
  241. data/lib/countries/data/subdivisions/KG.yaml +95 -86
  242. data/lib/countries/data/subdivisions/KH.yaml +64 -39
  243. data/lib/countries/data/subdivisions/KI.yaml +6 -3
  244. data/lib/countries/data/subdivisions/KM.yaml +6 -3
  245. data/lib/countries/data/subdivisions/KN.yaml +32 -16
  246. data/lib/countries/data/subdivisions/KP.yaml +24 -227
  247. data/lib/countries/data/subdivisions/KR.yaml +34 -17
  248. data/lib/countries/data/subdivisions/KW.yaml +12 -6
  249. data/lib/countries/data/subdivisions/KZ.yaml +47 -102
  250. data/lib/countries/data/subdivisions/LA.yaml +36 -34
  251. data/lib/countries/data/subdivisions/LB.yaml +71 -63
  252. data/lib/countries/data/subdivisions/LC.yaml +116 -106
  253. data/lib/countries/data/subdivisions/LI.yaml +22 -11
  254. data/lib/countries/data/subdivisions/LK.yaml +445 -411
  255. data/lib/countries/data/subdivisions/LR.yaml +146 -129
  256. data/lib/countries/data/subdivisions/LS.yaml +20 -10
  257. data/lib/countries/data/subdivisions/LT.yaml +1706 -1636
  258. data/lib/countries/data/subdivisions/LU.yaml +24 -12
  259. data/lib/countries/data/subdivisions/LV.yaml +1623 -1577
  260. data/lib/countries/data/subdivisions/LY.yaml +44 -22
  261. data/lib/countries/data/subdivisions/MA.yaml +810 -1589
  262. data/lib/countries/data/subdivisions/MC.yaml +261 -244
  263. data/lib/countries/data/subdivisions/MD.yaml +74 -79
  264. data/lib/countries/data/subdivisions/ME.yaml +217 -195
  265. data/lib/countries/data/subdivisions/MG.yaml +12 -6
  266. data/lib/countries/data/subdivisions/MH.yaml +167 -140
  267. data/lib/countries/data/subdivisions/MK.yaml +160 -80
  268. data/lib/countries/data/subdivisions/ML.yaml +48 -37
  269. data/lib/countries/data/subdivisions/MM.yaml +30 -15
  270. data/lib/countries/data/subdivisions/MN.yaml +44 -22
  271. data/lib/countries/data/subdivisions/MR.yaml +30 -34
  272. data/lib/countries/data/subdivisions/MT.yaml +136 -68
  273. data/lib/countries/data/subdivisions/MU.yaml +24 -262
  274. data/lib/countries/data/subdivisions/MV.yaml +161 -254
  275. data/lib/countries/data/subdivisions/MW.yaml +250 -219
  276. data/lib/countries/data/subdivisions/MX.yaml +67 -47
  277. data/lib/countries/data/subdivisions/MY.yaml +32 -16
  278. data/lib/countries/data/subdivisions/MZ.yaml +22 -11
  279. data/lib/countries/data/subdivisions/NA.yaml +58 -44
  280. data/lib/countries/data/subdivisions/NE.yaml +16 -8
  281. data/lib/countries/data/subdivisions/NG.yaml +74 -37
  282. data/lib/countries/data/subdivisions/NI.yaml +34 -17
  283. data/lib/countries/data/subdivisions/NL.yaml +303 -285
  284. data/lib/countries/data/subdivisions/NO.yaml +39 -17
  285. data/lib/countries/data/subdivisions/NP.yaml +302 -276
  286. data/lib/countries/data/subdivisions/NR.yaml +28 -14
  287. data/lib/countries/data/subdivisions/NZ.yaml +34 -17
  288. data/lib/countries/data/subdivisions/OM.yaml +260 -311
  289. data/lib/countries/data/subdivisions/PA.yaml +57 -44
  290. data/lib/countries/data/subdivisions/PE.yaml +107 -81
  291. data/lib/countries/data/subdivisions/PG.yaml +163 -158
  292. data/lib/countries/data/subdivisions/PH.yaml +5062 -4992
  293. data/lib/countries/data/subdivisions/PK.yaml +145 -235
  294. data/lib/countries/data/subdivisions/PL.yaml +51 -3
  295. data/lib/countries/data/subdivisions/PS.yaml +32 -16
  296. data/lib/countries/data/subdivisions/PT.yaml +40 -20
  297. data/lib/countries/data/subdivisions/PW.yaml +32 -16
  298. data/lib/countries/data/subdivisions/PY.yaml +36 -18
  299. data/lib/countries/data/subdivisions/QA.yaml +27 -78
  300. data/lib/countries/data/subdivisions/RO.yaml +84 -42
  301. data/lib/countries/data/subdivisions/RS.yaml +104 -72
  302. data/lib/countries/data/subdivisions/RU.yaml +166 -83
  303. data/lib/countries/data/subdivisions/RW.yaml +10 -5
  304. data/lib/countries/data/subdivisions/SA.yaml +26 -13
  305. data/lib/countries/data/subdivisions/SB.yaml +20 -10
  306. data/lib/countries/data/subdivisions/SC.yaml +54 -25
  307. data/lib/countries/data/subdivisions/SD.yaml +798 -780
  308. data/lib/countries/data/subdivisions/SE.yaml +42 -21
  309. data/lib/countries/data/subdivisions/SG.yaml +15 -10
  310. data/lib/countries/data/subdivisions/SH.yaml +21 -32
  311. data/lib/countries/data/subdivisions/SI.yaml +475 -263
  312. data/lib/countries/data/subdivisions/SK.yaml +16 -8
  313. data/lib/countries/data/subdivisions/SL.yaml +23 -18
  314. data/lib/countries/data/subdivisions/SM.yaml +18 -9
  315. data/lib/countries/data/subdivisions/SN.yaml +188 -174
  316. data/lib/countries/data/subdivisions/SO.yaml +36 -18
  317. data/lib/countries/data/subdivisions/SR.yaml +20 -10
  318. data/lib/countries/data/subdivisions/SS.yaml +20 -10
  319. data/lib/countries/data/subdivisions/ST.yaml +38 -52
  320. data/lib/countries/data/subdivisions/SV.yaml +28 -14
  321. data/lib/countries/data/subdivisions/SY.yaml +28 -14
  322. data/lib/countries/data/subdivisions/SZ.yaml +8 -4
  323. data/lib/countries/data/subdivisions/TD.yaml +312 -303
  324. data/lib/countries/data/subdivisions/TG.yaml +10 -5
  325. data/lib/countries/data/subdivisions/TH.yaml +211 -133
  326. data/lib/countries/data/subdivisions/TJ.yaml +161 -156
  327. data/lib/countries/data/subdivisions/TL.yaml +26 -13
  328. data/lib/countries/data/subdivisions/TM.yaml +12 -6
  329. data/lib/countries/data/subdivisions/TN.yaml +48 -24
  330. data/lib/countries/data/subdivisions/TO.yaml +10 -5
  331. data/lib/countries/data/subdivisions/TR.yaml +162 -81
  332. data/lib/countries/data/subdivisions/TT.yaml +128 -160
  333. data/lib/countries/data/subdivisions/TV.yaml +57 -63
  334. data/lib/countries/data/subdivisions/TW.yaml +143 -183
  335. data/lib/countries/data/subdivisions/TZ.yaml +62 -31
  336. data/lib/countries/data/subdivisions/UA.yaml +55 -28
  337. data/lib/countries/data/subdivisions/UG.yaml +4806 -4660
  338. data/lib/countries/data/subdivisions/UM.yaml +18 -9
  339. data/lib/countries/data/subdivisions/US.yaml +114 -57
  340. data/lib/countries/data/subdivisions/UY.yaml +99 -80
  341. data/lib/countries/data/subdivisions/UZ.yaml +28 -14
  342. data/lib/countries/data/subdivisions/VC.yaml +12 -6
  343. data/lib/countries/data/subdivisions/VE.yaml +50 -25
  344. data/lib/countries/data/subdivisions/VN.yaml +3576 -3513
  345. data/lib/countries/data/subdivisions/VU.yaml +12 -6
  346. data/lib/countries/data/subdivisions/WF.yaml +6 -3
  347. data/lib/countries/data/subdivisions/WS.yaml +22 -11
  348. data/lib/countries/data/subdivisions/YE.yaml +222 -200
  349. data/lib/countries/data/subdivisions/ZA.yaml +86 -100
  350. data/lib/countries/data/subdivisions/ZM.yaml +20 -10
  351. data/lib/countries/data/subdivisions/ZW.yaml +20 -10
  352. data/lib/countries/data/translations/countries-ab.yaml +254 -0
  353. data/lib/countries/data/translations/countries-af.yaml +254 -0
  354. data/lib/countries/data/translations/countries-ak.yaml +254 -0
  355. data/lib/countries/data/translations/countries-am.yaml +254 -0
  356. data/lib/countries/data/translations/countries-an.yaml +254 -0
  357. data/lib/countries/data/translations/countries-ar.yaml +254 -0
  358. data/lib/countries/data/translations/countries-as.yaml +254 -0
  359. data/lib/countries/data/translations/countries-ay.yaml +254 -0
  360. data/lib/countries/data/translations/countries-az.yaml +254 -0
  361. data/lib/countries/data/translations/countries-ba.yaml +254 -0
  362. data/lib/countries/data/translations/countries-be.yaml +254 -0
  363. data/lib/countries/data/translations/countries-bg.yaml +254 -0
  364. data/lib/countries/data/translations/countries-bi.yaml +254 -0
  365. data/lib/countries/data/translations/countries-bn.yaml +254 -0
  366. data/lib/countries/data/translations/countries-bn_IN.yaml +254 -0
  367. data/lib/countries/data/translations/countries-br.yaml +254 -0
  368. data/lib/countries/data/translations/countries-bs.yaml +254 -0
  369. data/lib/countries/data/translations/countries-ca.yaml +254 -0
  370. data/lib/countries/data/translations/countries-ce.yaml +254 -0
  371. data/lib/countries/data/translations/countries-ch.yaml +254 -0
  372. data/lib/countries/data/translations/countries-cs.yaml +254 -0
  373. data/lib/countries/data/translations/countries-cv.yaml +254 -0
  374. data/lib/countries/data/translations/countries-cy.yaml +254 -0
  375. data/lib/countries/data/translations/countries-da.yaml +254 -0
  376. data/lib/countries/data/translations/countries-de.yaml +254 -0
  377. data/lib/countries/data/translations/countries-dv.yaml +254 -0
  378. data/lib/countries/data/translations/countries-dz.yaml +254 -0
  379. data/lib/countries/data/translations/countries-ee.yaml +254 -0
  380. data/lib/countries/data/translations/countries-el.yaml +254 -0
  381. data/lib/countries/data/translations/countries-en.yaml +254 -0
  382. data/lib/countries/data/translations/countries-eo.yaml +254 -0
  383. data/lib/countries/data/translations/countries-es.yaml +254 -0
  384. data/lib/countries/data/translations/countries-et.yaml +254 -0
  385. data/lib/countries/data/translations/countries-eu.yaml +254 -0
  386. data/lib/countries/data/translations/countries-fa.yaml +254 -0
  387. data/lib/countries/data/translations/countries-ff.yaml +254 -0
  388. data/lib/countries/data/translations/countries-fi.yaml +254 -0
  389. data/lib/countries/data/translations/countries-fo.yaml +254 -0
  390. data/lib/countries/data/translations/countries-fr.yaml +254 -0
  391. data/lib/countries/data/translations/countries-fy.yaml +254 -0
  392. data/lib/countries/data/translations/countries-ga.yaml +254 -0
  393. data/lib/countries/data/translations/countries-gl.yaml +254 -0
  394. data/lib/countries/data/translations/countries-gn.yaml +254 -0
  395. data/lib/countries/data/translations/countries-gu.yaml +254 -0
  396. data/lib/countries/data/translations/countries-gv.yaml +254 -0
  397. data/lib/countries/data/translations/countries-ha.yaml +254 -0
  398. data/lib/countries/data/translations/countries-he.yaml +254 -0
  399. data/lib/countries/data/translations/countries-hi.yaml +254 -0
  400. data/lib/countries/data/translations/countries-hr.yaml +254 -0
  401. data/lib/countries/data/translations/countries-ht.yaml +254 -0
  402. data/lib/countries/data/translations/countries-hu.yaml +254 -0
  403. data/lib/countries/data/translations/countries-hy.yaml +254 -0
  404. data/lib/countries/data/translations/countries-ia.yaml +254 -0
  405. data/lib/countries/data/translations/countries-id.yaml +254 -0
  406. data/lib/countries/data/translations/countries-io.yaml +254 -0
  407. data/lib/countries/data/translations/countries-is.yaml +254 -0
  408. data/lib/countries/data/translations/countries-it.yaml +254 -0
  409. data/lib/countries/data/translations/countries-iu.yaml +254 -0
  410. data/lib/countries/data/translations/countries-ja.yaml +254 -0
  411. data/lib/countries/data/translations/countries-ka.yaml +254 -0
  412. data/lib/countries/data/translations/countries-ki.yaml +254 -0
  413. data/lib/countries/data/translations/countries-kk.yaml +254 -0
  414. data/lib/countries/data/translations/countries-kl.yaml +254 -0
  415. data/lib/countries/data/translations/countries-km.yaml +254 -0
  416. data/lib/countries/data/translations/countries-kn.yaml +254 -0
  417. data/lib/countries/data/translations/countries-ko.yaml +254 -0
  418. data/lib/countries/data/translations/countries-ku.yaml +254 -0
  419. data/lib/countries/data/translations/countries-kv.yaml +254 -0
  420. data/lib/countries/data/translations/countries-kw.yaml +254 -0
  421. data/lib/countries/data/translations/countries-ky.yaml +254 -0
  422. data/lib/countries/data/translations/countries-lo.yaml +254 -0
  423. data/lib/countries/data/translations/countries-lt.yaml +254 -0
  424. data/lib/countries/data/translations/countries-lv.yaml +254 -0
  425. data/lib/countries/data/translations/countries-mi.yaml +254 -0
  426. data/lib/countries/data/translations/countries-mk.yaml +254 -0
  427. data/lib/countries/data/translations/countries-ml.yaml +254 -0
  428. data/lib/countries/data/translations/countries-mn.yaml +254 -0
  429. data/lib/countries/data/translations/countries-mr.yaml +254 -0
  430. data/lib/countries/data/translations/countries-ms.yaml +254 -0
  431. data/lib/countries/data/translations/countries-mt.yaml +254 -0
  432. data/lib/countries/data/translations/countries-my.yaml +254 -0
  433. data/lib/countries/data/translations/countries-na.yaml +254 -0
  434. data/lib/countries/data/translations/countries-nb.yaml +254 -0
  435. data/lib/countries/data/translations/countries-ne.yaml +254 -0
  436. data/lib/countries/data/translations/countries-nl.yaml +254 -0
  437. data/lib/countries/data/translations/countries-nn.yaml +254 -0
  438. data/lib/countries/data/translations/countries-nv.yaml +254 -0
  439. data/lib/countries/data/translations/countries-oc.yaml +254 -0
  440. data/lib/countries/data/translations/countries-or.yaml +254 -0
  441. data/lib/countries/data/translations/countries-pa.yaml +254 -0
  442. data/lib/countries/data/translations/countries-pi.yaml +254 -0
  443. data/lib/countries/data/translations/countries-pl.yaml +254 -0
  444. data/lib/countries/data/translations/countries-ps.yaml +254 -0
  445. data/lib/countries/data/translations/countries-pt.yaml +254 -0
  446. data/lib/countries/data/translations/countries-pt_BR.yaml +254 -0
  447. data/lib/countries/data/translations/countries-ro.yaml +254 -0
  448. data/lib/countries/data/translations/countries-ru.yaml +254 -0
  449. data/lib/countries/data/translations/countries-rw.yaml +254 -0
  450. data/lib/countries/data/translations/countries-sc.yaml +254 -0
  451. data/lib/countries/data/translations/countries-sd.yaml +254 -0
  452. data/lib/countries/data/translations/countries-si.yaml +254 -0
  453. data/lib/countries/data/translations/countries-sk.yaml +254 -0
  454. data/lib/countries/data/translations/countries-sl.yaml +254 -0
  455. data/lib/countries/data/translations/countries-so.yaml +254 -0
  456. data/lib/countries/data/translations/countries-sq.yaml +254 -0
  457. data/lib/countries/data/translations/countries-sr.yaml +254 -0
  458. data/lib/countries/data/translations/countries-sv.yaml +254 -0
  459. data/lib/countries/data/translations/countries-sw.yaml +254 -0
  460. data/lib/countries/data/translations/countries-ta.yaml +254 -0
  461. data/lib/countries/data/translations/countries-te.yaml +254 -0
  462. data/lib/countries/data/translations/countries-tg.yaml +254 -0
  463. data/lib/countries/data/translations/countries-th.yaml +254 -0
  464. data/lib/countries/data/translations/countries-ti.yaml +254 -0
  465. data/lib/countries/data/translations/countries-tk.yaml +254 -0
  466. data/lib/countries/data/translations/countries-tl.yaml +254 -0
  467. data/lib/countries/data/translations/countries-tr.yaml +254 -0
  468. data/lib/countries/data/translations/countries-tt.yaml +254 -0
  469. data/lib/countries/data/translations/countries-ug.yaml +254 -0
  470. data/lib/countries/data/translations/countries-uk.yaml +254 -0
  471. data/lib/countries/data/translations/countries-ur.yaml +254 -0
  472. data/lib/countries/data/translations/countries-uz.yaml +254 -0
  473. data/lib/countries/data/translations/countries-ve.yaml +254 -0
  474. data/lib/countries/data/translations/countries-vi.yaml +254 -0
  475. data/lib/countries/data/translations/countries-wa.yaml +254 -0
  476. data/lib/countries/data/translations/countries-wo.yaml +254 -0
  477. data/lib/countries/data/translations/countries-xh.yaml +254 -0
  478. data/lib/countries/data/translations/countries-yo.yaml +254 -0
  479. data/lib/countries/data/translations/countries-zh_CN.yaml +254 -0
  480. data/lib/countries/data/translations/countries-zh_HK.yaml +254 -0
  481. data/lib/countries/data/translations/countries-zh_TW.yaml +254 -0
  482. data/lib/countries/data/translations/countries-zu.yaml +254 -0
  483. data/lib/countries/data.rb +40 -8
  484. data/lib/countries/iso3166.rb +0 -1
  485. data/lib/countries/sources/cldr/subdivision_updater.rb +1 -1
  486. data/lib/countries/subdivision.rb +19 -8
  487. data/lib/countries/version.rb +1 -1
  488. data/spec/country_spec.rb +63 -19
  489. data/spec/data_spec.rb +74 -5
  490. metadata +134 -24
  491. data/lib/countries/cache/locales/zh.json +0 -1
  492. data/lib/countries/data/subdivisions/AI.yaml +0 -197
  493. data/lib/countries/data/subdivisions/BM.yaml +0 -155
  494. data/lib/countries/data/subdivisions/CK.yaml +0 -155
  495. data/lib/countries/data/subdivisions/EH.yaml +0 -80
  496. data/lib/countries/data/subdivisions/SJ.yaml +0 -29
  497. data/lib/countries/data/subdivisions/TK.yaml +0 -43
  498. data/lib/countries/data/translation_corrections.yaml +0 -51
@@ -0,0 +1,254 @@
1
+ # Country name translations for locale zu
2
+ #
3
+ # alpha2: localized_name
4
+ #
5
+ ---
6
+ AD: I-Andora
7
+ AE: United Arab Emirates
8
+ AF: I-Afganistani
9
+ AG: Antigua no Barbuda
10
+ AI: Anguilla
11
+ AL: I-Albaniya
12
+ AM: Armenia
13
+ AO: I-Angola
14
+ AQ: Antarctica
15
+ AR: I-Argentina
16
+ AS: American Samoa
17
+ AT: I-Ostriya
18
+ AU: I-Ostreliya
19
+ AW: Aruba
20
+ AX: Åland Islands
21
+ AZ: I-Azerbayijani
22
+ BA: IBhosniya neHerzegovina
23
+ BB: I-Barbados
24
+ BD: Isi-Bhangladeshi
25
+ BE: Isi-Bhelijiyamu
26
+ BF: IBukhina Faso
27
+ BG: IBulgariya
28
+ BH: Bahrain
29
+ BI: IBurundi
30
+ BJ: IBenini
31
+ BL: Saint Barthélemy
32
+ BM: Bermuda
33
+ BN: Brunei Darussalam
34
+ BO: I Boliviya
35
+ BQ: Bonaire, Sint Eustatius and Saba
36
+ BR: IBrazili
37
+ BS: Bahamas
38
+ BT: Bhutan
39
+ BV: Bouvet Island
40
+ BW: IButswana
41
+ BY: IBelarusi
42
+ BZ: Belize
43
+ CA: I Khanada
44
+ CC: Cocos (Keeling) Islands
45
+ CD: Congo, The Democratic Republic of the
46
+ CF: Central African Republic
47
+ CG: Congo
48
+ CH: I-Switzerland
49
+ CI: Côte d'Ivoire
50
+ CK: Cook Islands
51
+ CL: I-Chile
52
+ CM: IKamerooni
53
+ CN: Isi-Shayina
54
+ CO: IKolombiya
55
+ CR: Costa Rica
56
+ CU: Cuba
57
+ CV: Cabo Verde
58
+ CW: Curaçao
59
+ CX: Christmas Island
60
+ CY: Cyprus
61
+ CZ: Czechia
62
+ DE: IJalimani
63
+ DJ: IJibuthi
64
+ DK: IDenimaki
65
+ DM: Dominica
66
+ DO: Ulawulo lokuziphatha kwe Dominikhani
67
+ DZ: IAljiriya
68
+ EC: Ecuador
69
+ EE: I-Estoniya
70
+ EG: IGibhithe
71
+ EH: Western Sahara
72
+ ER: I-Eritrea
73
+ ES: ISpeyini
74
+ ET: I-Ithiopia
75
+ FI: IFinlandi
76
+ FJ: IFiji
77
+ FK: Falkland Islands (Malvinas)
78
+ FM: Micronesia, Federated States of
79
+ FO: Faroe Islands
80
+ FR: IFulansi
81
+ GA: IGaboni
82
+ GB: Umbuso Ohlangeneyo
83
+ GD: I-Grenada
84
+ GE: Georgia
85
+ GF: French Guiana
86
+ GG: Guernsey
87
+ GH: IGana
88
+ GI: Gibraltar
89
+ GL: Greenland
90
+ GM: Gambia
91
+ GN: IGini
92
+ GP: Guadeloupe
93
+ GQ: IGini Enkabazwe
94
+ GR: IGreki
95
+ GS: South Georgia and the South Sandwich Islands
96
+ GT: I-Guwathemala
97
+ GU: Guam
98
+ GW: IGini Bisawu
99
+ GY: Guyana
100
+ HK: Hong Kong
101
+ HM: Heard Island and McDonald Islands
102
+ HN: I-Hondurasi
103
+ HR: IKrowati
104
+ HT: Haiti
105
+ HU: I-Hungariya
106
+ ID: I-Indonesia
107
+ IE: I-Ayilendi
108
+ IL: Isreyili
109
+ IM: Isle of Man
110
+ IN: India
111
+ IO: British Indian Ocean Territory
112
+ IQ: I-Iraki
113
+ IR: Iran, Islamic Republic of
114
+ IS: I-Ayisilandi
115
+ IT: ITaliya
116
+ JE: Jersey
117
+ JM: Jamaica
118
+ JO: Jordan
119
+ JP: IJaphani
120
+ KE: IKenya
121
+ KG: Kyrgyzstan
122
+ KH: Cambodia
123
+ KI: Kiribati
124
+ KM: IsiKhomorosi
125
+ KN: Saint Kitts and Nevis
126
+ KP: North Korea
127
+ KR: South Korea
128
+ KW: Kuwait
129
+ KY: Cayman Islands
130
+ KZ: Kazakhstan
131
+ LA: Lao People's Democratic Republic
132
+ LB: Lebanon
133
+ LC: Saint Lucia
134
+ LI: Liechtenstein
135
+ LK: Sri Lanka
136
+ LR: ILiberia
137
+ LS: OSotho
138
+ LT: ILithuwaniya
139
+ LU: I-Luxembourg
140
+ LV: ILatviya
141
+ LY: ILibiya
142
+ MA: IMorokho
143
+ MC: Monaco
144
+ MD: Moldova
145
+ ME: IMontenegro
146
+ MF: Saint Martin (French part)
147
+ MG: IMadagasika
148
+ MH: Marshall Islands
149
+ MK: North Macedonia
150
+ ML: IMali
151
+ MM: Myanmar
152
+ MN: Mongolia
153
+ MO: Macao
154
+ MP: Northern Mariana Islands
155
+ MQ: Martinique
156
+ MR: IMoritaniya
157
+ MS: Montserrat
158
+ MT: IMalta
159
+ MU: IMorishisi
160
+ MV: Maldives
161
+ MW: IMalawi
162
+ MX: IMekisiko
163
+ MY: Malaysia
164
+ MZ: IMozambiki
165
+ NA: INamibhiya
166
+ NC: New Caledonia
167
+ NE: INayighe
168
+ NF: Norfolk Island
169
+ NG: INigeria
170
+ NI: Nicaragua
171
+ NL: I-Netherlands
172
+ 'NO': INoki
173
+ NP: Nepal
174
+ NR: Nauru
175
+ NU: Niue
176
+ NZ: INyuzilandi
177
+ OM: Oman
178
+ PA: Panama
179
+ PE: I-Peru
180
+ PF: French Polynesia
181
+ PG: Papua New Guinea
182
+ PH: Philippines
183
+ PK: IPakistani
184
+ PL: IPolandi
185
+ PM: Saint Pierre and Miquelon
186
+ PN: Pitcairn
187
+ PR: Puerto Rico
188
+ PS: Palestine, State of
189
+ PT: IPhothugali
190
+ PW: Palau
191
+ PY: I-Paraguwayi
192
+ QA: Qatar
193
+ RE: IRiyunion
194
+ RO: I-Romaniya
195
+ RS: ISerbiya
196
+ RU: Russian Federation
197
+ RW: IRuwanda
198
+ SA: Saudi Arabia
199
+ SB: Solomon Islands
200
+ SC: IsiSeyisheli
201
+ SD: ISudan
202
+ SE: ISwidi
203
+ SG: Singapore
204
+ SH: Saint Helena, Ascension and Tristan da Cunha
205
+ SI: ISloveniya
206
+ SJ: Svalbard and Jan Mayen
207
+ SK: ISlovaki
208
+ SL: ISiera Liyoni
209
+ SM: USanti Marino
210
+ SN: ISenegal
211
+ SO: ISomalia
212
+ SR: Suriname
213
+ SS: ISudan yaseNingizimu
214
+ ST: ISawu Tome noPhrinitshipeyi
215
+ SV: El Salvador
216
+ SX: Sint Maarten (Dutch part)
217
+ SY: Syrian Arab Republic
218
+ SZ: Eswatini
219
+ TC: Turks and Caicos Islands
220
+ TD: ITshedi
221
+ TF: French Southern Territories
222
+ TG: ITogo
223
+ TH: I-Thayilandi
224
+ TJ: Tajikistan
225
+ TK: Tokelau
226
+ TL: Timor-Leste
227
+ TM: Turkmenistan
228
+ TN: ITunisia
229
+ TO: Tonga
230
+ TR: ITheki
231
+ TT: I-Trinidad ne Tobago
232
+ TV: Tuvalu
233
+ TW: I-Tayiwani
234
+ TZ: ITanzania
235
+ UA: I-Yukreyini
236
+ UG: IYuganda
237
+ UM: United States Minor Outlying Islands
238
+ US: United States
239
+ UY: I-Uruguwayi
240
+ UZ: Uzbekistan
241
+ VA: Holy See (Vatican City State)
242
+ VC: Saint Vincent and the Grenadines
243
+ VE: I-Venezuwela
244
+ VG: Virgin Islands, British
245
+ VI: Virgin Islands, U.S.
246
+ VN: IViyetnami
247
+ VU: Vanuatu
248
+ WF: Wallis and Futuna
249
+ WS: Samoa
250
+ YE: IYemen
251
+ YT: IMayotte
252
+ ZA: IRiphabliki yaseNingizimu Afrika
253
+ ZM: IZambiya
254
+ ZW: IZimbabwe
@@ -5,8 +5,10 @@ module ISO3166
5
5
  class Data
6
6
  @cache_dir = [File.dirname(__FILE__), 'cache']
7
7
  @cache = {}
8
+ @loaded_country_codes = []
8
9
  @registered_data = {}
9
10
  @mutex = Mutex.new
11
+ @subdivisions = {}
10
12
 
11
13
  def initialize(alpha2)
12
14
  @alpha2 = alpha2.to_s.upcase
@@ -43,13 +45,14 @@ module ISO3166
43
45
  # Resets the loaded data and cache
44
46
  def reset
45
47
  @cache = {}
48
+ @subdivisions = {}
46
49
  @registered_data = {}
47
50
  ISO3166.configuration.loaded_locales = []
48
51
  end
49
52
 
50
53
  def codes
51
54
  load_data!
52
- loaded_codes
55
+ cached_codes
53
56
  end
54
57
 
55
58
  def update_cache
@@ -58,6 +61,35 @@ module ISO3166
58
61
  @cache
59
62
  end
60
63
 
64
+ def loaded_codes
65
+ load_data!
66
+ @loaded_country_codes
67
+ end
68
+
69
+ def datafile_path(file_array)
70
+ File.join([@cache_dir] + file_array)
71
+ end
72
+
73
+ def subdivision_data(alpha2)
74
+ file = subdivision_file_path(alpha2)
75
+ data = File.exist?(file) ? YAML.load_file(file) : {}
76
+ locales = ISO3166.configuration.locales.map(&:to_s)
77
+ data.each_value{ |v| v['translations'] = v['translations'].slice(*locales)}
78
+
79
+ return data
80
+ end
81
+
82
+ def subdivisions(alpha2)
83
+ @subdivisions ||= {}
84
+ @subdivisions[alpha2] ||= create_subdivisions(ISO3166::Data.subdivision_data(alpha2))
85
+ end
86
+
87
+ def create_subdivisions(subdivision_data)
88
+ subdivision_data.each_with_object({}) do |(k, v), hash|
89
+ hash[k] = Subdivision.new(v)
90
+ end
91
+ end
92
+
61
93
  private
62
94
 
63
95
  def load_data!
@@ -65,7 +97,7 @@ module ISO3166
65
97
 
66
98
  synchronized do
67
99
  @cache = load_cache %w[countries.json]
68
- @_country_codes = @cache.keys
100
+ @loaded_country_codes = @cache.keys
69
101
  @cache = @cache.merge(@registered_data)
70
102
  @cache
71
103
  end
@@ -102,13 +134,13 @@ module ISO3166
102
134
  end
103
135
  end
104
136
 
105
- def loaded_codes
137
+ def cached_codes
106
138
  @cache.keys
107
139
  end
108
140
 
109
141
  # Codes that we have translations for in dataset
110
142
  def internal_codes
111
- @_country_codes - @registered_data.keys
143
+ @loaded_country_codes - @registered_data.keys
112
144
  end
113
145
 
114
146
  def cache_flush_required?
@@ -158,10 +190,6 @@ module ISO3166
158
190
  File.exist?(file_path) ? JSON.parse(File.binread(file_path)) : {}
159
191
  end
160
192
 
161
- def datafile_path(file_array)
162
- File.join([@cache_dir] + file_array)
163
- end
164
-
165
193
  def deep_stringify_keys(data)
166
194
  data.transform_keys!(&:to_s)
167
195
  data.transform_values! do |v|
@@ -170,6 +198,10 @@ module ISO3166
170
198
 
171
199
  data
172
200
  end
201
+
202
+ def subdivision_file_path(alpha2)
203
+ File.join(File.dirname(__FILE__), 'data', 'subdivisions', "#{alpha2}.yaml")
204
+ end
173
205
  end
174
206
  end
175
207
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'yaml'
4
4
  require 'json'
5
- require 'i18n_data'
6
5
 
7
6
  require 'countries/kwarg_struct'
8
7
  require 'countries/configuration'
@@ -19,7 +19,7 @@ module Sources
19
19
  language_data = Nokogiri::XML(File.read(file_path))
20
20
  language_code = File.basename(file_path, '.*')
21
21
  subdivisions = language_data.css('subdivision')
22
- next if subdivisions.empty?
22
+ return if subdivisions.empty?
23
23
 
24
24
  last_country_code_seen = nil
25
25
 
@@ -1,12 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ISO3166
4
- Subdivision = KwargStruct.new(
5
- :name,
6
- :code,
7
- :unofficial_names,
8
- :geo,
9
- :translations,
10
- :comments
11
- )
4
+ class Subdivision
5
+ attr_accessor :name,
6
+ :code,
7
+ :unofficial_names,
8
+ :geo,
9
+ :translations,
10
+ :comments,
11
+ :type
12
+
13
+ def initialize(attrs)
14
+ attrs.each_pair do |k, v|
15
+ send "#{k}=", v
16
+ end
17
+ end
18
+
19
+ def [](attr_name)
20
+ send attr_name
21
+ end
22
+ end
12
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Countries
4
- VERSION = '5.0.1'.freeze
4
+ VERSION = '5.1.2'.freeze
5
5
  end
data/spec/country_spec.rb CHANGED
@@ -221,7 +221,7 @@ describe ISO3166::Country do
221
221
  end
222
222
 
223
223
  describe 'subdivisions' do
224
- let(:virginia) { country.states['VA'] }
224
+ let(:virginia) { country.subdivisions['VA'] }
225
225
  it 'should return an empty hash for a country with no ISO3166-2' do
226
226
  expect(ISO3166::Country.search('VA').subdivisions.size).to eq(0)
227
227
  end
@@ -230,8 +230,8 @@ describe ISO3166::Country do
230
230
  expect(country.subdivisions.size).to eq(57)
231
231
  end
232
232
 
233
- it 'should be available through states' do
234
- expect(country.states.size).to eq(57)
233
+ it '#states should be deprecated' do
234
+ expect {country.states}.to output.to_stderr
235
235
  end
236
236
 
237
237
  it 'should be a subdivision object' do
@@ -251,6 +251,60 @@ describe ISO3166::Country do
251
251
  end
252
252
  end
253
253
 
254
+ describe 'subdivision_types' do
255
+ it "should return an array of subdivision types" do
256
+ expect(country.subdivision_types).to contain_exactly('district', 'state', 'outlying_area')
257
+ end
258
+
259
+ it "should return an array of subdivision types even if there is only a single type" do
260
+ expect(ISO3166::Country['LI'].subdivision_types).to contain_exactly('commune')
261
+ end
262
+
263
+ it "should return an empty array if country has no subdivisions" do
264
+ expect(ISO3166::Country['AS'].subdivisions?).to be_falsey
265
+ expect(ISO3166::Country['AS'].subdivision_types).to eq([])
266
+ end
267
+ end
268
+
269
+ describe 'subdivisions_of_types' do
270
+ it "given a single type, should return an array of subdivisions that match the type" do
271
+ us_states = country.subdivisions_of_types(%w[state])
272
+ expect(us_states.size).to eq(50)
273
+ dc = country.subdivisions_of_types(%w[district])
274
+ expect(dc.size).to eq(1)
275
+ end
276
+
277
+ it "given multiple types, should return an array of subdivisions matching the types" do
278
+ us_states_plus_dc = country.subdivisions_of_types(%w[state district])
279
+ expect(us_states_plus_dc.size).to eq(51)
280
+ end
281
+
282
+ it "given multiple types where at least one does not exist for that country, should work without issue" do
283
+ us_states_plus_dc = country.subdivisions_of_types(%w[state district governorate])
284
+ expect(us_states_plus_dc.size).to eq(51)
285
+ end
286
+
287
+ it "given only types that do not exist for that country, should return an empty collection" do
288
+ should_be_empty = ISO3166::Country['PT'].subdivisions_of_types(%w[state county])
289
+ expect(should_be_empty).to be_empty
290
+ end
291
+ end
292
+
293
+ describe 'humanized_subdivision_types' do
294
+ it "should return an array of humanized subdivision types" do
295
+ expect(country.humanized_subdivision_types).to contain_exactly('District', 'State', 'Outlying area')
296
+ end
297
+
298
+ it "should return an array of subdivision types even if there is only a single type" do
299
+ expect(ISO3166::Country['LI'].humanized_subdivision_types).to contain_exactly('Commune')
300
+ end
301
+
302
+ it "should return an empty array if country has no subdivisions" do
303
+ expect(ISO3166::Country['AS'].subdivisions?).to be_falsey
304
+ expect(ISO3166::Country['AS'].humanized_subdivision_types).to eq([])
305
+ end
306
+ end
307
+
254
308
  describe 'subdivision_names_with_codes' do
255
309
  it 'should return an alphabetized list of all subdivisions names with codes' do
256
310
  subdivisions = ISO3166::Country.search('EG').subdivision_names_with_codes
@@ -330,7 +384,7 @@ describe ISO3166::Country do
330
384
  countries = ISO3166::Country.all_translated('fr')
331
385
  expect(countries).to be_an(Array)
332
386
  expect(countries.first).to be_a(String)
333
- expect(countries.first).to eq('Aruba')
387
+ expect(countries.first).to eq('Andorre')
334
388
  # countries missing the desired locale will not be added to the list
335
389
  # so all 250 countries may not be returned, 'fr' returns 249, for example
336
390
  expect(countries.size).to eq(NUM_OF_COUNTRIES)
@@ -340,7 +394,7 @@ describe ISO3166::Country do
340
394
  countries = ISO3166::Country.all_translated
341
395
  expect(countries).to be_an(Array)
342
396
  expect(countries.first).to be_a(String)
343
- expect(countries.first).to eq('Aruba')
397
+ expect(countries.first).to eq('Andorra')
344
398
  expect(countries.size).to eq(NUM_OF_COUNTRIES)
345
399
  end
346
400
 
@@ -448,8 +502,8 @@ describe ISO3166::Country do
448
502
  it 'should return an hash of all country names translated to the selected locale' do
449
503
  countries = ISO3166::Country.translations('fr')
450
504
  expect(countries).to be_an(Hash)
451
- expect(countries.first[0]).to eq('AW')
452
- expect(countries.first).to eq(%w[AW Aruba])
505
+ expect(countries.first[0]).to eq('AD')
506
+ expect(countries.first).to eq(%w[AD Andorre])
453
507
  # countries missing the desired locale will not be added to the list
454
508
  # so all 250 countries may not be returned, 'fr' returns 249, for example
455
509
  expect(countries.size).to eq(NUM_OF_COUNTRIES)
@@ -458,8 +512,8 @@ describe ISO3166::Country do
458
512
  it 'should return an hash of all country names in English if no locale is passed' do
459
513
  countries = ISO3166::Country.translations
460
514
  expect(countries).to be_an(Hash)
461
- expect(countries.first[0]).to eq('AW')
462
- expect(countries.first).to eq(%w[AW Aruba])
515
+ expect(countries.first[0]).to eq('AD')
516
+ expect(countries.first).to eq(%w[AD Andorra])
463
517
  expect(countries.size).to eq(NUM_OF_COUNTRIES)
464
518
  end
465
519
  end
@@ -896,16 +950,6 @@ describe ISO3166::Country do
896
950
  end
897
951
  end
898
952
 
899
- describe 'names in Data' do
900
- it 'should be unique (to allow .find_by_any_name work properly)' do
901
- names = ISO3166::Data.cache.map do |_k, v|
902
- [v['iso_short_name'], v['unofficial_names']].flatten.uniq
903
- end.flatten
904
-
905
- expect(names.size).to eq(names.uniq.size)
906
- end
907
- end
908
-
909
953
  describe 'Norway' do
910
954
  let(:norway) { ISO3166::Country.search('NO') }
911
955
 
data/spec/data_spec.rb CHANGED
@@ -26,6 +26,17 @@ describe ISO3166::Data do
26
26
  expect(data['translated_names'].size).to eq 1
27
27
  end
28
28
 
29
+ it 'only loads subdivision translations for the configured locales' do
30
+ ISO3166.configuration.locales = %i[en]
31
+ ISO3166::Data.reset
32
+ subdivisions = ISO3166::Data.subdivisions('US')
33
+ expect(subdivisions.values.first['translations'].keys).to eq(%w[en])
34
+ ISO3166.configuration.locales = %i[es de en]
35
+ ISO3166::Data.reset
36
+ subdivisions = ISO3166::Data.subdivisions('US')
37
+ expect(subdivisions.values.first['translations'].keys).to eq(%w[es de en])
38
+ end
39
+
29
40
  describe '#codes' do
30
41
  it 'returns an array' do
31
42
  data = ISO3166::Data.codes
@@ -122,8 +133,12 @@ describe ISO3166::Data do
122
133
  expect(subject.iso_short_name).to eq 'NEW Taiwan'
123
134
  expect(subject.translations).to eq('en' => 'NEW Taiwan',
124
135
  'de' => 'NEW Taiwan')
125
- expect(subject.subdivisions).to eq('CHA' => ISO3166::Subdivision.new({ name: 'New Changhua', code: 'CHA' }),
126
- 'CYI' => ISO3166::Subdivision.new({ name: 'New Municipality', code: 'CYI' }))
136
+ expect(subject.subdivisions.keys).to eq(%w[CHA CYI])
137
+ expect(subject.subdivisions.values.map(&:name)).to eq(['New Changhua', 'New Municipality'])
138
+ end
139
+
140
+ after do
141
+ ISO3166.reset
127
142
  end
128
143
  end
129
144
 
@@ -149,8 +164,8 @@ describe ISO3166::Data do
149
164
  data = ISO3166::Data.new('LOL').call
150
165
  expect(data['iso_short_name']).to eq 'Happy Country'
151
166
  expect(subject.iso_short_name).to eq 'Happy Country'
152
- expect(subject.subdivisions).to eq('LOL1' => ISO3166::Subdivision.new({name: 'Happy sub1', code: 'LOL1'}),
153
- 'LOL2' => ISO3166::Subdivision.new({name: 'Happy sub2', code: 'LOL2'}))
167
+ expect(subject.subdivisions.keys).to eq(%w[LOL1 LOL2])
168
+ expect(subject.subdivisions.values.map(&:name)).to eq(['Happy sub1', 'Happy sub2'])
154
169
  end
155
170
 
156
171
  it 'detect a stale cache' do
@@ -181,7 +196,61 @@ describe ISO3166::Data do
181
196
  end
182
197
 
183
198
  after do
184
- ISO3166::Data.unregister('lol')
199
+ ISO3166.reset
200
+ end
201
+ end
202
+
203
+ describe 'data checks' do
204
+ context 'subdivision YAML files' do
205
+ it 'has a non-blank code for all subdivisions' do
206
+ Dir['lib/countries/data/subdivisions/*.yaml'].each do |file|
207
+ data = YAML.load_file(file)
208
+ expect(data.values.none?{|s| s['code'].nil? }).to be_truthy, "empty subdivision code in #{file}"
209
+ end
210
+ end
211
+
212
+ it 'has a non-blank, lowercase and snake_case type for all subdivisions' do
213
+ Dir['lib/countries/data/subdivisions/*.yaml'].each do |file|
214
+ data = YAML.load_file(file)
215
+ no_type = data.select{|k,v| v['type'].nil? }
216
+ expect(no_type).to be_empty, "empty subdivision type in #{file} - #{no_type.keys}"
217
+ uppercase = data.select{|k,v| v['type'] =~ /[A-Z]/ }
218
+ expect(uppercase).to be_empty, "uppercase characters in subdivision type in #{file} - #{uppercase.keys}"
219
+ spaces = data.select{|k,v| v['type'] =~ /\s/ }
220
+ expect(spaces).to be_empty, "whitespace characters in subdivision type in #{file} - #{spaces.keys}"
221
+ end
222
+ end
223
+
224
+ it 'has a non-blank name for all subdivisions' do
225
+ Dir['lib/countries/data/subdivisions/*.yaml'].each do |file|
226
+ data = YAML.load_file(file)
227
+ expect(data.values.none?{|s| s['name'].nil? }).to be_truthy, "empty subdivision name in #{file}"
228
+ end
229
+ end
230
+ end
231
+
232
+ context 'cached country subdivision data' do
233
+ it 'has a non-blank code for all subdivisions' do
234
+ ISO3166::Country.all.each do |country|
235
+ expect(country.subdivisions.values.none?{|s| s['code'].nil? }).to be_truthy, "empty subdivision code in #{country}"
236
+ end
237
+ end
238
+
239
+ it 'has a non-blank name for all subdivisions' do
240
+ ISO3166::Country.all.each do |country|
241
+ expect(country.subdivisions.values.none?{|s| s['name'].nil? }).to be_truthy, "empty subdivision name in #{country}"
242
+ end
243
+ end
244
+ end
245
+
246
+ context 'names in Data' do
247
+ it 'should be unique (to allow .find_by_any_name work properly)' do
248
+ names = ISO3166::Data.cache.map do |_k, v|
249
+ [v['iso_short_name'], v['unofficial_names']].flatten.uniq
250
+ end.flatten
251
+
252
+ expect(names.size).to eq(names.uniq.size)
253
+ end
185
254
  end
186
255
  end
187
256
  end