countries 4.2.1 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql-analysis.yml +70 -0
  3. data/.github/workflows/tests.yml +1 -5
  4. data/.rubocop.yml +40 -1
  5. data/.rubocop_todo.yml +8 -41
  6. data/CHANGELOG.md +33 -5
  7. data/Gemfile +5 -3
  8. data/LICENSE +3 -1
  9. data/README.markdown +34 -18
  10. data/Rakefile +15 -31
  11. data/bin/console +1 -0
  12. data/countries.gemspec +12 -10
  13. data/lib/countries/cache/countries.json +1 -1
  14. data/lib/countries/cache/locales/oc.json +1 -1
  15. data/lib/countries/cache/locales/ti.json +1 -1
  16. data/lib/countries/cache/locales/zu.json +1 -1
  17. data/lib/countries/configuration.rb +2 -0
  18. data/lib/countries/country/class_methods.rb +12 -97
  19. data/lib/countries/country/currency_methods.rb +2 -0
  20. data/lib/countries/country/emoji.rb +2 -3
  21. data/lib/countries/country/finder_methods.rb +81 -0
  22. data/lib/countries/country.rb +3 -40
  23. data/lib/countries/data/countries/AE.yaml +1 -1
  24. data/lib/countries/data/countries/KN.yaml +0 -1
  25. data/lib/countries/data/subdivisions/AD.yaml +21 -21
  26. data/lib/countries/data/subdivisions/AF.yaml +2 -2
  27. data/lib/countries/data/subdivisions/AG.yaml +1 -1
  28. data/lib/countries/data/subdivisions/AI.yaml +98 -98
  29. data/lib/countries/data/subdivisions/AL.yaml +82 -626
  30. data/lib/countries/data/subdivisions/AZ.yaml +5 -5
  31. data/lib/countries/data/subdivisions/BA.yaml +11 -11
  32. data/lib/countries/data/subdivisions/BD.yaml +8 -8
  33. data/lib/countries/data/subdivisions/BE.yaml +2 -2
  34. data/lib/countries/data/subdivisions/BF.yaml +13 -13
  35. data/lib/countries/data/subdivisions/BI.yaml +3 -3
  36. data/lib/countries/data/subdivisions/BM.yaml +77 -77
  37. data/lib/countries/data/subdivisions/BS.yaml +22 -22
  38. data/lib/countries/data/subdivisions/BW.yaml +7 -7
  39. data/lib/countries/data/subdivisions/BY.yaml +1 -1
  40. data/lib/countries/data/subdivisions/CD.yaml +19 -19
  41. data/lib/countries/data/subdivisions/CG.yaml +1 -1
  42. data/lib/countries/data/subdivisions/CI.yaml +14 -14
  43. data/lib/countries/data/subdivisions/CK.yaml +77 -77
  44. data/lib/countries/data/subdivisions/CN.yaml +0 -107
  45. data/lib/countries/data/subdivisions/CV.yaml +9 -9
  46. data/lib/countries/data/subdivisions/DK.yaml +1 -0
  47. data/lib/countries/data/subdivisions/DO.yaml +11 -11
  48. data/lib/countries/data/subdivisions/EE.yaml +78 -2
  49. data/lib/countries/data/subdivisions/EH.yaml +12 -12
  50. data/lib/countries/data/subdivisions/ES.yaml +17 -17
  51. data/lib/countries/data/subdivisions/FI.yaml +16 -16
  52. data/lib/countries/data/subdivisions/FJ.yaml +14 -14
  53. data/lib/countries/data/subdivisions/GB.yaml +21 -20
  54. data/lib/countries/data/subdivisions/GH.yaml +7 -7
  55. data/lib/countries/data/subdivisions/GL.yaml +6 -6
  56. data/lib/countries/data/subdivisions/GN.yaml +7 -7
  57. data/lib/countries/data/subdivisions/GQ.yaml +1 -0
  58. data/lib/countries/data/subdivisions/GR.yaml +1 -1
  59. data/lib/countries/data/subdivisions/GW.yaml +3 -3
  60. data/lib/countries/data/subdivisions/HT.yaml +1 -1
  61. data/lib/countries/data/subdivisions/ID.yaml +41 -41
  62. data/lib/countries/data/subdivisions/IE.yaml +1 -2
  63. data/lib/countries/data/subdivisions/IN.yaml +4 -3
  64. data/lib/countries/data/subdivisions/IQ.yaml +1 -1
  65. data/lib/countries/data/subdivisions/IR.yaml +2 -1
  66. data/lib/countries/data/subdivisions/IS.yaml +72 -0
  67. data/lib/countries/data/subdivisions/IT.yaml +7 -8
  68. data/lib/countries/data/subdivisions/KG.yaml +1 -1
  69. data/lib/countries/data/subdivisions/KH.yaml +1 -1
  70. data/lib/countries/data/subdivisions/KN.yaml +2 -2
  71. data/lib/countries/data/subdivisions/KP.yaml +12 -12
  72. data/lib/countries/data/subdivisions/KR.yaml +1 -1
  73. data/lib/countries/data/subdivisions/KZ.yaml +1 -1
  74. data/lib/countries/data/subdivisions/LA.yaml +1 -1
  75. data/lib/countries/data/subdivisions/LB.yaml +2 -2
  76. data/lib/countries/data/subdivisions/LC.yaml +10 -10
  77. data/lib/countries/data/subdivisions/LK.yaml +9 -9
  78. data/lib/countries/data/subdivisions/LR.yaml +2 -2
  79. data/lib/countries/data/subdivisions/LT.yaml +60 -60
  80. data/lib/countries/data/subdivisions/LU.yaml +1 -1
  81. data/lib/countries/data/subdivisions/LV.yaml +1 -1
  82. data/lib/countries/data/subdivisions/MA.yaml +35 -35
  83. data/lib/countries/data/subdivisions/MC.yaml +17 -17
  84. data/lib/countries/data/subdivisions/MD.yaml +740 -740
  85. data/lib/countries/data/subdivisions/ME.yaml +3 -3
  86. data/lib/countries/data/subdivisions/MH.yaml +2 -2
  87. data/lib/countries/data/subdivisions/ML.yaml +2 -2
  88. data/lib/countries/data/subdivisions/MM.yaml +1 -1
  89. data/lib/countries/data/subdivisions/MR.yaml +3 -3
  90. data/lib/countries/data/subdivisions/MV.yaml +8 -8
  91. data/lib/countries/data/subdivisions/MW.yaml +4 -4
  92. data/lib/countries/data/subdivisions/MX.yaml +1 -1
  93. data/lib/countries/data/subdivisions/NL.yaml +6 -6
  94. data/lib/countries/data/subdivisions/NO.yaml +1 -0
  95. data/lib/countries/data/subdivisions/NP.yaml +12 -12
  96. data/lib/countries/data/subdivisions/NZ.yaml +1 -1
  97. data/lib/countries/data/subdivisions/OM.yaml +6 -6
  98. data/lib/countries/data/subdivisions/PG.yaml +3 -3
  99. data/lib/countries/data/subdivisions/PH.yaml +16 -16
  100. data/lib/countries/data/subdivisions/PK.yaml +2 -2
  101. data/lib/countries/data/subdivisions/PS.yaml +16 -16
  102. data/lib/countries/data/subdivisions/QA.yaml +2 -2
  103. data/lib/countries/data/subdivisions/RS.yaml +2 -2
  104. data/lib/countries/data/subdivisions/SC.yaml +4 -2
  105. data/lib/countries/data/subdivisions/SH.yaml +1 -1
  106. data/lib/countries/data/subdivisions/SI.yaml +19 -19
  107. data/lib/countries/data/subdivisions/SJ.yaml +14 -14
  108. data/lib/countries/data/subdivisions/SL.yaml +1 -1
  109. data/lib/countries/data/subdivisions/SN.yaml +3 -3
  110. data/lib/countries/data/subdivisions/SS.yaml +10 -10
  111. data/lib/countries/data/subdivisions/ST.yaml +6 -0
  112. data/lib/countries/data/subdivisions/TD.yaml +6 -6
  113. data/lib/countries/data/subdivisions/TH.yaml +1 -1
  114. data/lib/countries/data/subdivisions/TJ.yaml +2 -2
  115. data/lib/countries/data/subdivisions/TK.yaml +21 -21
  116. data/lib/countries/data/subdivisions/TM.yaml +1 -1
  117. data/lib/countries/data/subdivisions/TT.yaml +2 -2
  118. data/lib/countries/data/subdivisions/TV.yaml +1 -1
  119. data/lib/countries/data/subdivisions/TW.yaml +3 -17
  120. data/lib/countries/data/subdivisions/TZ.yaml +5 -5
  121. data/lib/countries/data/subdivisions/UG.yaml +59 -52
  122. data/lib/countries/data/subdivisions/UM.yaml +0 -10
  123. data/lib/countries/data/subdivisions/WF.yaml +3 -13
  124. data/lib/countries/data/subdivisions/YE.yaml +3 -3
  125. data/lib/countries/data/subdivisions/ZA.yaml +2 -2
  126. data/lib/countries/data/subdivisions/ZM.yaml +1 -1
  127. data/lib/countries/data.rb +34 -37
  128. data/lib/countries/global.rb +2 -0
  129. data/lib/countries/iso3166.rb +3 -0
  130. data/lib/countries/kwarg_struct.rb +2 -0
  131. data/lib/countries/mongoid.rb +2 -0
  132. data/lib/countries/sources/cldr/downloader.rb +8 -8
  133. data/lib/countries/sources/cldr/subdivision.rb +3 -0
  134. data/lib/countries/sources/cldr/subdivision_updater.rb +23 -17
  135. data/lib/countries/sources/local/cached_loader.rb +3 -0
  136. data/lib/countries/sources/local/subdivision.rb +5 -2
  137. data/lib/countries/sources.rb +2 -0
  138. data/lib/countries/structure.rb +1 -1
  139. data/lib/countries/subdivision.rb +2 -0
  140. data/lib/countries/tasks/geocoding.rake +15 -6
  141. data/lib/countries/tasks/postal_codes.rake +5 -3
  142. data/lib/countries/timezones.rb +5 -2
  143. data/lib/countries/translations.rb +2 -0
  144. data/lib/countries/version.rb +3 -1
  145. data/lib/countries.rb +2 -0
  146. data/spec/00_global_spec.rb +2 -0
  147. data/spec/configuration_spec.rb +11 -5
  148. data/spec/country_spec.rb +71 -22
  149. data/spec/data_spec.rb +24 -18
  150. data/spec/mongoid_spec.rb +2 -2
  151. data/spec/perf_spec.rb +16 -16
  152. data/spec/spec_helper.rb +2 -0
  153. data/spec/subdivision_spec.rb +6 -4
  154. data/spec/thread_safety_spec.rb +4 -3
  155. data/spec/timezone_spec.rb +2 -0
  156. metadata +18 -45
  157. data/lib/countries/data/subdivisions/AS.yaml +0 -85
  158. data/lib/countries/data/subdivisions/AW.yaml +0 -9
  159. data/lib/countries/data/subdivisions/AX.yaml +0 -51
  160. data/lib/countries/data/subdivisions/BL.yaml +0 -11
  161. data/lib/countries/data/subdivisions/CP.yaml +0 -4
  162. data/lib/countries/data/subdivisions/CW.yaml +0 -9
  163. data/lib/countries/data/subdivisions/GF.yaml +0 -11
  164. data/lib/countries/data/subdivisions/GG.yaml +0 -155
  165. data/lib/countries/data/subdivisions/GP.yaml +0 -11
  166. data/lib/countries/data/subdivisions/GU.yaml +0 -275
  167. data/lib/countries/data/subdivisions/HK.yaml +0 -267
  168. data/lib/countries/data/subdivisions/IC.yaml +0 -4
  169. data/lib/countries/data/subdivisions/IM.yaml +0 -337
  170. data/lib/countries/data/subdivisions/JE.yaml +0 -169
  171. data/lib/countries/data/subdivisions/MF.yaml +0 -9
  172. data/lib/countries/data/subdivisions/MO.yaml +0 -9
  173. data/lib/countries/data/subdivisions/MP.yaml +0 -71
  174. data/lib/countries/data/subdivisions/MQ.yaml +0 -11
  175. data/lib/countries/data/subdivisions/MS.yaml +0 -43
  176. data/lib/countries/data/subdivisions/NC.yaml +0 -57
  177. data/lib/countries/data/subdivisions/PF.yaml +0 -81
  178. data/lib/countries/data/subdivisions/PM.yaml +0 -39
  179. data/lib/countries/data/subdivisions/PR.yaml +0 -1107
  180. data/lib/countries/data/subdivisions/RE.yaml +0 -11
  181. data/lib/countries/data/subdivisions/SX.yaml +0 -9
  182. data/lib/countries/data/subdivisions/TA.yaml +0 -4
  183. data/lib/countries/data/subdivisions/TF.yaml +0 -67
  184. data/lib/countries/data/subdivisions/VI.yaml +0 -57
  185. data/lib/countries/data/subdivisions/YT.yaml +0 -247
  186. data/lib/countries/setup.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 678e46df92cdbff4228c25619b4a2314ce1d6226fff8a482ec0f9ed9a6bac464
4
- data.tar.gz: fb5e189397d9af4855751ddcb0168156c84a9409c79bbd707b36cc91155051ba
3
+ metadata.gz: a8a95786ec6321b9d8d1f9b11854cd37d693554a2052a270187a7ee82f8d629b
4
+ data.tar.gz: 9c360efbd86c1f91526ec28474041255c54d81585c689c8dd1b492c33e7db060
5
5
  SHA512:
6
- metadata.gz: 161184e5015c11d10070be7d17bfe02c7292e5c1ff1fb68e9344f8fad39e23ed1fde5f7bef46f256999ef80a5503cdecb290e411343ce328bf085517e1a1a205
7
- data.tar.gz: cb629c1eaf3626afe096159e170d5bf02c678db4ea4046623ed719cc5eea76983500ae38b8c7cb22146b32e7ddc91a006377bcace5e94d590ed85a70850ed67e
6
+ metadata.gz: 077e94f77953b21e4d3e59e7830429f9effa3633e310ce682d554f3eeefdf976fc0290a6d1ae9e1ee5f379f3f7abbb8043a1484822ea82473f833f3369b8f9f0
7
+ data.tar.gz: 7fcdbfc5e27c1eb44e684694da9974000f7d076da9770138c9402ec46866cdd7e52c90141c815559149b7a5fe6e00ee16a2578c6b6f966c5d7bcc5c819840255
@@ -0,0 +1,70 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '19 13 * * 5'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v3
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v1
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v1
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v1
@@ -15,15 +15,11 @@ jobs:
15
15
  strategy:
16
16
  matrix:
17
17
  include:
18
- - ruby-version: 2.5.9
19
- bundler-version: default
20
- - ruby-version: 2.6.9
21
- bundler-version: default
22
18
  - ruby-version: 2.7.5
23
19
  bundler-version: default
24
20
  - ruby-version: 3.0.3
25
21
  bundler-version: default
26
- - ruby-version: 3.1.0
22
+ - ruby-version: 3.1.1
27
23
  bundler-version: default
28
24
  steps:
29
25
  - uses: actions/checkout@v2
data/.rubocop.yml CHANGED
@@ -1 +1,40 @@
1
- inherit_from: .rubocop_todo.yml
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+
6
+ Layout/LineLength:
7
+ Exclude:
8
+ - countries.gemspec
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - 'spec/**/*'
13
+ - Rakefile
14
+ - 'spec/**/*'
15
+ - 'lib/countries/tasks/*'
16
+
17
+ Style/RescueModifier:
18
+ Enabled: false
19
+
20
+ Style/CaseEquality:
21
+ Exclude:
22
+ - 'lib/countries/country/finder_methods.rb'
23
+
24
+ Style/IfUnlessModifier:
25
+ Exclude:
26
+ - 'spec/thread_safety_spec.rb'
27
+
28
+ Naming/MethodName:
29
+ Exclude:
30
+ - 'lib/countries/country/class_methods.rb'
31
+
32
+ Lint/AmbiguousBlockAssociation:
33
+ Exclude:
34
+ - 'spec/perf_spec.rb'
35
+
36
+ Metrics/MethodLength:
37
+ Max: 20
38
+
39
+ Metrics/ClassLength:
40
+ Max: 130
data/.rubocop_todo.yml CHANGED
@@ -1,52 +1,19 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-09-19 23:29:07 -0400 using RuboCop version 0.43.0.
3
+ # on 2022-01-07 11:03:11 UTC using RuboCop version 1.24.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
- # Offense count: 1
9
- # Configuration parameters: CountComments.
10
- Metrics/ClassLength:
11
- Max: 101
12
8
 
13
- # Offense count: 64
14
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
15
- # URISchemes: http, https
16
- Metrics/LineLength:
17
- Max: 483
18
9
 
19
- # Offense count: 1
10
+ # Offense count: 3
11
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
20
12
  Metrics/AbcSize:
21
- Max: 19
13
+ Max: 33
22
14
 
23
- # Offense count: 1
24
- Style/CaseEquality:
25
- Exclude:
26
- - 'lib/countries/country/class_methods.rb'
27
-
28
- # Offense count: 7
29
- Style/ClassVars:
30
- Exclude:
31
- - 'lib/countries/data.rb'
32
-
33
- # Offense count: 9
15
+ # Enable after the doc branch is merged
34
16
  Style/Documentation:
35
- Exclude:
36
- - 'spec/**/*'
37
- - 'test/**/*'
38
- - 'lib/countries/configuration.rb'
39
- - 'lib/countries/country.rb'
40
- - 'lib/countries/country/class_methods.rb'
41
- - 'lib/countries/country/emoji.rb'
42
- - 'lib/countries/global.rb'
43
- - 'lib/countries/kwarg_struct.rb'
44
- - 'lib/countries/mongoid.rb'
45
-
46
-
47
- # Offense count: 1
48
- # Configuration parameters: EnforcedStyle, SupportedStyles.
49
- # SupportedStyles: snake_case, camelCase
50
- Style/MethodName:
51
- Exclude:
52
- - 'lib/countries/country/class_methods.rb'
17
+ Enabled: false
18
+ # Exclude:
19
+ # - 'spec/**/*'
data/CHANGELOG.md CHANGED
@@ -1,18 +1,46 @@
1
1
  # Change Log
2
+
2
3
  All notable changes to this project will be documented in this file.
3
- This project adheres to [Semantic Versioning](http://semver.org/).
4
+ This project adheres to [Semantic Versioning](https://semver.org/).
4
5
 
5
- ## [Future 5.0 release]
6
+ ## [5.0.0] (https://github.com/countries/countries/releases/tag/v5.0.') (2022/04/03 17:44 +00:00)
6
7
 
7
8
  **Breaking Changes**
8
9
 
10
+ - Drop support for Ruby 2.5 and 2.6. (EOL in 2021-03-31 and 2022-03-31, respectively)
11
+ - Remove deprecated attributes and add new `#find_by_any_name` finder, see https://github.com/countries/countries#upgrading-to-42-and-5x for details
12
+
13
+ **Merged pull requests:**
14
+
9
15
  - Drop support for Ruby 2.5 and 2.6 [\#708](https://github.com/countries/countries/pull/708) ([pmor](https://github.com/pmor))
16
+ - Remove deprecated attributes; Add new `#find_by_any_name` finder [\#745](https://github.com/countries/countries/pull/708) ([pmor](https://github.com/pmor))
10
17
 
11
- ## [4.2.1](https://github.com/countries/countries/releases/tag/v4.2.0) (2022/01/11 12:39 +00:00)
18
+ ## [4.2.3](https://github.com/countries/countries/releases/tag/v4.2.2) (2022/03/24 11:00 +00:00)
12
19
 
13
- - Missing update to cache files on release 4.2.0
14
- - Update postal code regexes from rake task [\#734 ](https://github.com/countries/countries/pull/734 ) ([cover](https://github.com/cover))
20
+ **IMPORTANT NOTE: This will be be the last release of the 4.x series, and the last one to support Ruby 2.5 and 2.6**
21
+
22
+ * Use bundle add instead [\#743](https://github.com/countries/countries/pull/743) ([glaucocustodio](https://github.com/glaucocustodio))
23
+ * update i18n_data [\#742](https://github.com/countries/countries/pull/742) ([bonekost](https://github.com/bonekost))
24
+
25
+ ## [4.2.2](https://github.com/countries/countries/releases/tag/v4.2.2) (2022/02/17 13:52 +00:00)
26
+
27
+ **Merged pull requests:**
15
28
 
29
+ * http:// -> https:// [\#737](https://github.com/countries/countries/pull/737) ([biow0lf](https://github.com/biow0lf))
30
+ * Update AE start_of_week to monday. [\#739](https://github.com/countries/countries/pull/739) ([pmor](https://github.com/pmor))
31
+ * Fix Subdivision data by [\#740](https://github.com/countries/countries/pull/740) ([pmor](https://github.com/pmor))
32
+
33
+ **Closed issues:**
34
+
35
+ * Change on UAE Value.start_of_week [\#738](https://github.com/countries/countries/issues/738)
36
+
37
+
38
+ **Full Changelog**: https://github.com/countries/countries/compare/v4.2.1...v4.2.2
39
+
40
+ ## [4.2.1](https://github.com/countries/countries/releases/tag/v4.2.1) (2022/01/11 12:39 +00:00)
41
+
42
+ - Missing update to cache files on release 4.2.0
43
+ - Update postal code regexes from rake task [\#734](https://github.com/countries/countries/pull/734 ) ([cover](https://github.com/cover))
16
44
 
17
45
  ## [4.2.0](https://github.com/countries/countries/releases/tag/v4.2.0) (2022/01/11 11:04 +00:00)
18
46
 
data/Gemfile CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
- gem 'rake'
3
4
  gem 'geocoder'
5
+ gem 'money'
6
+ gem 'rake'
4
7
  gem 'retryable'
5
8
  gem 'tzinfo'
6
- gem 'money'
7
9
 
8
10
  # Specify your gem's dependencies in countries.gemspec
9
11
  gemspec
@@ -11,4 +13,4 @@ gemspec
11
13
  group :development, :test do
12
14
  gem 'pry'
13
15
  gem 'yaml'
14
- end
16
+ end
data/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2012 hexorx
1
+ Copyright (c) 2012-2015 hexorx
2
+ Copyright (c) 2015-2021 hexorx, rposborne
3
+ Copyright (c) 2022 hexorx, rposborne, pmor
2
4
 
3
5
  MIT License
4
6
 
data/README.markdown CHANGED
@@ -3,23 +3,21 @@
3
3
  Countries is a collection of all sorts of useful information for every country in the ISO 3166 standard. It contains info for the following standards ISO3166-1 (countries), ISO3166-2 (states/subdivisions), ISO4217 (currency) and E.164 (phone numbers). I will add any country based data I can get access to. I hope this to be a repository for all country based information.
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/countries.svg)](https://badge.fury.io/rb/countries) [![Tests](https://github.com/countries/countries/actions/workflows/tests.yml/badge.svg)](https://github.com/countries/countries/actions/workflows/tests.yml) [![Code Climate](https://codeclimate.com/github/countries/countries.svg)](https://codeclimate.com/github/countries/countries)
6
+ [![CodeQL](https://github.com/countries/countries/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/countries/countries/actions/workflows/codeql-analysis.yml)
7
+
6
8
 
7
9
  ## Installation
8
10
 
9
11
  ```bash
10
- gem install countries
11
- ```
12
+ gem install countries
13
+ ```
12
14
 
13
- Or you can install via Bundler if you are using Rails. Add this line to your application's Gemfile:
15
+ Or you can install via Bundler if you are using Rails:
14
16
 
15
- ```ruby
16
- gem 'countries'
17
+ ```bash
18
+ bundle add countries
17
19
  ```
18
20
 
19
- And then execute:
20
-
21
- $ bundle
22
-
23
21
  ## Basic Usage
24
22
 
25
23
  Simply load a new country object using Country.new(*alpha2*) or the shortcut Country[*alpha2*]. An example works best.
@@ -56,10 +54,25 @@ In release 4.2 the `#name` attribute was deprecated in favour of `#iso_short_nam
56
54
 
57
55
  For additional clarity, the `#names` method, which was an alias to `#unofficial_names` has also been deprecated, together with the finder methods that use `name` or `names` attributes.
58
56
 
59
- The `#name` and `#names` attributes, and corresponding finder methods will be removed in 5.0.
57
+ The `#name` and `#names` attributes, and corresponding finder methods were removed in 5.0.
58
+
59
+ The replacement finders added in 5.0 are:
60
+
61
+ - `#find_by_name` => `#find_by_any_name` - Searches all the name attributes, same as before
62
+ - `#find_by_names` => `#find_by_unofficial_names`
63
+ - `#find_*_by_name` => `#find_*_by_any_name`
64
+ - `#find_*_by_names` => `#find_*_by_unofficial_names`
65
+
66
+ With the addition of the new name attributes, there are now also the following finders:
67
+
68
+ - `#find_by_common_name`/`#find_*_by_common_name`
69
+ - `#find_by_iso_short_name`/`#find_*_by_iso_short_name`
70
+ - `#find_by_iso_long_name`/`#find_*_by_iso_long_name`
60
71
 
61
72
  For translated country names, we use data from [pkg-isocodes](https://salsa.debian.org/iso-codes-team/iso-codes), via the [i18n_data](https://github.com/grosser/i18n_data) gem, and these generally correspond to the expected "common names". These names and the corresponding methods have not been changed.
62
73
 
74
+ The 5.0 release removed support for Ruby 2.5 (EOL 2021-03-01) and 2.6 (EOL 2022-03-31)
75
+
63
76
  ## Selective Loading of Locales
64
77
 
65
78
  As of 2.0 you can selectively load locales to reduce memory usage in production.
@@ -86,7 +99,8 @@ end
86
99
  You can lookup a country or an array of countries using any of the data attributes via the find\_country\_by_*attribute* dynamic methods:
87
100
 
88
101
  ```ruby
89
- c = ISO3166::Country.find_country_by_iso_short_name('united states')
102
+ c = ISO3166::Country.find_country_by_iso_short_name('italy')
103
+ c = ISO3166::Country.find_country_by_any_name('united states')
90
104
  h = ISO3166::Country.find_all_by(:translated_names, 'França')
91
105
  list = ISO3166::Country.find_all_countries_by_region('Americas')
92
106
  c = ISO3166::Country.find_country_by_alpha3('can')
@@ -95,8 +109,7 @@ c = ISO3166::Country.find_country_by_alpha3('can')
95
109
  For a list of available attributes please see `ISO3166::DEFAULT_COUNTRY_HASH`.
96
110
  Note: searches are *case insensitive and ignore accents*.
97
111
 
98
- _Please note that `find_by_name`, `find_by_names`, `find_*_by_name` and `find_*_by_names` methods are deprecated and will be removed in 5.0. See [Upgrading to 4.2 and 5.x](#upgrading-to-4-2-and-5-x) above_
99
-
112
+ _Please note that `find_by_name`, `find_by_names`, `find_*_by_name` and `find_*_by_names` methods were removed in 5.0. See [Upgrading to 4.2 and 5.x](#upgrading-to-4-2-and-5-x) above for the new methods_
100
113
 
101
114
  ## Country Info
102
115
 
@@ -153,7 +166,7 @@ c.region # => "Americas"
153
166
  c.subregion # => "Northern America"
154
167
  ```
155
168
 
156
- Please note that `latitude_dec` and `longitude_dec` was be deprecated on release 4.2 and will be deleted in 5.0. These attributes have been redundant for several years, since the `latitude` and `longitude` fields have been switched decimal coordinates.
169
+ Please note that `latitude_dec` and `longitude_dec` were deprecated on release 4.2 and removed in 5.0. These attributes have been redundant for several years, since the `latitude` and `longitude` fields have been switched decimal coordinates.
157
170
 
158
171
  ### Timezones **(optional)**
159
172
 
@@ -165,8 +178,8 @@ gem 'tzinfo', '~> 1.2', '>= 1.2.2'
165
178
 
166
179
  ```ruby
167
180
  c.timezones.zone_identifiers # => ["America/New_York", "America/Detroit", "America/Kentucky/Louisville", ...]
168
- c.timezones.zone_info # see [tzinfo docs]( http://www.rubydoc.info/gems/tzinfo/TZInfo/CountryInfo)
169
- c.timezones # see [tzinfo docs]( http://www.rubydoc.info/gems/tzinfo/TZInfo/Country)
181
+ c.timezones.zone_info # see [tzinfo docs](https://www.rubydoc.info/gems/tzinfo/TZInfo/CountryTimezone)
182
+ c.timezones # see [tzinfo docs](https://www.rubydoc.info/gems/tzinfo/TZInfo/Country)
170
183
  ```
171
184
 
172
185
  ### Telephone Routing (E164)
@@ -240,7 +253,7 @@ c.currency.symbol # => '$'
240
253
 
241
254
  ## Address Formatting
242
255
 
243
- A template for formatting addresses is available through the address_format method. These templates are compatible with the [Liquid](http://www.liquidmarkup.org/) template system.
256
+ A template for formatting addresses is available through the address_format method. These templates are compatible with the [Liquid](https://shopify.github.io/liquid/) template system.
244
257
 
245
258
  ```ruby
246
259
  c.address_format # => "{{recipient}}\n{{street}}\n{{city}} {{region}} {{postalcode}}\n{{country}}"
@@ -349,5 +362,8 @@ the next `rake update_cache`.
349
362
 
350
363
  ## Copyright
351
364
 
352
- Copyright (c) 2016 hexorx. See LICENSE for details.
365
+ Copyright (c) 2012-2015 hexorx
366
+ Copyright (c) 2015-2021 hexorx, rposborne
367
+ Copyright (c) 2022 hexorx, rposborne, pmor
353
368
 
369
+ See LICENSE for details.
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env rake
2
+ # frozen_string_literal: true
3
+
2
4
  require 'bundler/gem_tasks'
3
5
 
4
6
  require 'rake'
@@ -34,9 +36,12 @@ task :update_cache do
34
36
  codes = Dir['lib/countries/data/countries/*.yaml'].map { |x| File.basename(x, File.extname(x)) }.uniq.sort
35
37
  data = {}
36
38
 
37
- corrections = YAML.load_file(File.join(File.dirname(__FILE__), 'lib', 'countries', 'data', 'translation_corrections.yaml')) || {}
39
+ corrections_file = File.join(File.dirname(__FILE__), 'lib', 'countries', 'data', 'translation_corrections.yaml')
40
+ corrections = YAML.load_file(corrections_file) || {}
38
41
 
39
- language_keys = I18nData.languages.keys + ['zh_CN', 'zh_TW', 'zh_HK','bn_IN','pt_BR']
42
+ language_keys = I18nData.languages.keys + %w[zh_CN zh_TW zh_HK bn_IN pt_BR]
43
+ # Ignore locales that have bad data in i18n_data 0.16.0
44
+ language_keys -= %w[AY AM BA]
40
45
  language_keys.each do |locale|
41
46
  locale = locale.downcase
42
47
  begin
@@ -46,40 +51,19 @@ task :update_cache do
46
51
  end
47
52
 
48
53
  # Apply any known corrections to i18n_data
49
- unless corrections[locale].nil?
50
- corrections[locale].each do |alpha2, localized_name|
51
- local_names[alpha2] = localized_name
52
- end
54
+ corrections[locale]&.each do |alpha2, localized_name|
55
+ local_names[alpha2] = localized_name
53
56
  end
54
57
 
55
- File.open(File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'locales', "#{locale.gsub(/_/, '-')}.json"), 'wb') { |f| f.write(local_names.to_json) }
58
+ out = File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'locales', "#{locale.gsub(/_/, '-')}.json")
59
+ File.binwrite(out, local_names.to_json)
56
60
  end
57
61
 
58
62
  codes.each do |alpha2|
59
- data[alpha2] ||= YAML.load_file(File.join(File.dirname(__FILE__), 'lib', 'countries', 'data', 'countries', "#{alpha2}.yaml"))[alpha2]
63
+ country_file = File.join(File.dirname(__FILE__), 'lib', 'countries', 'data', 'countries', "#{alpha2}.yaml")
64
+ data[alpha2] ||= YAML.load_file(country_file)[alpha2]
60
65
  end
61
66
 
62
- File.open(File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'countries.json'), 'wb') { |f| f.write(data.to_json) }
67
+ out_file = File.join(File.dirname(__FILE__), 'lib', 'countries', 'cache', 'countries.json')
68
+ File.binwrite(out_file, data.to_json)
63
69
  end
64
-
65
- # Temporary task to update YAML file structure with iso_long_name and iso_short_name attributes
66
- task :update_iso_names do
67
- require 'csv'
68
- isodata = CSV.read 'isonames.csv', headers: true
69
-
70
- d = Dir['lib/countries/data/countries/*.yaml']
71
- d.each do |file|
72
- puts "checking : #{file}"
73
- data = YAML.load_file(file)
74
-
75
- country_code = data.keys.first
76
- iso_country = isodata.find {|c| c['cc'] == country_code}
77
-
78
- data.values.first['iso_long_name'] = iso_country['iso_full_name']
79
- data.values.first['iso_short_name'] = data.values.first.delete('name')
80
-
81
- data[country_code.upcase] = data[country_code.upcase].sort.to_h
82
-
83
- File.open(file, 'w') { |f| f.write data.to_yaml }
84
- end
85
- end
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'countries'
data/countries.gemspec CHANGED
@@ -1,16 +1,18 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/countries/version', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('lib/countries/version', __dir__)
3
4
 
4
5
  Gem::Specification.new do |gem|
5
6
  gem.authors = ['Josh Robinson', 'Joe Corcoran', 'Russell Osborne', 'Pedro Moreira']
6
7
  gem.email = ['hexorx@gmail.com', 'russell@burningpony.com', 'pedro@codecreations.tech']
7
8
  gem.description = 'All sorts of useful information about every country packaged as pretty little country objects. It includes data from ISO 3166'
8
9
  gem.summary = 'Gives you a country object full of all sorts of useful information.'
9
- gem.homepage = 'http://github.com/countries/countries'
10
- gem.metadata = { 'bug_tracker_uri' => 'http://github.com/countries/countries/issues',
11
- 'changelog_uri' => 'https://github.com/countries/countries/blob/master/CHANGELOG.md',
12
- 'source_code_uri' => 'https://github.com/countries/countries',
13
- 'wiki_uri' => 'https://github.com/countries/countries/wiki'}
10
+ gem.homepage = 'https://github.com/countries/countries'
11
+ gem.metadata = { 'bug_tracker_uri' => 'https://github.com/countries/countries/issues',
12
+ 'changelog_uri' => 'https://github.com/countries/countries/blob/master/CHANGELOG.md',
13
+ 'source_code_uri' => 'https://github.com/countries/countries',
14
+ 'wiki_uri' => 'https://github.com/countries/countries/wiki',
15
+ 'rubygems_mfa_required' => 'true' }
14
16
 
15
17
  gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
16
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -19,11 +21,11 @@ Gem::Specification.new do |gem|
19
21
  gem.version = Countries::VERSION.dup
20
22
  gem.license = 'MIT'
21
23
 
22
- gem.required_ruby_version = '>= 2.5'
24
+ gem.required_ruby_version = '>= 2.7'
23
25
 
24
- gem.add_dependency('i18n_data', '~> 0.15.0')
26
+ gem.add_dependency('i18n_data', '~> 0.16.0')
25
27
  gem.add_dependency('sixarm_ruby_unaccent', '~> 1.1')
26
- gem.add_development_dependency('rspec', '>= 3')
27
28
  gem.add_development_dependency('activesupport', '>= 3')
28
29
  gem.add_development_dependency('nokogiri', '>= 1.8')
30
+ gem.add_development_dependency('rspec', '>= 3')
29
31
  end