countries 4.1.1 → 4.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (526) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +2 -0
  3. data/CHANGELOG.md +97 -5
  4. data/LICENSE +3 -1
  5. data/README.markdown +55 -50
  6. data/Rakefile +25 -31
  7. data/countries.gemspec +5 -5
  8. data/lib/countries/cache/countries.json +1 -1
  9. data/lib/countries/cache/locales/ab.json +1 -1
  10. data/lib/countries/cache/locales/af.json +1 -1
  11. data/lib/countries/cache/locales/ak.json +1 -1
  12. data/lib/countries/cache/locales/am.json +1 -1
  13. data/lib/countries/cache/locales/an.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/bg.json +1 -1
  19. data/lib/countries/cache/locales/bi.json +1 -1
  20. data/lib/countries/cache/locales/br.json +1 -1
  21. data/lib/countries/cache/locales/bs.json +1 -1
  22. data/lib/countries/cache/locales/ca.json +1 -1
  23. data/lib/countries/cache/locales/ce.json +1 -1
  24. data/lib/countries/cache/locales/ch.json +1 -1
  25. data/lib/countries/cache/locales/cv.json +1 -1
  26. data/lib/countries/cache/locales/de.json +1 -1
  27. data/lib/countries/cache/locales/dv.json +1 -1
  28. data/lib/countries/cache/locales/dz.json +1 -1
  29. data/lib/countries/cache/locales/ee.json +1 -1
  30. data/lib/countries/cache/locales/en.json +1 -1
  31. data/lib/countries/cache/locales/eo.json +1 -1
  32. data/lib/countries/cache/locales/es.json +1 -1
  33. data/lib/countries/cache/locales/et.json +1 -1
  34. data/lib/countries/cache/locales/ff.json +1 -1
  35. data/lib/countries/cache/locales/fi.json +1 -1
  36. data/lib/countries/cache/locales/fo.json +1 -1
  37. data/lib/countries/cache/locales/fr.json +1 -1
  38. data/lib/countries/cache/locales/fy.json +1 -1
  39. data/lib/countries/cache/locales/ga.json +1 -1
  40. data/lib/countries/cache/locales/gl.json +1 -1
  41. data/lib/countries/cache/locales/gn.json +1 -1
  42. data/lib/countries/cache/locales/gu.json +1 -1
  43. data/lib/countries/cache/locales/gv.json +1 -1
  44. data/lib/countries/cache/locales/ha.json +1 -1
  45. data/lib/countries/cache/locales/he.json +1 -1
  46. data/lib/countries/cache/locales/hi.json +1 -1
  47. data/lib/countries/cache/locales/hr.json +1 -1
  48. data/lib/countries/cache/locales/ht.json +1 -1
  49. data/lib/countries/cache/locales/hy.json +1 -1
  50. data/lib/countries/cache/locales/io.json +1 -1
  51. data/lib/countries/cache/locales/is.json +1 -1
  52. data/lib/countries/cache/locales/iu.json +1 -1
  53. data/lib/countries/cache/locales/ja.json +1 -1
  54. data/lib/countries/cache/locales/ka.json +1 -1
  55. data/lib/countries/cache/locales/ki.json +1 -1
  56. data/lib/countries/cache/locales/kk.json +1 -1
  57. data/lib/countries/cache/locales/kl.json +1 -1
  58. data/lib/countries/cache/locales/km.json +1 -1
  59. data/lib/countries/cache/locales/kn.json +1 -1
  60. data/lib/countries/cache/locales/kv.json +1 -1
  61. data/lib/countries/cache/locales/kw.json +1 -1
  62. data/lib/countries/cache/locales/ky.json +1 -1
  63. data/lib/countries/cache/locales/lo.json +1 -1
  64. data/lib/countries/cache/locales/lt.json +1 -1
  65. data/lib/countries/cache/locales/lv.json +1 -1
  66. data/lib/countries/cache/locales/mi.json +1 -1
  67. data/lib/countries/cache/locales/mk.json +1 -1
  68. data/lib/countries/cache/locales/ml.json +1 -1
  69. data/lib/countries/cache/locales/mn.json +1 -1
  70. data/lib/countries/cache/locales/ms.json +1 -1
  71. data/lib/countries/cache/locales/mt.json +1 -1
  72. data/lib/countries/cache/locales/my.json +1 -1
  73. data/lib/countries/cache/locales/na.json +1 -1
  74. data/lib/countries/cache/locales/nb.json +1 -1
  75. data/lib/countries/cache/locales/ne.json +1 -1
  76. data/lib/countries/cache/locales/nl.json +1 -1
  77. data/lib/countries/cache/locales/nn.json +1 -1
  78. data/lib/countries/cache/locales/nv.json +1 -1
  79. data/lib/countries/cache/locales/oc.json +1 -1
  80. data/lib/countries/cache/locales/pi.json +1 -1
  81. data/lib/countries/cache/locales/ps.json +1 -1
  82. data/lib/countries/cache/locales/pt-br.json +1 -1
  83. data/lib/countries/cache/locales/ro.json +1 -1
  84. data/lib/countries/cache/locales/ru.json +1 -1
  85. data/lib/countries/cache/locales/rw.json +1 -1
  86. data/lib/countries/cache/locales/sc.json +1 -1
  87. data/lib/countries/cache/locales/sd.json +1 -1
  88. data/lib/countries/cache/locales/si.json +1 -1
  89. data/lib/countries/cache/locales/sk.json +1 -1
  90. data/lib/countries/cache/locales/sl.json +1 -1
  91. data/lib/countries/cache/locales/so.json +1 -1
  92. data/lib/countries/cache/locales/sr.json +1 -1
  93. data/lib/countries/cache/locales/sv.json +1 -1
  94. data/lib/countries/cache/locales/sw.json +1 -1
  95. data/lib/countries/cache/locales/ta.json +1 -1
  96. data/lib/countries/cache/locales/te.json +1 -1
  97. data/lib/countries/cache/locales/th.json +1 -1
  98. data/lib/countries/cache/locales/ti.json +1 -1
  99. data/lib/countries/cache/locales/tk.json +1 -1
  100. data/lib/countries/cache/locales/tl.json +1 -1
  101. data/lib/countries/cache/locales/tr.json +1 -1
  102. data/lib/countries/cache/locales/tt.json +1 -1
  103. data/lib/countries/cache/locales/ur.json +1 -1
  104. data/lib/countries/cache/locales/uz.json +1 -1
  105. data/lib/countries/cache/locales/ve.json +1 -1
  106. data/lib/countries/cache/locales/vi.json +1 -1
  107. data/lib/countries/cache/locales/wa.json +1 -1
  108. data/lib/countries/cache/locales/wo.json +1 -1
  109. data/lib/countries/cache/locales/xh.json +1 -1
  110. data/lib/countries/cache/locales/yo.json +1 -1
  111. data/lib/countries/cache/locales/zh-cn.json +1 -1
  112. data/lib/countries/cache/locales/zh.json +1 -1
  113. data/lib/countries/cache/locales/zu.json +1 -1
  114. data/lib/countries/configuration.rb +13 -0
  115. data/lib/countries/country/class_methods.rb +19 -6
  116. data/lib/countries/country/currency_methods.rb +4 -1
  117. data/lib/countries/country/emoji.rb +3 -0
  118. data/lib/countries/country.rb +147 -7
  119. data/lib/countries/data/countries/AD.yaml +28 -29
  120. data/lib/countries/data/countries/AE.yaml +32 -33
  121. data/lib/countries/data/countries/AF.yaml +32 -33
  122. data/lib/countries/data/countries/AG.yaml +28 -29
  123. data/lib/countries/data/countries/AI.yaml +27 -28
  124. data/lib/countries/data/countries/AL.yaml +28 -29
  125. data/lib/countries/data/countries/AM.yaml +30 -31
  126. data/lib/countries/data/countries/AO.yaml +25 -26
  127. data/lib/countries/data/countries/AQ.yaml +24 -25
  128. data/lib/countries/data/countries/AR.yaml +30 -31
  129. data/lib/countries/data/countries/AS.yaml +31 -32
  130. data/lib/countries/data/countries/AT.yaml +36 -37
  131. data/lib/countries/data/countries/AU.yaml +33 -34
  132. data/lib/countries/data/countries/AW.yaml +25 -26
  133. data/lib/countries/data/countries/AX.yaml +27 -28
  134. data/lib/countries/data/countries/AZ.yaml +30 -31
  135. data/lib/countries/data/countries/BA.yaml +32 -33
  136. data/lib/countries/data/countries/BB.yaml +28 -29
  137. data/lib/countries/data/countries/BD.yaml +27 -28
  138. data/lib/countries/data/countries/BE.yaml +41 -42
  139. data/lib/countries/data/countries/BF.yaml +27 -28
  140. data/lib/countries/data/countries/BG.yaml +36 -37
  141. data/lib/countries/data/countries/BH.yaml +28 -29
  142. data/lib/countries/data/countries/BI.yaml +27 -28
  143. data/lib/countries/data/countries/BJ.yaml +26 -27
  144. data/lib/countries/data/countries/BL.yaml +25 -26
  145. data/lib/countries/data/countries/BM.yaml +29 -30
  146. data/lib/countries/data/countries/BN.yaml +26 -27
  147. data/lib/countries/data/countries/BO.yaml +31 -32
  148. data/lib/countries/data/countries/BQ.yaml +28 -29
  149. data/lib/countries/data/countries/BR.yaml +35 -36
  150. data/lib/countries/data/countries/BS.yaml +27 -28
  151. data/lib/countries/data/countries/BT.yaml +28 -29
  152. data/lib/countries/data/countries/BV.yaml +23 -24
  153. data/lib/countries/data/countries/BW.yaml +27 -28
  154. data/lib/countries/data/countries/BY.yaml +30 -31
  155. data/lib/countries/data/countries/BZ.yaml +28 -29
  156. data/lib/countries/data/countries/CA.yaml +30 -31
  157. data/lib/countries/data/countries/CC.yaml +28 -29
  158. data/lib/countries/data/countries/CD.yaml +35 -36
  159. data/lib/countries/data/countries/CF.yaml +29 -30
  160. data/lib/countries/data/countries/CG.yaml +29 -30
  161. data/lib/countries/data/countries/CH.yaml +40 -41
  162. data/lib/countries/data/countries/CI.yaml +27 -28
  163. data/lib/countries/data/countries/CK.yaml +27 -28
  164. data/lib/countries/data/countries/CL.yaml +32 -33
  165. data/lib/countries/data/countries/CM.yaml +29 -30
  166. data/lib/countries/data/countries/CN.yaml +28 -29
  167. data/lib/countries/data/countries/CO.yaml +28 -29
  168. data/lib/countries/data/countries/CR.yaml +26 -27
  169. data/lib/countries/data/countries/CU.yaml +27 -28
  170. data/lib/countries/data/countries/CV.yaml +28 -29
  171. data/lib/countries/data/countries/CW.yaml +25 -26
  172. data/lib/countries/data/countries/CX.yaml +30 -31
  173. data/lib/countries/data/countries/CY.yaml +40 -41
  174. data/lib/countries/data/countries/CZ.yaml +38 -39
  175. data/lib/countries/data/countries/DE.yaml +36 -37
  176. data/lib/countries/data/countries/DJ.yaml +29 -30
  177. data/lib/countries/data/countries/DK.yaml +35 -36
  178. data/lib/countries/data/countries/DM.yaml +26 -27
  179. data/lib/countries/data/countries/DO.yaml +28 -29
  180. data/lib/countries/data/countries/DZ.yaml +28 -29
  181. data/lib/countries/data/countries/EC.yaml +28 -29
  182. data/lib/countries/data/countries/EE.yaml +35 -36
  183. data/lib/countries/data/countries/EG.yaml +28 -29
  184. data/lib/countries/data/countries/EH.yaml +30 -31
  185. data/lib/countries/data/countries/ER.yaml +31 -32
  186. data/lib/countries/data/countries/ES.yaml +36 -37
  187. data/lib/countries/data/countries/ET.yaml +28 -29
  188. data/lib/countries/data/countries/FI.yaml +38 -39
  189. data/lib/countries/data/countries/FJ.yaml +33 -34
  190. data/lib/countries/data/countries/FK.yaml +29 -30
  191. data/lib/countries/data/countries/FM.yaml +28 -29
  192. data/lib/countries/data/countries/FO.yaml +28 -29
  193. data/lib/countries/data/countries/FR.yaml +37 -38
  194. data/lib/countries/data/countries/GA.yaml +27 -28
  195. data/lib/countries/data/countries/GB.yaml +39 -38
  196. data/lib/countries/data/countries/GD.yaml +26 -27
  197. data/lib/countries/data/countries/GE.yaml +28 -29
  198. data/lib/countries/data/countries/GF.yaml +29 -30
  199. data/lib/countries/data/countries/GG.yaml +30 -31
  200. data/lib/countries/data/countries/GH.yaml +27 -28
  201. data/lib/countries/data/countries/GI.yaml +26 -27
  202. data/lib/countries/data/countries/GL.yaml +29 -30
  203. data/lib/countries/data/countries/GM.yaml +25 -26
  204. data/lib/countries/data/countries/GN.yaml +30 -31
  205. data/lib/countries/data/countries/GP.yaml +27 -28
  206. data/lib/countries/data/countries/GQ.yaml +29 -30
  207. data/lib/countries/data/countries/GR.yaml +37 -38
  208. data/lib/countries/data/countries/GS.yaml +27 -28
  209. data/lib/countries/data/countries/GT.yaml +26 -27
  210. data/lib/countries/data/countries/GU.yaml +31 -32
  211. data/lib/countries/data/countries/GW.yaml +28 -29
  212. data/lib/countries/data/countries/GY.yaml +26 -27
  213. data/lib/countries/data/countries/HK.yaml +28 -29
  214. data/lib/countries/data/countries/HM.yaml +27 -28
  215. data/lib/countries/data/countries/HN.yaml +27 -28
  216. data/lib/countries/data/countries/HR.yaml +37 -38
  217. data/lib/countries/data/countries/HT.yaml +29 -30
  218. data/lib/countries/data/countries/HU.yaml +37 -38
  219. data/lib/countries/data/countries/ID.yaml +28 -29
  220. data/lib/countries/data/countries/IE.yaml +39 -40
  221. data/lib/countries/data/countries/IL.yaml +35 -31
  222. data/lib/countries/data/countries/IM.yaml +29 -30
  223. data/lib/countries/data/countries/IN.yaml +30 -31
  224. data/lib/countries/data/countries/IO.yaml +26 -27
  225. data/lib/countries/data/countries/IQ.yaml +28 -29
  226. data/lib/countries/data/countries/IR.yaml +28 -29
  227. data/lib/countries/data/countries/IS.yaml +35 -36
  228. data/lib/countries/data/countries/IT.yaml +36 -37
  229. data/lib/countries/data/countries/JE.yaml +26 -27
  230. data/lib/countries/data/countries/JM.yaml +28 -29
  231. data/lib/countries/data/countries/JO.yaml +28 -29
  232. data/lib/countries/data/countries/JP.yaml +28 -29
  233. data/lib/countries/data/countries/KE.yaml +29 -30
  234. data/lib/countries/data/countries/KG.yaml +30 -31
  235. data/lib/countries/data/countries/KH.yaml +28 -29
  236. data/lib/countries/data/countries/KI.yaml +25 -26
  237. data/lib/countries/data/countries/KM.yaml +29 -30
  238. data/lib/countries/data/countries/KN.yaml +29 -29
  239. data/lib/countries/data/countries/KP.yaml +27 -28
  240. data/lib/countries/data/countries/KR.yaml +28 -29
  241. data/lib/countries/data/countries/KW.yaml +28 -29
  242. data/lib/countries/data/countries/KY.yaml +29 -30
  243. data/lib/countries/data/countries/KZ.yaml +30 -31
  244. data/lib/countries/data/countries/LA.yaml +27 -28
  245. data/lib/countries/data/countries/LB.yaml +30 -31
  246. data/lib/countries/data/countries/LC.yaml +28 -29
  247. data/lib/countries/data/countries/LI.yaml +27 -28
  248. data/lib/countries/data/countries/LK.yaml +28 -29
  249. data/lib/countries/data/countries/LR.yaml +28 -29
  250. data/lib/countries/data/countries/LS.yaml +28 -29
  251. data/lib/countries/data/countries/LT.yaml +37 -38
  252. data/lib/countries/data/countries/LU.yaml +39 -40
  253. data/lib/countries/data/countries/LV.yaml +36 -37
  254. data/lib/countries/data/countries/LY.yaml +27 -28
  255. data/lib/countries/data/countries/MA.yaml +28 -29
  256. data/lib/countries/data/countries/MC.yaml +28 -29
  257. data/lib/countries/data/countries/MD.yaml +28 -29
  258. data/lib/countries/data/countries/ME.yaml +33 -34
  259. data/lib/countries/data/countries/MF.yaml +29 -30
  260. data/lib/countries/data/countries/MG.yaml +30 -31
  261. data/lib/countries/data/countries/MH.yaml +30 -31
  262. data/lib/countries/data/countries/MK.yaml +28 -29
  263. data/lib/countries/data/countries/ML.yaml +25 -26
  264. data/lib/countries/data/countries/MM.yaml +27 -28
  265. data/lib/countries/data/countries/MN.yaml +28 -29
  266. data/lib/countries/data/countries/MO.yaml +28 -29
  267. data/lib/countries/data/countries/MP.yaml +31 -32
  268. data/lib/countries/data/countries/MQ.yaml +27 -28
  269. data/lib/countries/data/countries/MR.yaml +29 -30
  270. data/lib/countries/data/countries/MS.yaml +26 -27
  271. data/lib/countries/data/countries/MT.yaml +36 -37
  272. data/lib/countries/data/countries/MU.yaml +28 -29
  273. data/lib/countries/data/countries/MV.yaml +28 -29
  274. data/lib/countries/data/countries/MW.yaml +27 -28
  275. data/lib/countries/data/countries/MX.yaml +33 -34
  276. data/lib/countries/data/countries/MY.yaml +30 -31
  277. data/lib/countries/data/countries/MZ.yaml +28 -29
  278. data/lib/countries/data/countries/NA.yaml +30 -31
  279. data/lib/countries/data/countries/NC.yaml +29 -30
  280. data/lib/countries/data/countries/NE.yaml +27 -28
  281. data/lib/countries/data/countries/NF.yaml +29 -30
  282. data/lib/countries/data/countries/NG.yaml +33 -34
  283. data/lib/countries/data/countries/NI.yaml +26 -27
  284. data/lib/countries/data/countries/NL.yaml +36 -37
  285. data/lib/countries/data/countries/NO.yaml +36 -37
  286. data/lib/countries/data/countries/NP.yaml +32 -33
  287. data/lib/countries/data/countries/NR.yaml +27 -28
  288. data/lib/countries/data/countries/NU.yaml +25 -26
  289. data/lib/countries/data/countries/NZ.yaml +34 -35
  290. data/lib/countries/data/countries/OM.yaml +28 -29
  291. data/lib/countries/data/countries/PA.yaml +26 -27
  292. data/lib/countries/data/countries/PE.yaml +28 -29
  293. data/lib/countries/data/countries/PF.yaml +29 -30
  294. data/lib/countries/data/countries/PG.yaml +28 -29
  295. data/lib/countries/data/countries/PH.yaml +35 -36
  296. data/lib/countries/data/countries/PK.yaml +30 -31
  297. data/lib/countries/data/countries/PL.yaml +36 -37
  298. data/lib/countries/data/countries/PM.yaml +29 -30
  299. data/lib/countries/data/countries/PN.yaml +27 -28
  300. data/lib/countries/data/countries/PR.yaml +28 -29
  301. data/lib/countries/data/countries/PS.yaml +31 -32
  302. data/lib/countries/data/countries/PT.yaml +33 -34
  303. data/lib/countries/data/countries/PW.yaml +26 -27
  304. data/lib/countries/data/countries/PY.yaml +28 -29
  305. data/lib/countries/data/countries/QA.yaml +27 -28
  306. data/lib/countries/data/countries/RE.yaml +28 -29
  307. data/lib/countries/data/countries/RO.yaml +37 -38
  308. data/lib/countries/data/countries/RS.yaml +28 -29
  309. data/lib/countries/data/countries/RU.yaml +28 -29
  310. data/lib/countries/data/countries/RW.yaml +31 -32
  311. data/lib/countries/data/countries/SA.yaml +33 -29
  312. data/lib/countries/data/countries/SB.yaml +27 -28
  313. data/lib/countries/data/countries/SC.yaml +28 -29
  314. data/lib/countries/data/countries/SD.yaml +30 -31
  315. data/lib/countries/data/countries/SE.yaml +37 -38
  316. data/lib/countries/data/countries/SG.yaml +32 -33
  317. data/lib/countries/data/countries/SH.yaml +29 -30
  318. data/lib/countries/data/countries/SI.yaml +36 -37
  319. data/lib/countries/data/countries/SJ.yaml +29 -30
  320. data/lib/countries/data/countries/SK.yaml +36 -37
  321. data/lib/countries/data/countries/SL.yaml +25 -26
  322. data/lib/countries/data/countries/SM.yaml +28 -29
  323. data/lib/countries/data/countries/SN.yaml +27 -28
  324. data/lib/countries/data/countries/SO.yaml +30 -31
  325. data/lib/countries/data/countries/SR.yaml +26 -27
  326. data/lib/countries/data/countries/SS.yaml +29 -30
  327. data/lib/countries/data/countries/ST.yaml +27 -28
  328. data/lib/countries/data/countries/SV.yaml +27 -28
  329. data/lib/countries/data/countries/SX.yaml +28 -29
  330. data/lib/countries/data/countries/SY.yaml +27 -28
  331. data/lib/countries/data/countries/SZ.yaml +30 -31
  332. data/lib/countries/data/countries/TC.yaml +30 -31
  333. data/lib/countries/data/countries/TD.yaml +29 -30
  334. data/lib/countries/data/countries/TF.yaml +28 -29
  335. data/lib/countries/data/countries/TG.yaml +25 -26
  336. data/lib/countries/data/countries/TH.yaml +34 -35
  337. data/lib/countries/data/countries/TJ.yaml +30 -31
  338. data/lib/countries/data/countries/TK.yaml +27 -28
  339. data/lib/countries/data/countries/TL.yaml +27 -28
  340. data/lib/countries/data/countries/TM.yaml +30 -31
  341. data/lib/countries/data/countries/TN.yaml +30 -31
  342. data/lib/countries/data/countries/TO.yaml +29 -30
  343. data/lib/countries/data/countries/TR.yaml +28 -29
  344. data/lib/countries/data/countries/TT.yaml +28 -29
  345. data/lib/countries/data/countries/TV.yaml +25 -26
  346. data/lib/countries/data/countries/TW.yaml +28 -29
  347. data/lib/countries/data/countries/TZ.yaml +30 -31
  348. data/lib/countries/data/countries/UA.yaml +34 -35
  349. data/lib/countries/data/countries/UG.yaml +28 -29
  350. data/lib/countries/data/countries/UM.yaml +29 -30
  351. data/lib/countries/data/countries/US.yaml +29 -29
  352. data/lib/countries/data/countries/UY.yaml +27 -28
  353. data/lib/countries/data/countries/UZ.yaml +30 -31
  354. data/lib/countries/data/countries/VA.yaml +31 -32
  355. data/lib/countries/data/countries/VC.yaml +29 -30
  356. data/lib/countries/data/countries/VE.yaml +26 -27
  357. data/lib/countries/data/countries/VG.yaml +29 -30
  358. data/lib/countries/data/countries/VI.yaml +28 -29
  359. data/lib/countries/data/countries/VN.yaml +28 -29
  360. data/lib/countries/data/countries/VU.yaml +31 -32
  361. data/lib/countries/data/countries/WF.yaml +29 -30
  362. data/lib/countries/data/countries/WS.yaml +28 -29
  363. data/lib/countries/data/countries/YE.yaml +27 -28
  364. data/lib/countries/data/countries/YT.yaml +26 -27
  365. data/lib/countries/data/countries/ZA.yaml +39 -40
  366. data/lib/countries/data/countries/ZM.yaml +28 -29
  367. data/lib/countries/data/countries/ZW.yaml +31 -32
  368. data/lib/countries/data/subdivisions/AD.yaml +21 -21
  369. data/lib/countries/data/subdivisions/AF.yaml +2 -2
  370. data/lib/countries/data/subdivisions/AG.yaml +1 -1
  371. data/lib/countries/data/subdivisions/AI.yaml +98 -98
  372. data/lib/countries/data/subdivisions/AL.yaml +82 -626
  373. data/lib/countries/data/subdivisions/AZ.yaml +5 -5
  374. data/lib/countries/data/subdivisions/BA.yaml +11 -11
  375. data/lib/countries/data/subdivisions/BD.yaml +8 -8
  376. data/lib/countries/data/subdivisions/BE.yaml +2 -2
  377. data/lib/countries/data/subdivisions/BF.yaml +13 -13
  378. data/lib/countries/data/subdivisions/BI.yaml +3 -3
  379. data/lib/countries/data/subdivisions/BM.yaml +77 -77
  380. data/lib/countries/data/subdivisions/BS.yaml +22 -22
  381. data/lib/countries/data/subdivisions/BW.yaml +7 -7
  382. data/lib/countries/data/subdivisions/BY.yaml +1 -1
  383. data/lib/countries/data/subdivisions/CD.yaml +19 -19
  384. data/lib/countries/data/subdivisions/CG.yaml +1 -1
  385. data/lib/countries/data/subdivisions/CI.yaml +14 -14
  386. data/lib/countries/data/subdivisions/CK.yaml +77 -77
  387. data/lib/countries/data/subdivisions/CN.yaml +0 -107
  388. data/lib/countries/data/subdivisions/CV.yaml +9 -9
  389. data/lib/countries/data/subdivisions/CZ.yaml +1045 -3736
  390. data/lib/countries/data/subdivisions/DE.yaml +16 -16
  391. data/lib/countries/data/subdivisions/DK.yaml +65 -286
  392. data/lib/countries/data/subdivisions/DO.yaml +11 -11
  393. data/lib/countries/data/subdivisions/EE.yaml +172 -88
  394. data/lib/countries/data/subdivisions/EH.yaml +12 -12
  395. data/lib/countries/data/subdivisions/ES.yaml +17 -17
  396. data/lib/countries/data/subdivisions/FI.yaml +101 -498
  397. data/lib/countries/data/subdivisions/FJ.yaml +14 -14
  398. data/lib/countries/data/subdivisions/FR.yaml +584 -977
  399. data/lib/countries/data/subdivisions/GB.yaml +21 -20
  400. data/lib/countries/data/subdivisions/GH.yaml +7 -7
  401. data/lib/countries/data/subdivisions/GL.yaml +6 -6
  402. data/lib/countries/data/subdivisions/GN.yaml +7 -7
  403. data/lib/countries/data/subdivisions/GQ.yaml +1 -0
  404. data/lib/countries/data/subdivisions/GR.yaml +117 -988
  405. data/lib/countries/data/subdivisions/GW.yaml +3 -3
  406. data/lib/countries/data/subdivisions/HT.yaml +1 -1
  407. data/lib/countries/data/subdivisions/HU.yaml +62 -62
  408. data/lib/countries/data/subdivisions/ID.yaml +41 -41
  409. data/lib/countries/data/subdivisions/IE.yaml +483 -483
  410. data/lib/countries/data/subdivisions/IN.yaml +4 -3
  411. data/lib/countries/data/subdivisions/IQ.yaml +1 -1
  412. data/lib/countries/data/subdivisions/IR.yaml +2 -1
  413. data/lib/countries/data/subdivisions/IS.yaml +72 -0
  414. data/lib/countries/data/subdivisions/IT.yaml +1250 -1839
  415. data/lib/countries/data/subdivisions/KE.yaml +391 -503
  416. data/lib/countries/data/subdivisions/KG.yaml +1 -1
  417. data/lib/countries/data/subdivisions/KH.yaml +1 -1
  418. data/lib/countries/data/subdivisions/KN.yaml +2 -2
  419. data/lib/countries/data/subdivisions/KP.yaml +12 -12
  420. data/lib/countries/data/subdivisions/KR.yaml +1 -1
  421. data/lib/countries/data/subdivisions/KZ.yaml +1 -1
  422. data/lib/countries/data/subdivisions/LA.yaml +1 -1
  423. data/lib/countries/data/subdivisions/LB.yaml +2 -2
  424. data/lib/countries/data/subdivisions/LC.yaml +10 -10
  425. data/lib/countries/data/subdivisions/LK.yaml +9 -9
  426. data/lib/countries/data/subdivisions/LR.yaml +2 -2
  427. data/lib/countries/data/subdivisions/LT.yaml +60 -60
  428. data/lib/countries/data/subdivisions/LU.yaml +194 -243
  429. data/lib/countries/data/subdivisions/LV.yaml +147 -5139
  430. data/lib/countries/data/subdivisions/MA.yaml +35 -35
  431. data/lib/countries/data/subdivisions/MC.yaml +17 -17
  432. data/lib/countries/data/subdivisions/MD.yaml +740 -740
  433. data/lib/countries/data/subdivisions/ME.yaml +3 -3
  434. data/lib/countries/data/subdivisions/MH.yaml +2 -2
  435. data/lib/countries/data/subdivisions/MK.yaml +3501 -5809
  436. data/lib/countries/data/subdivisions/ML.yaml +2 -2
  437. data/lib/countries/data/subdivisions/MM.yaml +1 -1
  438. data/lib/countries/data/subdivisions/MR.yaml +3 -3
  439. data/lib/countries/data/subdivisions/MV.yaml +8 -8
  440. data/lib/countries/data/subdivisions/MW.yaml +4 -4
  441. data/lib/countries/data/subdivisions/MX.yaml +1 -1
  442. data/lib/countries/data/subdivisions/NL.yaml +6 -6
  443. data/lib/countries/data/subdivisions/NO.yaml +1 -0
  444. data/lib/countries/data/subdivisions/NP.yaml +12 -12
  445. data/lib/countries/data/subdivisions/NZ.yaml +68 -112
  446. data/lib/countries/data/subdivisions/OM.yaml +6 -6
  447. data/lib/countries/data/subdivisions/PG.yaml +3 -3
  448. data/lib/countries/data/subdivisions/PH.yaml +16 -16
  449. data/lib/countries/data/subdivisions/PK.yaml +2 -2
  450. data/lib/countries/data/subdivisions/PL.yaml +210 -1208
  451. data/lib/countries/data/subdivisions/PS.yaml +16 -16
  452. data/lib/countries/data/subdivisions/QA.yaml +2 -2
  453. data/lib/countries/data/subdivisions/RS.yaml +2 -2
  454. data/lib/countries/data/subdivisions/SC.yaml +4 -2
  455. data/lib/countries/data/subdivisions/SG.yaml +39 -109
  456. data/lib/countries/data/subdivisions/SH.yaml +1 -1
  457. data/lib/countries/data/subdivisions/SI.yaml +19 -19
  458. data/lib/countries/data/subdivisions/SJ.yaml +14 -14
  459. data/lib/countries/data/subdivisions/SL.yaml +1 -1
  460. data/lib/countries/data/subdivisions/SN.yaml +3 -3
  461. data/lib/countries/data/subdivisions/SS.yaml +10 -10
  462. data/lib/countries/data/subdivisions/ST.yaml +6 -0
  463. data/lib/countries/data/subdivisions/TD.yaml +6 -6
  464. data/lib/countries/data/subdivisions/TH.yaml +1 -1
  465. data/lib/countries/data/subdivisions/TJ.yaml +2 -2
  466. data/lib/countries/data/subdivisions/TK.yaml +21 -21
  467. data/lib/countries/data/subdivisions/TM.yaml +1 -1
  468. data/lib/countries/data/subdivisions/TT.yaml +2 -2
  469. data/lib/countries/data/subdivisions/TV.yaml +1 -1
  470. data/lib/countries/data/subdivisions/TW.yaml +3 -17
  471. data/lib/countries/data/subdivisions/TZ.yaml +5 -5
  472. data/lib/countries/data/subdivisions/UG.yaml +59 -52
  473. data/lib/countries/data/subdivisions/UM.yaml +0 -10
  474. data/lib/countries/data/subdivisions/US.yaml +0 -42
  475. data/lib/countries/data/subdivisions/WF.yaml +3 -13
  476. data/lib/countries/data/subdivisions/YE.yaml +3 -3
  477. data/lib/countries/data/subdivisions/ZA.yaml +2 -2
  478. data/lib/countries/data/subdivisions/ZM.yaml +1 -1
  479. data/lib/countries/data/translation_corrections.yaml +20 -12
  480. data/lib/countries/data.rb +5 -1
  481. data/lib/countries/global.rb +13 -3
  482. data/lib/countries/mongoid.rb +3 -0
  483. data/lib/countries/sources/cldr/downloader.rb +3 -0
  484. data/lib/countries/sources/cldr/subdivision.rb +1 -0
  485. data/lib/countries/sources/cldr/subdivision_updater.rb +1 -0
  486. data/lib/countries/sources/local/cached_loader.rb +2 -0
  487. data/lib/countries/sources/local/subdivision.rb +1 -0
  488. data/lib/countries/structure.rb +2 -5
  489. data/lib/countries/tasks/geocoding.rake +1 -1
  490. data/lib/countries/timezones.rb +4 -2
  491. data/lib/countries/translations.rb +2 -3
  492. data/lib/countries/version.rb +1 -1
  493. data/spec/country_spec.rb +60 -56
  494. data/spec/data_spec.rb +9 -9
  495. metadata +7 -38
  496. data/lib/countries/data/subdivisions/AS.yaml +0 -85
  497. data/lib/countries/data/subdivisions/AW.yaml +0 -9
  498. data/lib/countries/data/subdivisions/AX.yaml +0 -51
  499. data/lib/countries/data/subdivisions/BL.yaml +0 -11
  500. data/lib/countries/data/subdivisions/CP.yaml +0 -4
  501. data/lib/countries/data/subdivisions/CW.yaml +0 -9
  502. data/lib/countries/data/subdivisions/FO.yaml +0 -85
  503. data/lib/countries/data/subdivisions/GF.yaml +0 -11
  504. data/lib/countries/data/subdivisions/GG.yaml +0 -155
  505. data/lib/countries/data/subdivisions/GP.yaml +0 -11
  506. data/lib/countries/data/subdivisions/GU.yaml +0 -275
  507. data/lib/countries/data/subdivisions/HK.yaml +0 -267
  508. data/lib/countries/data/subdivisions/IC.yaml +0 -4
  509. data/lib/countries/data/subdivisions/IM.yaml +0 -337
  510. data/lib/countries/data/subdivisions/JE.yaml +0 -169
  511. data/lib/countries/data/subdivisions/KY.yaml +0 -85
  512. data/lib/countries/data/subdivisions/MF.yaml +0 -9
  513. data/lib/countries/data/subdivisions/MO.yaml +0 -9
  514. data/lib/countries/data/subdivisions/MP.yaml +0 -71
  515. data/lib/countries/data/subdivisions/MQ.yaml +0 -11
  516. data/lib/countries/data/subdivisions/MS.yaml +0 -43
  517. data/lib/countries/data/subdivisions/NC.yaml +0 -57
  518. data/lib/countries/data/subdivisions/PF.yaml +0 -81
  519. data/lib/countries/data/subdivisions/PM.yaml +0 -39
  520. data/lib/countries/data/subdivisions/PR.yaml +0 -1107
  521. data/lib/countries/data/subdivisions/RE.yaml +0 -11
  522. data/lib/countries/data/subdivisions/SX.yaml +0 -9
  523. data/lib/countries/data/subdivisions/TA.yaml +0 -4
  524. data/lib/countries/data/subdivisions/TF.yaml +0 -67
  525. data/lib/countries/data/subdivisions/VI.yaml +0 -57
  526. data/lib/countries/data/subdivisions/YT.yaml +0 -247
@@ -1,7 +1,17 @@
1
1
  require 'countries'
2
2
 
3
+ # Some apps might not want to constantly call +ISO3166::Country+. This gem has a helper that can provide a Country class
4
+ #
5
+ # With global Country Helper enabled
6
+ #
7
+ # c = Country['US']
8
+ #
9
+ # This will conflict with any existing Country constant
10
+ #
11
+ # To Use
12
+ #
13
+ # gem 'countries', require: 'countries/global'
14
+ #
3
15
  class Country < ISO3166::Country
4
- def to_s
5
- name
6
- end
16
+
7
17
  end
@@ -5,6 +5,7 @@ module ISO3166
5
5
  end
6
6
 
7
7
  class << self
8
+ # Convert an +ISO3166::Country+ to the data that is stored by Mongoid.
8
9
  def mongoize(country)
9
10
  if country.is_a?(self) && !country.data.nil?
10
11
  country.alpha2
@@ -13,10 +14,12 @@ module ISO3166
13
14
  end
14
15
  end
15
16
 
17
+ # Get the object as it was stored with Mongoid, and instantiate an +ISO3166::Country+.
16
18
  def demongoize(alpha2)
17
19
  new(alpha2)
18
20
  end
19
21
 
22
+ # Convert an +ISO3166::Country+ to the data that is stored by Mongoid.
20
23
  def evolve(country)
21
24
  mongoize(country)
22
25
  end
@@ -4,8 +4,11 @@ require 'nokogiri'
4
4
  require 'fileutils'
5
5
  require 'json'
6
6
 
7
+ # Support code to allow updating subdivision data from the Unicode CLDR repository
7
8
  module Sources
9
+ # Support code to allow updating subdivision data from the Unicode CLDR repository
8
10
  module CLDR
11
+ # Downloads data from the Unicode CLDR repository
9
12
  module Downloader
10
13
  module_function
11
14
 
@@ -1,5 +1,6 @@
1
1
  module Sources
2
2
  module CLDR
3
+ # Auxiliary Subdivision class to support loading Unicode CLDR data to update local files
3
4
  class Subdivision
4
5
  attr_reader :xml, :language_code
5
6
  def initialize(language_code:, xml:)
@@ -5,6 +5,7 @@ require 'pry'
5
5
 
6
6
  module Sources
7
7
  module CLDR
8
+ # Updates local subdivision files with data from the Unicode CLDR repository
8
9
  class SubdivisionUpdater
9
10
  def call
10
11
  d = Dir['./tmp/cldr/trunk/common/subdivisions/*.xml']
@@ -1,5 +1,7 @@
1
1
  module Sources
2
+ # Support code to allow updating subdivision data from the Unicode CLDR repository
2
3
  module Local
4
+ # Loader for locally-cached data, to allow merging Unicode CLDR data with existing local data
3
5
  class CachedLoader
4
6
  attr_reader :klass
5
7
  def initialize(klass)
@@ -1,5 +1,6 @@
1
1
  module Sources
2
2
  module Local
3
+ # Auxiliary Subdivision class to support loading the local subdivision data to be updated with Unicode CLDR data
3
4
  class Subdivision
4
5
  attr_reader :code
5
6
  def initialize(code)
@@ -11,9 +11,7 @@ module ISO3166
11
11
  'gec' => nil,
12
12
  'geo' => {
13
13
  'latitude' => nil,
14
- 'latitude_dec' => nil,
15
14
  'longitude' => nil,
16
- 'longitude_dec' => nil,
17
15
  'max_latitude' => nil,
18
16
  'max_longitude' => nil,
19
17
  'min_latitude' => nil,
@@ -31,7 +29,8 @@ module ISO3166
31
29
  },
32
30
  'international_prefix' => nil,
33
31
  'ioc' => nil,
34
- 'name' => nil,
32
+ 'iso_long_name' => nil,
33
+ 'iso_short_name' => nil,
35
34
  'national_destination_code_lengths' => [],
36
35
  'national_number_lengths' => [],
37
36
  'national_prefix' => nil,
@@ -63,9 +62,7 @@ module ISO3166
63
62
  'translations' => {},
64
63
  'geo' => {
65
64
  'latitude' => nil,
66
- 'latitude_dec' => nil,
67
65
  'longitude' => nil,
68
- 'longitude_dec' => nil,
69
66
  'max_latitude' => nil,
70
67
  'max_longitude' => nil,
71
68
  'min_latitude' => nil,
@@ -43,7 +43,7 @@ namespace :geocode do
43
43
  # Load unmutated yaml file.
44
44
  data = load_country_yaml(country.alpha2)
45
45
 
46
- next unless (result = geocode(country.name, {region: country.alpha2}))
46
+ next unless (result = geocode(country.iso_short_name, {region: country.alpha2}))
47
47
  puts "WARNING:: Geocoder returned something that was not a country for #{country.alpha2}" unless result.types.include?('country')
48
48
  geometry = result.geometry
49
49
 
@@ -1,6 +1,8 @@
1
- # Extend Country class with support for timezones
2
1
  module ISO3166
3
- # Extend Country class with support for timezones
2
+ # Extend Country class with support for timezones. Requires the {tzinfo}[https://github.com/tzinfo/tzinfo] gem
3
+ #
4
+ # gem 'tzinfo'
5
+ #
4
6
  module TimezoneExtensions
5
7
  def timezones
6
8
  @tz_country ||= TZInfo::Country.get(alpha2)
@@ -1,9 +1,8 @@
1
1
  module ISO3166
2
2
  # Extend the hash class to allow locale lookup fall back behavior
3
3
  #
4
- # ex:
5
- # if a country has translations for pt, and the user looks up `pt-br` fallback
6
- # to `pt` to prevent from showing nil values
4
+ # E.g. if a country has translations for +pt+, and the user looks up +pt-br+ fallback
5
+ # to +pt+ to prevent from showing nil values
7
6
  class Translations < Hash
8
7
  def [](locale)
9
8
  super(locale) || super(locale.to_s.sub(/-.*/, ''))
@@ -1,3 +1,3 @@
1
1
  module Countries
2
- VERSION = '4.1.1'.freeze
2
+ VERSION = '4.2.3'.freeze
3
3
  end
data/spec/country_spec.rb CHANGED
@@ -43,12 +43,12 @@ describe ISO3166::Country do
43
43
  expect(country.alpha3).to eq('USA')
44
44
  end
45
45
 
46
- it 'should return 3166 name' do
47
- expect(country.name).to eq('United States of America')
46
+ it 'should return 3166 iso_short_name' do
47
+ expect(country.iso_short_name).to eq('United States of America')
48
48
  end
49
49
 
50
50
  it 'should return alternate names' do
51
- expect(country.names).to eq(['United States', 'Murica', 'Vereinigte Staaten von Amerika', 'États-Unis', 'Estados Unidos', 'アメリカ合衆国', 'Verenigde Staten'])
51
+ expect(country.unofficial_names).to eq(['United States', 'USA', 'Murica', 'Vereinigte Staaten von Amerika', 'États-Unis', 'Estados Unidos', 'アメリカ合衆国', 'Verenigde Staten'])
52
52
  end
53
53
 
54
54
  it 'should return translations' do
@@ -65,15 +65,7 @@ describe ISO3166::Country do
65
65
  end
66
66
 
67
67
  it 'should return bounds' do
68
- expect(country.bounds['northeast']['lat']).to eq(71.5388001)
69
- end
70
-
71
- it 'should return the decimal Latitude' do
72
- expect(country.latitude_dec).to eq('39.44325637817383')
73
- end
74
-
75
- it 'should return the decimal Longitude' do
76
- expect(country.longitude_dec).to eq('-98.95733642578125')
68
+ expect(country.bounds['northeast']['lat']).to eq(71.3577635769)
77
69
  end
78
70
 
79
71
  it 'should return continent' do
@@ -144,7 +136,7 @@ describe ISO3166::Country do
144
136
  before do
145
137
  ISO3166::Data.register(
146
138
  alpha2: 'BR2',
147
- name: 'Brazil',
139
+ iso_short_name: 'Brazil',
148
140
  languages_official: %w(pt-BR),
149
141
  translations: {
150
142
  'pt-BR' => 'Translation for pt-BR',
@@ -168,7 +160,7 @@ describe ISO3166::Country do
168
160
  before do
169
161
  ISO3166::Data.register(
170
162
  alpha2: 'BR2',
171
- name: 'Brazil',
163
+ iso_short_name: 'Brazil',
172
164
  languages_official: %w(pt-BR),
173
165
  translations: {
174
166
  'pt' => 'Translation for pt'
@@ -233,11 +225,11 @@ describe ISO3166::Country do
233
225
  end
234
226
 
235
227
  it 'should return a hash with all sub divisions' do
236
- expect(country.subdivisions.size).to eq(60)
228
+ expect(country.subdivisions.size).to eq(57)
237
229
  end
238
230
 
239
231
  it 'should be available through states' do
240
- expect(country.states.size).to eq(60)
232
+ expect(country.states.size).to eq(57)
241
233
  end
242
234
 
243
235
  it 'should be a subdivision object' do
@@ -323,7 +315,7 @@ describe ISO3166::Country do
323
315
  end
324
316
 
325
317
  it 'should allow to customize each country representation passing a block to the method' do
326
- countries = ISO3166::Country.all { |country, data| [data['name'], country, data['country_code']] }
318
+ countries = ISO3166::Country.all { |country, data| [data['iso_short_name'], country, data['country_code']] }
327
319
  expect(countries).to be_an(Array)
328
320
  expect(countries.first).to be_an(Array)
329
321
  expect(countries.first.size).to eq(3)
@@ -354,7 +346,7 @@ describe ISO3166::Country do
354
346
  before do
355
347
  ISO3166::Data.register(
356
348
  alpha2: 'XX',
357
- name: 'Custom Country',
349
+ iso_short_name: 'Custom Country',
358
350
  translations: { 'en' => 'Custom Country' }
359
351
  )
360
352
  end
@@ -362,7 +354,7 @@ describe ISO3166::Country do
362
354
  it 'should include custom registered countries' do
363
355
  custom_country = ISO3166::Country.find_by_alpha2('XX')[1]
364
356
  countries = ISO3166::Country.all_translated
365
- expect(countries).to include(custom_country['name'])
357
+ expect(countries).to include(custom_country['iso_short_name'])
366
358
  end
367
359
 
368
360
  after do
@@ -549,7 +541,7 @@ describe ISO3166::Country do
549
541
  end
550
542
 
551
543
  it 'also performs searches with regexps and forces it to ignore case' do
552
- spain_data = ISO3166::Country.find_all_by(:names, /Españ/)
544
+ spain_data = ISO3166::Country.find_all_by(:unofficial_names, /Españ/)
553
545
  expect(spain_data).to be_a Hash
554
546
  expect(spain_data.keys).to eq(['ES'])
555
547
  end
@@ -561,7 +553,7 @@ describe ISO3166::Country do
561
553
  case lookup.length
562
554
  when 2 then ISO3166::Country.find_all_by(:alpha2, lookup)
563
555
  when 3 then ISO3166::Country.find_all_by(:alpha3, lookup)
564
- else ISO3166::Country.find_all_by(:name, lookup)
556
+ else ISO3166::Country.find_all_by(:iso_short_name, lookup)
565
557
  end
566
558
  end
567
559
  expect(Time.now - start).to be < 1
@@ -569,22 +561,22 @@ describe ISO3166::Country do
569
561
  end
570
562
 
571
563
  describe 'hash finder methods' do
572
- context "when search name in 'name'" do
573
- subject { ISO3166::Country.find_by_name('Poland') }
564
+ context "when search name in 'iso_short_name'" do
565
+ subject { ISO3166::Country.find_by_iso_short_name('Poland') }
574
566
  it 'should return' do
575
567
  expect(subject.first).to eq('PL')
576
568
  end
577
569
  end
578
570
 
579
- context "when search lowercase name in 'name'" do
580
- subject { ISO3166::Country.find_by_name('poland') }
571
+ context "when search lowercase name in 'iso_short_name'" do
572
+ subject { ISO3166::Country.find_by_iso_short_name('poland') }
581
573
  it 'should return' do
582
574
  expect(subject.first).to eq('PL')
583
575
  end
584
576
  end
585
577
 
586
- context "when search name with comma in 'name'" do
587
- subject { ISO3166::Country.find_by_name(country_name) }
578
+ context "when search name with comma in 'iso_short_name'" do
579
+ subject { ISO3166::Country.find_by_iso_short_name(country_name) }
588
580
 
589
581
  context 'with Republic of Korea' do
590
582
  let(:country_name) { 'Korea, Republic of' }
@@ -609,7 +601,7 @@ describe ISO3166::Country do
609
601
  end
610
602
 
611
603
  context 'when search lowercase multibyte name found' do
612
- subject { ISO3166::Country.find_country_by_name('россия') }
604
+ subject { ISO3166::Country.find_country_by_unofficial_names('россия') }
613
605
 
614
606
  it 'should be a country instance' do
615
607
  expect(subject).to be_a(ISO3166::Country)
@@ -618,7 +610,7 @@ describe ISO3166::Country do
618
610
  end
619
611
 
620
612
  context 'when search lowercase multibyte name found' do
621
- subject { ISO3166::Country.find_country_by_name(/россия/) }
613
+ subject { ISO3166::Country.find_country_by_unofficial_names(/россия/) }
622
614
 
623
615
  it 'should be a country instance' do
624
616
  expect(subject).to be_a(ISO3166::Country)
@@ -627,7 +619,7 @@ describe ISO3166::Country do
627
619
  end
628
620
 
629
621
  context 'when accents are not used' do
630
- subject { ISO3166::Country.find_country_by_name('emirats Arabes Unis') }
622
+ subject { ISO3166::Country.find_country_by_unofficial_names('emirats Arabes Unis') }
631
623
 
632
624
  it 'should be a country instance' do
633
625
  expect(subject).to be_a(ISO3166::Country)
@@ -635,8 +627,20 @@ describe ISO3166::Country do
635
627
  end
636
628
  end
637
629
 
638
- context "when search name in 'names'" do
639
- subject { ISO3166::Country.find_by_name('Polonia') }
630
+ context "when search name in 'unofficial_names'" do
631
+ subject { ISO3166::Country.find_by_unofficial_names('Polonia') }
632
+ it 'should return' do
633
+ expect(subject.first).to eq('PL')
634
+ end
635
+ end
636
+
637
+ context "when search name in 'translated_names'" do
638
+ before do
639
+ ISO3166.configure do |config|
640
+ config.locales = [:bs]
641
+ end
642
+ end
643
+ subject { ISO3166::Country.find_by_translated_names('Poljska') }
640
644
  it 'should return' do
641
645
  expect(subject.first).to eq('PL')
642
646
  end
@@ -669,7 +673,7 @@ describe ISO3166::Country do
669
673
 
670
674
  describe 'country finder methods' do
671
675
  context 'when search name found' do
672
- let(:uk) { ISO3166::Country.find_country_by_name('United Kingdom') }
676
+ let(:uk) { ISO3166::Country.find_country_by_unofficial_names('United Kingdom') }
673
677
 
674
678
  it 'should be a country instance' do
675
679
  expect(uk).to be_a(ISO3166::Country)
@@ -678,7 +682,7 @@ describe ISO3166::Country do
678
682
  end
679
683
 
680
684
  context 'when search lowercase name found' do
681
- let(:uk) { ISO3166::Country.find_country_by_name('united kingdom') }
685
+ let(:uk) { ISO3166::Country.find_country_by_unofficial_names('united kingdom') }
682
686
 
683
687
  it 'should be a country instance' do
684
688
  expect(uk).to be_a(ISO3166::Country)
@@ -687,7 +691,7 @@ describe ISO3166::Country do
687
691
  end
688
692
 
689
693
  context 'when the search term contains comma' do
690
- let(:korea) { ISO3166::Country.find_country_by_name('Korea, Republic of') }
694
+ let(:korea) { ISO3166::Country.find_country_by_unofficial_names('Korea, Republic of') }
691
695
 
692
696
  it 'should be a country instance' do
693
697
  expect(korea).to be_a(ISO3166::Country)
@@ -726,7 +730,7 @@ describe ISO3166::Country do
726
730
  end
727
731
  end
728
732
  context 'when search name not found' do
729
- let(:bogus) { ISO3166::Country.find_country_by_name('Does not exist') }
733
+ let(:bogus) { ISO3166::Country.find_country_by_unofficial_names('Does not exist') }
730
734
 
731
735
  it 'should be a country instance' do
732
736
  expect(bogus).to eq(nil)
@@ -735,7 +739,7 @@ describe ISO3166::Country do
735
739
 
736
740
  # Spot checks #243
737
741
  context 'when search name not found' do
738
- let(:belgium) { ISO3166::Country.find_country_by_name('Belgium') }
742
+ let(:belgium) { ISO3166::Country.find_country_by_unofficial_names('Belgium') }
739
743
 
740
744
  it 'should be a country instance' do
741
745
  expect(belgium.alpha2).to eq('BE')
@@ -744,7 +748,7 @@ describe ISO3166::Country do
744
748
 
745
749
  # Spot checks #240
746
750
  context 'when search name not found' do
747
- let(:canada) { ISO3166::Country.find_country_by_name('Canada') }
751
+ let(:canada) { ISO3166::Country.find_country_by_unofficial_names('Canada') }
748
752
 
749
753
  it 'should be a country instance' do
750
754
  expect(canada.alpha2).to eq('CA')
@@ -753,7 +757,7 @@ describe ISO3166::Country do
753
757
 
754
758
  # Spot checks #241
755
759
  context 'when search name not found' do
756
- let(:israel) { ISO3166::Country.find_country_by_name('Israel') }
760
+ let(:israel) { ISO3166::Country.find_country_by_unofficial_names('Israel') }
757
761
 
758
762
  it 'should be a country instance' do
759
763
  expect(israel.alpha2).to eq('IL')
@@ -762,7 +766,7 @@ describe ISO3166::Country do
762
766
 
763
767
  # Spot checks #241
764
768
  context 'when search name not found' do
765
- let(:israel) { ISO3166::Country.find_by_name('Israel') }
769
+ let(:israel) { ISO3166::Country.find_by_iso_short_name('Israel') }
766
770
 
767
771
  it 'should be a country instance' do
768
772
  expect(israel[0]).to eq('IL')
@@ -771,7 +775,7 @@ describe ISO3166::Country do
771
775
 
772
776
  # Spot checks #241
773
777
  context 'when search name not found' do
774
- let(:israel) { ISO3166::Country.find_all_by(:name, 'Israel') }
778
+ let(:israel) { ISO3166::Country.find_all_by(:iso_short_name, 'Israel') }
775
779
 
776
780
  it 'should be a country instance' do
777
781
  expect(israel.size).to eq(1)
@@ -820,7 +824,7 @@ describe ISO3166::Country do
820
824
 
821
825
  describe 'hash finder methods' do
822
826
  context 'find by a valid Country attribute' do
823
- let(:method_name) { :find_by_name }
827
+ let(:method_name) { :find_by_iso_short_name }
824
828
  it { is_expected.to be true }
825
829
  end
826
830
 
@@ -846,7 +850,7 @@ describe ISO3166::Country do
846
850
  describe 'names in Data' do
847
851
  it 'should be unique (to allow .find_by_name work properly)' do
848
852
  names = ISO3166::Data.cache.map do |_k, v|
849
- [v['name'], v['unofficial_names']].flatten.uniq
853
+ [v['iso_short_name'], v['unofficial_names']].flatten.uniq
850
854
  end.flatten
851
855
 
852
856
  expect(names.size).to eq(names.uniq.size)
@@ -929,7 +933,7 @@ describe ISO3166::Country do
929
933
  end
930
934
 
931
935
  describe 'to_s' do
932
- it 'should return the country name' do
936
+ it 'should return the country iso_short_name' do
933
937
  expect(ISO3166::Country.new('GB').to_s).to eq('United Kingdom of Great Britain and Northern Ireland')
934
938
  end
935
939
  end
@@ -970,30 +974,30 @@ describe ISO3166::Country do
970
974
 
971
975
  describe 'Added country names to search by' do
972
976
  it 'should return country code for Democratic Republic of the Congo' do
973
- expect(ISO3166::Country.find_country_by_name('Democratic Republic of the Congo').alpha2).to eq 'CD'
977
+ expect(ISO3166::Country.find_country_by_unofficial_names('Democratic Republic of the Congo').alpha2).to eq 'CD'
974
978
  end
975
979
  it 'should return country code for Ivory Coast' do
976
- expect(ISO3166::Country.find_country_by_name('Ivory Coast').alpha2).to eq 'CI'
980
+ expect(ISO3166::Country.find_country_by_unofficial_names('Ivory Coast').alpha2).to eq 'CI'
977
981
  end
978
982
  it 'should return Pakistan code for Guinea Bissau' do
979
- expect(ISO3166::Country.find_country_by_name('Guinea Bissau').alpha2).to eq 'GW'
983
+ expect(ISO3166::Country.find_country_by_unofficial_names('Guinea Bissau').alpha2).to eq 'GW'
980
984
  end
981
985
  it 'should return Pakistan code for St Kitts and Nevis' do
982
- expect(ISO3166::Country.find_country_by_name('St Kitts and Nevis').alpha2).to eq 'KN'
986
+ expect(ISO3166::Country.find_country_by_unofficial_names('St Kitts and Nevis').alpha2).to eq 'KN'
983
987
  end
984
988
  it 'should return Pakistan code for St Lucia' do
985
- expect(ISO3166::Country.find_country_by_name('St Lucia').alpha2).to eq 'LC'
986
- expect(ISO3166::Country.find_country_by_name('St. Lucia').alpha2).to eq 'LC'
989
+ expect(ISO3166::Country.find_country_by_unofficial_names('St Lucia').alpha2).to eq 'LC'
990
+ expect(ISO3166::Country.find_country_by_unofficial_names('St. Lucia').alpha2).to eq 'LC'
987
991
  end
988
992
  it 'should return Pakistan code for Turks and Caicos' do
989
- expect(ISO3166::Country.find_country_by_name('Turks and Caicos').alpha2).to eq 'TC'
993
+ expect(ISO3166::Country.find_country_by_unofficial_names('Turks and Caicos').alpha2).to eq 'TC'
990
994
  end
991
995
  it 'should return Pakistan code for St Vincent Grenadines' do
992
- expect(ISO3166::Country.find_country_by_name('St Vincent Grenadines').alpha2).to eq 'VC'
993
- expect(ISO3166::Country.find_country_by_name('St. Vincent Grenadines').alpha2).to eq 'VC'
996
+ expect(ISO3166::Country.find_country_by_unofficial_names('St Vincent Grenadines').alpha2).to eq 'VC'
997
+ expect(ISO3166::Country.find_country_by_unofficial_names('St. Vincent Grenadines').alpha2).to eq 'VC'
994
998
  end
995
999
  it 'should return country code for Palestinian Authority' do
996
- expect(ISO3166::Country.find_country_by_name('Palestinian Authority').alpha2).to eq 'PS'
1000
+ expect(ISO3166::Country.find_country_by_unofficial_names('Palestinian Authority').alpha2).to eq 'PS'
997
1001
  end
998
1002
  end
999
1003
 
@@ -1022,8 +1026,8 @@ describe ISO3166::Country do
1022
1026
  expect(subject.last).to be_empty
1023
1027
  end
1024
1028
 
1025
- context "when asking for alpha2, alpha3 and name" do
1026
- let(:args) { [:alpha2, :alpha3, :name] }
1029
+ context "when asking for alpha2, alpha3 and iso_short_name" do
1030
+ let(:args) { [:alpha2, :alpha3, :iso_short_name] }
1027
1031
 
1028
1032
  it "returns the correct values" do
1029
1033
  expect(subject.first).to eq(["AD", "AND", "Andorra"])
data/spec/data_spec.rb CHANGED
@@ -95,7 +95,7 @@ describe ISO3166::Data do
95
95
  before do
96
96
  ISO3166::Data.register(
97
97
  alpha2: 'TW',
98
- name: 'NEW Taiwan',
98
+ iso_short_name: 'NEW Taiwan',
99
99
  subdivisions: {
100
100
  CHA: {name: 'New Changhua'},
101
101
  CYI: {name: 'New Municipality'}
@@ -112,8 +112,8 @@ describe ISO3166::Data do
112
112
  it 'can be done' do
113
113
  data = ISO3166::Data.new('TW').call
114
114
  ISO3166.configuration.locales = [:es, :de, :de]
115
- expect(data['name']).to eq 'NEW Taiwan'
116
- expect(subject.name).to eq 'NEW Taiwan'
115
+ expect(data['iso_short_name']).to eq 'NEW Taiwan'
116
+ expect(subject.iso_short_name).to eq 'NEW Taiwan'
117
117
  expect(subject.translations).to eq('en' => 'NEW Taiwan',
118
118
  'de' => 'NEW Taiwan')
119
119
  expect(subject.subdivisions).to eq('CHA' => ISO3166::Subdivision.new({name: 'New Changhua', code: 'CHA'}),
@@ -125,7 +125,7 @@ describe ISO3166::Data do
125
125
  before do
126
126
  ISO3166::Data.register(
127
127
  alpha2: 'LOL',
128
- name: 'Happy Country',
128
+ iso_short_name: 'Happy Country',
129
129
  subdivisions: {
130
130
  LOL1: {name: 'Happy sub1'},
131
131
  LOL2: {name: 'Happy sub2'}
@@ -141,17 +141,17 @@ describe ISO3166::Data do
141
141
 
142
142
  it 'can be done' do
143
143
  data = ISO3166::Data.new('LOL').call
144
- expect(data['name']).to eq 'Happy Country'
145
- expect(subject.name).to eq 'Happy Country'
144
+ expect(data['iso_short_name']).to eq 'Happy Country'
145
+ expect(subject.iso_short_name).to eq 'Happy Country'
146
146
  expect(subject.subdivisions).to eq('LOL1' => ISO3166::Subdivision.new({name: 'Happy sub1', code: 'LOL1'}),
147
147
  'LOL2' => ISO3166::Subdivision.new({name: 'Happy sub2', code: 'LOL2'}))
148
148
  end
149
149
 
150
150
  it 'detect a stale cache' do
151
- ISO3166::Data.register(alpha2: 'SAD', name: 'Sad Country')
151
+ ISO3166::Data.register(alpha2: 'SAD', iso_short_name: 'Sad Country')
152
152
  data = ISO3166::Data.new('SAD').call
153
- expect(data['name']).to eq 'Sad Country'
154
- expect(ISO3166::Country.new('SAD').name).to eq 'Sad Country'
153
+ expect(data['iso_short_name']).to eq 'Sad Country'
154
+ expect(ISO3166::Country.new('SAD').iso_short_name).to eq 'Sad Country'
155
155
  ISO3166::Data.unregister('SAD')
156
156
  end
157
157