countries 5.4.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +61 -0
  3. data/.github/workflows/tests.yml +4 -0
  4. data/.gitignore +0 -1
  5. data/.rubocop.yml +17 -8
  6. data/CHANGELOG.md +8 -0
  7. data/Gemfile +1 -2
  8. data/Gemfile.lock +84 -0
  9. data/README.md +41 -1
  10. data/Rakefile +2 -3
  11. data/countries.gemspec +1 -1
  12. data/lib/countries/cache/countries.json +1 -1
  13. data/lib/countries/country/class_methods.rb +22 -3
  14. data/lib/countries/country/country_subdivision_methods.rb +82 -0
  15. data/lib/countries/country/currency_methods.rb +0 -1
  16. data/lib/countries/country/finder_methods.rb +2 -4
  17. data/lib/countries/country.rb +13 -53
  18. data/lib/countries/data/countries/AR.yaml +1 -0
  19. data/lib/countries/data/countries/AU.yaml +1 -0
  20. data/lib/countries/data/countries/BR.yaml +1 -0
  21. data/lib/countries/data/countries/CA.yaml +2 -0
  22. data/lib/countries/data/countries/CN.yaml +1 -0
  23. data/lib/countries/data/countries/DE.yaml +2 -0
  24. data/lib/countries/data/countries/FR.yaml +2 -0
  25. data/lib/countries/data/countries/GB.yaml +2 -0
  26. data/lib/countries/data/countries/ID.yaml +1 -0
  27. data/lib/countries/data/countries/IN.yaml +1 -0
  28. data/lib/countries/data/countries/IT.yaml +2 -0
  29. data/lib/countries/data/countries/JP.yaml +2 -0
  30. data/lib/countries/data/countries/KR.yaml +1 -0
  31. data/lib/countries/data/countries/MX.yaml +1 -0
  32. data/lib/countries/data/countries/RU.yaml +1 -0
  33. data/lib/countries/data/countries/SA.yaml +1 -0
  34. data/lib/countries/data/countries/TR.yaml +1 -0
  35. data/lib/countries/data/countries/US.yaml +2 -0
  36. data/lib/countries/data/countries/ZA.yaml +1 -0
  37. data/lib/countries/data/locales_methods.rb +23 -0
  38. data/lib/countries/data/subdivision_methods.rb +30 -0
  39. data/lib/countries/data/subdivisions/AD.yaml +7 -0
  40. data/lib/countries/data/subdivisions/AE.yaml +18 -0
  41. data/lib/countries/data/subdivisions/AF.yaml +167 -2
  42. data/lib/countries/data/subdivisions/AG.yaml +9 -0
  43. data/lib/countries/data/subdivisions/AL.yaml +57 -0
  44. data/lib/countries/data/subdivisions/AM.yaml +34 -0
  45. data/lib/countries/data/subdivisions/AO.yaml +36 -0
  46. data/lib/countries/data/subdivisions/AR.yaml +46 -0
  47. data/lib/countries/data/subdivisions/AT.yaml +28 -0
  48. data/lib/countries/data/subdivisions/AU.yaml +29 -0
  49. data/lib/countries/data/subdivisions/AZ.yaml +239 -0
  50. data/lib/countries/data/subdivisions/BA.yaml +5 -0
  51. data/lib/countries/data/subdivisions/BB.yaml +4 -0
  52. data/lib/countries/data/subdivisions/BD.yaml +139 -0
  53. data/lib/countries/data/subdivisions/BE.yaml +34 -0
  54. data/lib/countries/data/subdivisions/BF.yaml +56 -0
  55. data/lib/countries/data/subdivisions/BG.yaml +30 -0
  56. data/lib/countries/data/subdivisions/BH.yaml +13 -0
  57. data/lib/countries/data/subdivisions/BI.yaml +54 -0
  58. data/lib/countries/data/subdivisions/BJ.yaml +22 -0
  59. data/lib/countries/data/subdivisions/BN.yaml +9 -0
  60. data/lib/countries/data/subdivisions/BO.yaml +35 -0
  61. data/lib/countries/data/subdivisions/BQ.yaml +4 -0
  62. data/lib/countries/data/subdivisions/BR.yaml +14 -0
  63. data/lib/countries/data/subdivisions/BS.yaml +24 -0
  64. data/lib/countries/data/subdivisions/BT.yaml +24 -0
  65. data/lib/countries/data/subdivisions/BW.yaml +24 -0
  66. data/lib/countries/data/subdivisions/BY.yaml +5 -0
  67. data/lib/countries/data/subdivisions/BZ.yaml +3 -0
  68. data/lib/countries/data/subdivisions/CA.yaml +24 -0
  69. data/lib/countries/data/subdivisions/CD.yaml +77 -0
  70. data/lib/countries/data/subdivisions/CF.yaml +15 -0
  71. data/lib/countries/data/subdivisions/CG.yaml +18 -0
  72. data/lib/countries/data/subdivisions/CH.yaml +92 -0
  73. data/lib/countries/data/subdivisions/CI.yaml +65 -0
  74. data/lib/countries/data/subdivisions/CL.yaml +45 -2
  75. data/lib/countries/data/subdivisions/CM.yaml +22 -0
  76. data/lib/countries/data/subdivisions/CN.yaml +98 -0
  77. data/lib/countries/data/subdivisions/CO.yaml +68 -0
  78. data/lib/countries/data/subdivisions/CR.yaml +14 -0
  79. data/lib/countries/data/subdivisions/CU.yaml +42 -0
  80. data/lib/countries/data/subdivisions/CV.yaml +32 -0
  81. data/lib/countries/data/subdivisions/CY.yaml +18 -0
  82. data/lib/countries/data/subdivisions/CZ.yaml +227 -0
  83. data/lib/countries/data/subdivisions/DE.yaml +31 -0
  84. data/lib/countries/data/subdivisions/DJ.yaml +16 -0
  85. data/lib/countries/data/subdivisions/DK.yaml +13 -0
  86. data/lib/countries/data/subdivisions/DM.yaml +1 -0
  87. data/lib/countries/data/subdivisions/DO.yaml +102 -0
  88. data/lib/countries/data/subdivisions/DZ.yaml +104 -0
  89. data/lib/countries/data/subdivisions/EC.yaml +72 -0
  90. data/lib/countries/data/subdivisions/EE.yaml +6 -0
  91. data/lib/countries/data/subdivisions/EG.yaml +54 -0
  92. data/lib/countries/data/subdivisions/ER.yaml +2 -0
  93. data/lib/countries/data/subdivisions/ES.yaml +252 -0
  94. data/lib/countries/data/subdivisions/ET.yaml +27 -0
  95. data/lib/countries/data/subdivisions/FI.yaml +78 -0
  96. data/lib/countries/data/subdivisions/FJ.yaml +30 -0
  97. data/lib/countries/data/subdivisions/FM.yaml +11 -0
  98. data/lib/countries/data/subdivisions/FR.yaml +332 -1
  99. data/lib/countries/data/subdivisions/GA.yaml +24 -0
  100. data/lib/countries/data/subdivisions/GB.yaml +488 -0
  101. data/lib/countries/data/subdivisions/GD.yaml +10 -0
  102. data/lib/countries/data/subdivisions/GE.yaml +34 -0
  103. data/lib/countries/data/subdivisions/GH.yaml +79 -0
  104. data/lib/countries/data/subdivisions/GL.yaml +58 -0
  105. data/lib/countries/data/subdivisions/GM.yaml +10 -0
  106. data/lib/countries/data/subdivisions/GN.yaml +65 -0
  107. data/lib/countries/data/subdivisions/GQ.yaml +36 -0
  108. data/lib/countries/data/subdivisions/GR.yaml +41 -0
  109. data/lib/countries/data/subdivisions/GW.yaml +24 -0
  110. data/lib/countries/data/subdivisions/GY.yaml +31 -0
  111. data/lib/countries/data/subdivisions/HN.yaml +21 -0
  112. data/lib/countries/data/subdivisions/HR.yaml +82 -0
  113. data/lib/countries/data/subdivisions/HT.yaml +14 -0
  114. data/lib/countries/data/subdivisions/HU.yaml +94 -0
  115. data/lib/countries/data/subdivisions/ID.yaml +99 -0
  116. data/lib/countries/data/subdivisions/IE.yaml +39 -0
  117. data/lib/countries/data/subdivisions/IL.yaml +15 -0
  118. data/lib/countries/data/subdivisions/IN.yaml +210 -0
  119. data/lib/countries/data/subdivisions/IQ.yaml +59 -0
  120. data/lib/countries/data/subdivisions/IR.yaml +2 -0
  121. data/lib/countries/data/subdivisions/IS.yaml +560 -0
  122. data/lib/countries/data/subdivisions/IT.yaml +321 -0
  123. data/lib/countries/data/subdivisions/JM.yaml +22 -0
  124. data/lib/countries/data/subdivisions/JO.yaml +16 -0
  125. data/lib/countries/data/subdivisions/JP.yaml +42 -0
  126. data/lib/countries/data/subdivisions/KE.yaml +298 -0
  127. data/lib/countries/data/subdivisions/KG.yaml +28 -0
  128. data/lib/countries/data/subdivisions/KH.yaml +108 -0
  129. data/lib/countries/data/subdivisions/KI.yaml +6 -0
  130. data/lib/countries/data/subdivisions/KM.yaml +4 -0
  131. data/lib/countries/data/subdivisions/KN.yaml +6 -0
  132. data/lib/countries/data/subdivisions/KP.yaml +42 -0
  133. data/lib/countries/data/subdivisions/KR.yaml +36 -0
  134. data/lib/countries/data/subdivisions/KW.yaml +5 -0
  135. data/lib/countries/data/subdivisions/KZ.yaml +113 -0
  136. data/lib/countries/data/subdivisions/LA.yaml +49 -0
  137. data/lib/countries/data/subdivisions/LB.yaml +28 -0
  138. data/lib/countries/data/subdivisions/LC.yaml +6 -0
  139. data/lib/countries/data/subdivisions/LI.yaml +37 -0
  140. data/lib/countries/data/subdivisions/LK.yaml +67 -0
  141. data/lib/countries/data/subdivisions/LR.yaml +16 -0
  142. data/lib/countries/data/subdivisions/LS.yaml +23 -0
  143. data/lib/countries/data/subdivisions/LT.yaml +315 -0
  144. data/lib/countries/data/subdivisions/LU.yaml +31 -0
  145. data/lib/countries/data/subdivisions/LV.yaml +83 -0
  146. data/lib/countries/data/subdivisions/LY.yaml +16 -0
  147. data/lib/countries/data/subdivisions/MA.yaml +827 -12
  148. data/lib/countries/data/subdivisions/MC.yaml +47 -0
  149. data/lib/countries/data/subdivisions/MD.yaml +41 -0
  150. data/lib/countries/data/subdivisions/ME.yaml +83 -0
  151. data/lib/countries/data/subdivisions/MG.yaml +21 -0
  152. data/lib/countries/data/subdivisions/MH.yaml +70 -0
  153. data/lib/countries/data/subdivisions/MK.yaml +505 -0
  154. data/lib/countries/data/subdivisions/ML.yaml +33 -0
  155. data/lib/countries/data/subdivisions/MM.yaml +51 -0
  156. data/lib/countries/data/subdivisions/MN.yaml +94 -0
  157. data/lib/countries/data/subdivisions/MR.yaml +32 -0
  158. data/lib/countries/data/subdivisions/MT.yaml +126 -0
  159. data/lib/countries/data/subdivisions/MU.yaml +21 -0
  160. data/lib/countries/data/subdivisions/MV.yaml +20 -0
  161. data/lib/countries/data/subdivisions/MW.yaml +52 -0
  162. data/lib/countries/data/subdivisions/MX.yaml +23 -0
  163. data/lib/countries/data/subdivisions/MY.yaml +24 -0
  164. data/lib/countries/data/subdivisions/MZ.yaml +20 -0
  165. data/lib/countries/data/subdivisions/NA.yaml +28 -0
  166. data/lib/countries/data/subdivisions/NE.yaml +9 -0
  167. data/lib/countries/data/subdivisions/NG.yaml +89 -0
  168. data/lib/countries/data/subdivisions/NI.yaml +25 -0
  169. data/lib/countries/data/subdivisions/NL.yaml +24 -0
  170. data/lib/countries/data/subdivisions/NO.yaml +138 -1
  171. data/lib/countries/data/subdivisions/NP.yaml +9 -0
  172. data/lib/countries/data/subdivisions/NR.yaml +19 -0
  173. data/lib/countries/data/subdivisions/NZ.yaml +34 -0
  174. data/lib/countries/data/subdivisions/OM.yaml +10 -0
  175. data/lib/countries/data/subdivisions/PA.yaml +27 -0
  176. data/lib/countries/data/subdivisions/PE.yaml +24 -0
  177. data/lib/countries/data/subdivisions/PG.yaml +46 -0
  178. data/lib/countries/data/subdivisions/PH.yaml +293 -0
  179. data/lib/countries/data/subdivisions/PK.yaml +22 -0
  180. data/lib/countries/data/subdivisions/PL.yaml +141 -0
  181. data/lib/countries/data/subdivisions/PS.yaml +41 -0
  182. data/lib/countries/data/subdivisions/PT.yaml +36 -0
  183. data/lib/countries/data/subdivisions/PW.yaml +24 -0
  184. data/lib/countries/data/subdivisions/PY.yaml +21 -0
  185. data/lib/countries/data/subdivisions/QA.yaml +26 -0
  186. data/lib/countries/data/subdivisions/RO.yaml +189 -0
  187. data/lib/countries/data/subdivisions/RS.yaml +112 -0
  188. data/lib/countries/data/subdivisions/RU.yaml +123 -0
  189. data/lib/countries/data/subdivisions/RW.yaml +7 -0
  190. data/lib/countries/data/subdivisions/SA.yaml +38 -0
  191. data/lib/countries/data/subdivisions/SB.yaml +11 -0
  192. data/lib/countries/data/subdivisions/SC.yaml +45 -0
  193. data/lib/countries/data/subdivisions/SD.yaml +15 -0
  194. data/lib/countries/data/subdivisions/SE.yaml +42 -0
  195. data/lib/countries/data/subdivisions/SG.yaml +8 -0
  196. data/lib/countries/data/subdivisions/SH.yaml +6 -0
  197. data/lib/countries/data/subdivisions/SI.yaml +735 -0
  198. data/lib/countries/data/subdivisions/SK.yaml +22 -0
  199. data/lib/countries/data/subdivisions/SL.yaml +7 -0
  200. data/lib/countries/data/subdivisions/SM.yaml +19 -0
  201. data/lib/countries/data/subdivisions/SN.yaml +43 -0
  202. data/lib/countries/data/subdivisions/SO.yaml +71 -0
  203. data/lib/countries/data/subdivisions/SR.yaml +17 -0
  204. data/lib/countries/data/subdivisions/SS.yaml +4 -0
  205. data/lib/countries/data/subdivisions/ST.yaml +127 -0
  206. data/lib/countries/data/subdivisions/SV.yaml +20 -0
  207. data/lib/countries/data/subdivisions/SY.yaml +53 -0
  208. data/lib/countries/data/subdivisions/SZ.yaml +18 -0
  209. data/lib/countries/data/subdivisions/TD.yaml +51 -0
  210. data/lib/countries/data/subdivisions/TG.yaml +13 -0
  211. data/lib/countries/data/subdivisions/TH.yaml +231 -0
  212. data/lib/countries/data/subdivisions/TJ.yaml +15 -0
  213. data/lib/countries/data/subdivisions/TL.yaml +38 -0
  214. data/lib/countries/data/subdivisions/TM.yaml +15 -0
  215. data/lib/countries/data/subdivisions/TN.yaml +25 -0
  216. data/lib/countries/data/subdivisions/TO.yaml +1 -0
  217. data/lib/countries/data/subdivisions/TR.yaml +93 -0
  218. data/lib/countries/data/subdivisions/TT.yaml +25 -0
  219. data/lib/countries/data/subdivisions/TV.yaml +25 -0
  220. data/lib/countries/data/subdivisions/TW.yaml +106 -0
  221. data/lib/countries/data/subdivisions/TZ.yaml +38 -0
  222. data/lib/countries/data/subdivisions/UA.yaml +86 -4
  223. data/lib/countries/data/subdivisions/UG.yaml +262 -0
  224. data/lib/countries/data/subdivisions/UM.yaml +4 -0
  225. data/lib/countries/data/subdivisions/US.yaml +118 -0
  226. data/lib/countries/data/subdivisions/UY.yaml +27 -0
  227. data/lib/countries/data/subdivisions/UZ.yaml +65 -0
  228. data/lib/countries/data/subdivisions/VC.yaml +6 -0
  229. data/lib/countries/data/subdivisions/VE.yaml +33 -0
  230. data/lib/countries/data/subdivisions/VN.yaml +131 -0
  231. data/lib/countries/data/subdivisions/VU.yaml +8 -0
  232. data/lib/countries/data/subdivisions/WS.yaml +18 -0
  233. data/lib/countries/data/subdivisions/YE.yaml +16 -0
  234. data/lib/countries/data/subdivisions/ZA.yaml +5 -0
  235. data/lib/countries/data/subdivisions/ZM.yaml +24 -0
  236. data/lib/countries/data/subdivisions/ZW.yaml +21 -0
  237. data/lib/countries/data.rb +19 -50
  238. data/lib/countries/global.rb +0 -1
  239. data/lib/countries/iso3166.rb +3 -0
  240. data/lib/countries/sources/cldr/subdivision.rb +1 -1
  241. data/lib/countries/subdivision.rb +5 -0
  242. data/lib/countries/tasks/postal_codes.rake +5 -1
  243. data/lib/countries/version.rb +1 -1
  244. data/spec/country_spec.rb +118 -22
  245. data/spec/data_spec.rb +12 -8
  246. data/spec/spec_helper.rb +4 -0
  247. data/spec/subdivision_spec.rb +8 -0
  248. metadata +23 -16
  249. data/.rubocop_todo.yml +0 -19
  250. data/lib/countries/tasks/geocoding.rake +0 -106
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2dbd1d2fabc23bc8ff8ae89a3d41c8a2a429a5e19d6b1c5adcaf0fe895030b14
4
- data.tar.gz: 8f86afddfb52099dba4cacbe45d712b139f02fc3af0ecb24735ee650fe39a714
3
+ metadata.gz: 558e68f4f533ad329ed3b08cfb026aef3d765e24bc997ec083b7cd37bb42c006
4
+ data.tar.gz: 112422bf94a5c6a3d1a3eaf94e6e0f533636568302621f6537fce95d5a779aa1
5
5
  SHA512:
6
- metadata.gz: c6e391cbcd4467e15f9be499266cbdedccd2ed4b937c8a7543a0ad11c586897b91328380857f97b965df07866c9dd061921ac4e39c4ffa9229db00907a426b1b
7
- data.tar.gz: e7e5b9394328c190aed09e3d95be5ac47fe78b20920aefc9a9e17378fbd034e89e21234af9761118cd83c1e402eb802d990d6d12433003789d26b22c5919483b
6
+ metadata.gz: 8c5d0866ebe1b9eeff6b1c363bb89dac7a652eebe88d582743d21b50ee6f91de4f6364b938fe2f8c04e700331e9d2bdefca0b726e1c9f4810bf141c0d38a0645
7
+ data.tar.gz: bb2e954f511906dbe97e122aa23613e30fe6e12c0d9bc36a7649dd63f035dd51bd17a97bf1329a5b1f8e6f44cca8ca9bc31b0e70f08cc47ac5752cf31238b4e2
data/.codeclimate.yml ADDED
@@ -0,0 +1,61 @@
1
+ version: "2"
2
+ checks:
3
+ argument-count:
4
+ enabled: true
5
+ config:
6
+ threshold: 4
7
+ complex-logic:
8
+ enabled: true
9
+ config:
10
+ threshold: 4
11
+ file-lines:
12
+ enabled: true
13
+ config:
14
+ threshold: 250
15
+ method-complexity:
16
+ enabled: true
17
+ config:
18
+ threshold: 5
19
+ method-count:
20
+ enabled: true
21
+ config:
22
+ threshold: 20
23
+ method-lines:
24
+ enabled: true
25
+ config:
26
+ threshold: 25
27
+ nested-control-flow:
28
+ enabled: true
29
+ config:
30
+ threshold: 4
31
+ return-statements:
32
+ enabled: true
33
+ config:
34
+ threshold: 4
35
+ plugins:
36
+ rubocop:
37
+ enabled: true
38
+ channel: rubocop-1-48-1
39
+ reek:
40
+ enabled: true
41
+ checks:
42
+ IrresponsibleModule:
43
+ enabled: false
44
+ TooManyStatements:
45
+ max_statements: 7
46
+ flog:
47
+ enabled: true
48
+ bundler-audit:
49
+ enabled: true
50
+ exclude_patterns:
51
+ - "config/"
52
+ - "db/"
53
+ - "dist/"
54
+ - "features/"
55
+ - "**/node_modules/"
56
+ - "script/"
57
+ - "**/spec/"
58
+ - "**/test/"
59
+ - "**/tests/"
60
+ - "**/vendor/"
61
+ - "**/*.d.ts"
@@ -17,6 +17,8 @@ jobs:
17
17
  fail-fast: false
18
18
  matrix:
19
19
  ruby: [2.7, '3.0', 3.1, 3.2]
20
+ env:
21
+ CC_TEST_REPORTER_ID: 1670b97bb8c09d4f4bad81e559f41c7588641c67bd700c933c267bbe7dbbef7f
20
22
  steps:
21
23
  - uses: actions/checkout@v3
22
24
  - name: Set up Ruby ${{ matrix.ruby-version }}
@@ -26,3 +28,5 @@ jobs:
26
28
  bundler-cache: true
27
29
  - name: Run tests
28
30
  run: bundle exec rake
31
+ - name: Publish code coverage
32
+ uses: paambaati/codeclimate-action@v4.0.0
data/.gitignore CHANGED
@@ -5,7 +5,6 @@
5
5
  .bundle
6
6
  .config
7
7
  .yardoc
8
- Gemfile.lock
9
8
  InstalledFiles
10
9
  _yardoc
11
10
  coverage
data/.rubocop.yml CHANGED
@@ -1,22 +1,30 @@
1
- inherit_from: .rubocop_todo.yml
2
1
 
3
2
  AllCops:
4
3
  NewCops: enable
4
+ TargetRubyVersion: 2.7
5
5
 
6
6
  Layout/LineLength:
7
+ Max: 120
8
+ AllowedPatterns: ['^ *# ']
7
9
  Exclude:
8
10
  - countries.gemspec
11
+ - 'spec/**/*'
12
+
13
+ Metrics/MethodLength:
14
+ Enabled: false
15
+
16
+ Style/Documentation:
17
+ Enabled: false
18
+
19
+ Bundler/OrderedGems:
20
+ Enabled: false
9
21
 
10
22
  Metrics/BlockLength:
11
23
  Exclude:
12
24
  - 'spec/**/*'
13
25
  - Rakefile
14
- - 'spec/**/*'
15
26
  - 'lib/countries/tasks/*'
16
27
 
17
- Style/RescueModifier:
18
- Enabled: false
19
-
20
28
  Style/CaseEquality:
21
29
  Exclude:
22
30
  - 'lib/countries/country/finder_methods.rb'
@@ -33,8 +41,9 @@ Lint/AmbiguousBlockAssociation:
33
41
  Exclude:
34
42
  - 'spec/perf_spec.rb'
35
43
 
36
- Metrics/MethodLength:
37
- Max: 20
38
-
39
44
  Metrics/ClassLength:
40
45
  Max: 130
46
+
47
+ Metrics/AbcSize:
48
+ Exclude:
49
+ - 'lib/countries/sources/cldr/*'
data/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [5.5.0](https://github.com/countries/countries/releases/tag/v5.5.0') (2023/06/17 16:20 +00:00)
7
+
8
+ * Added G20 and G7 member fields [\#799](https://github.com/countries/countries/pull/799) ([AndromedaSugar](https://github.com/AndromedaSugar))
9
+ * Update subdivision translations from CLDR [\#802](https://github.com/countries/countries/pull/802) ([pmor](https://github.com/pmor))
10
+ * Adds Country#collect_countries_with, Country#collect_likely_subdivisions, Country.find_subdivision_with, Country.find_subdivision_code_with_translations [\#800](https://github.com/countries/countries/pull/800) ([pmor](https://github.com/pmor))
11
+ * Add Japanese translation to subdivisions data [\#804](https://github.com/countries/countries/pull/804) ([shucream-p](https://github.com/shucream-p))
12
+ * Adding gdpr_compliant method to check if a country is regulated by GDPR [\#807](https://github.com/countries/countries/pull/807) ([yeseniamolinab](https://github.com/yeseniamolinab))
13
+
6
14
  ## [5.4.0](https://github.com/countries/countries/releases/tag/v5.4.0') (2023/04/12 12:44 +00:00)
7
15
 
8
16
  * fix: RUP are part of the European Union [\#794](https://github.com/countries/countries/pull/794) ([btrd](https://github.com/btrd))
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
- gem 'geocoder'
5
4
  gem 'money'
6
5
  gem 'rake'
7
6
  gem 'retryable'
@@ -11,6 +10,6 @@ gem 'tzinfo'
11
10
  gemspec
12
11
 
13
12
  group :development, :test do
14
- gem 'pry'
13
+ gem 'debug'
15
14
  gem 'yaml'
16
15
  end
data/Gemfile.lock ADDED
@@ -0,0 +1,84 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ countries (5.5.0)
5
+ unaccent (~> 0.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (7.0.5)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ concurrent-ruby (1.2.2)
16
+ debug (1.8.0)
17
+ irb (>= 1.5.0)
18
+ reline (>= 0.3.1)
19
+ diff-lcs (1.5.0)
20
+ docile (1.4.0)
21
+ i18n (1.14.1)
22
+ concurrent-ruby (~> 1.0)
23
+ io-console (0.6.0)
24
+ irb (1.7.0)
25
+ reline (>= 0.3.0)
26
+ minitest (5.18.1)
27
+ money (6.16.0)
28
+ i18n (>= 0.6.4, <= 2)
29
+ nokogiri (1.15.2-arm64-darwin)
30
+ racc (~> 1.4)
31
+ nokogiri (1.15.2-x86_64-darwin)
32
+ racc (~> 1.4)
33
+ nokogiri (1.15.2-x86_64-linux)
34
+ racc (~> 1.4)
35
+ racc (1.7.1)
36
+ rake (13.0.6)
37
+ reline (0.3.5)
38
+ io-console (~> 0.5)
39
+ retryable (3.0.5)
40
+ rspec (3.12.0)
41
+ rspec-core (~> 3.12.0)
42
+ rspec-expectations (~> 3.12.0)
43
+ rspec-mocks (~> 3.12.0)
44
+ rspec-core (3.12.2)
45
+ rspec-support (~> 3.12.0)
46
+ rspec-expectations (3.12.3)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.12.0)
49
+ rspec-mocks (3.12.5)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.12.0)
52
+ rspec-support (3.12.0)
53
+ simplecov (0.22.0)
54
+ docile (~> 1.1)
55
+ simplecov-html (~> 0.11)
56
+ simplecov_json_formatter (~> 0.1)
57
+ simplecov-html (0.12.3)
58
+ simplecov_json_formatter (0.1.4)
59
+ tzinfo (2.0.6)
60
+ concurrent-ruby (~> 1.0)
61
+ unaccent (0.4.0)
62
+ yaml (0.2.1)
63
+
64
+ PLATFORMS
65
+ arm64-darwin-22
66
+ x86_64-darwin-21
67
+ x86_64-darwin-22
68
+ x86_64-linux
69
+
70
+ DEPENDENCIES
71
+ activesupport (>= 3)
72
+ countries!
73
+ debug
74
+ money
75
+ nokogiri (>= 1.8)
76
+ rake
77
+ retryable
78
+ rspec (>= 3)
79
+ simplecov (~> 0.22)
80
+ tzinfo
81
+ yaml
82
+
83
+ BUNDLED WITH
84
+ 2.4.12
data/README.md CHANGED
@@ -132,6 +132,18 @@ c.states # => {"CO" => {"name" => "Colorado", "names" => "Colorado"}, ... }
132
132
 
133
133
  # Get specific translations for the country subdivisions
134
134
  c.subdivision_names_with_codes('es') #=> [ ..., ["Nuevo Hampshire", "NH"], ["Nueva Jersey", "NJ"], ... ]
135
+
136
+ # Subdivision code with translations for all loaded locales
137
+ c.subdivisions['NY'].code_with_translations #=> {"NY"=>{"en"=>"New York"}, ...}
138
+ ```
139
+
140
+ `#find_subdivision_by_name` Find a country's state using its code or name in any translation
141
+
142
+ ```ruby
143
+ > ISO3166::Country.new("IT").find_subdivision_by_name("Toscana").geo
144
+ => {"latitude"=>43.771389, "longitude"=>11.254167, ... }
145
+ > ISO3166::Country.new("IT").find_subdivision_by_name("Tuscany").geo
146
+ => {"latitude"=>43.771389, "longitude"=>11.254167, ... }
135
147
  ```
136
148
 
137
149
  ### Location
@@ -206,7 +218,13 @@ c.in_esm? # => false
206
218
  c.in_eu_vat? # => false
207
219
  ```
208
220
 
209
- ## Country Code in Emoji
221
+ ### GDPR Compliant (European Economic Area Membership or UK)
222
+
223
+ ```ruby
224
+ c.gdpr_compliant? # => false
225
+ ```
226
+
227
+ ### Country Code in Emoji
210
228
 
211
229
  ```ruby
212
230
  c = Country['MY']
@@ -219,6 +237,28 @@ c.emoji_flag # => "🇲🇾"
219
237
  ISO3166::Country.pluck(:alpha2, :iso_short_name) # => [["AD", "Andorra"], ["AE", "United Arab Emirates"], ...
220
238
  ```
221
239
 
240
+ `.collect_countries_with` allows to collect various countries' informations using any valid method and query value:
241
+ ```ruby
242
+ > ISO3166::Country.collect_countries_with("VR",:subdivisions,:common_name)
243
+ => ["Italy", "Monaco"]
244
+ > ISO3166::Country.collect_countries_with("Caribbean",:subregion,:languages_spoken).flatten.uniq
245
+ => ["en", "fr", "es", "ht", "nl"]
246
+ > ISO3166::Country.collect_countries_with("Oceania",:region,:international_prefix).uniq
247
+ => ["00", "011", "0011", "19", "05"]
248
+ > ISO3166::Country.collect_countries_with("Antarctica",:continent,:emoji_flag)
249
+ => ["🇦🇶", "🇬🇸", "🇧🇻", "🇹🇫", "🇭🇲"]
250
+ > ISO3166::Country.collect_countries_with("🇸🇨",:emoji_flag,:common_name)
251
+ => ["Seychelles"]
252
+ ```
253
+
254
+ `.collect_likely_countries_by_subdivision_name` allows to lookup all countries having the given state code or state name (in any translation)
255
+
256
+ ```ruby
257
+ ISO3166::Country.collect_likely_countries_by_subdivision_name("San José",:common_name)
258
+ => ["Costa Rica", "Uruguay"]
259
+ ```
260
+
261
+
222
262
  ## Currencies
223
263
 
224
264
  To enable currencies extension please add the following to countries initializer.
data/Rakefile CHANGED
@@ -6,12 +6,10 @@ require 'bundler/gem_tasks'
6
6
  require 'rake'
7
7
  require 'rspec/core/rake_task'
8
8
  require 'yaml'
9
+ require 'json'
9
10
 
10
11
  ISO3166_ROOT_PATH = File.dirname(__FILE__)
11
12
 
12
- # Enter your API Key enabled for Geocoding API and Places API
13
- GOOGLE_API_KEY = 'ENTER API KEY'
14
-
15
13
  Dir.glob('lib/countries/tasks/*.rake').each { |r| load r }
16
14
 
17
15
  desc 'Run all examples'
@@ -56,6 +54,7 @@ task :cleanup_subdivision_yaml do
56
54
  sd = Sources::Local::Subdivision.new(c_code)
57
55
  data = sd.load
58
56
  next if data.nil? || data == {}
57
+
59
58
  data = data.sort.to_h
60
59
  data['translations'] = data['translations'].sort.to_h unless data['translations'].nil?
61
60
  sd.save(data)
data/countries.gemspec CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |gem|
19
19
  'rubygems_mfa_required' => 'true' }
20
20
 
21
21
  gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
22
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
22
  gem.require_paths = ['lib']
24
23
 
25
24
  gem.required_ruby_version = '>= 2.7'
@@ -28,4 +27,5 @@ Gem::Specification.new do |gem|
28
27
  gem.add_development_dependency('activesupport', '>= 3')
29
28
  gem.add_development_dependency('nokogiri', '>= 1.8')
30
29
  gem.add_development_dependency('rspec', '>= 3')
30
+ gem.add_development_dependency('simplecov', '~> 0.22')
31
31
  end