turkish_cities 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +20 -0
  3. data/.hound.yml +1 -1
  4. data/.rubocop.yml +2 -1
  5. data/CHANGELOG.md +22 -0
  6. data/Gemfile.lock +21 -21
  7. data/README.md +143 -13
  8. data/config/locales/en.yml +19 -0
  9. data/config/locales/tr.yml +19 -0
  10. data/lib/turkish_cities/city.rb +1 -3
  11. data/lib/turkish_cities/data/cities.yaml +267 -0
  12. data/lib/turkish_cities/data/districts/adana.yaml +1 -1
  13. data/lib/turkish_cities/data/districts/adiyaman.yaml +184 -176
  14. data/lib/turkish_cities/data/districts/afyon.yaml +295 -189
  15. data/lib/turkish_cities/data/districts/agri.yaml +28 -28
  16. data/lib/turkish_cities/data/districts/aksaray.yaml +90 -61
  17. data/lib/turkish_cities/data/districts/amasya.yaml +17 -6
  18. data/lib/turkish_cities/data/districts/ankara.yaml +22 -22
  19. data/lib/turkish_cities/data/districts/antalya.yaml +3 -3
  20. data/lib/turkish_cities/data/districts/ardahan.yaml +10 -7
  21. data/lib/turkish_cities/data/districts/artvin.yaml +0 -60
  22. data/lib/turkish_cities/data/districts/bartin.yaml +23 -19
  23. data/lib/turkish_cities/data/districts/batman.yaml +45 -28
  24. data/lib/turkish_cities/data/districts/bayburt.yaml +12 -6
  25. data/lib/turkish_cities/data/districts/bilecik.yaml +18 -14
  26. data/lib/turkish_cities/data/districts/bingol.yaml +29 -35
  27. data/lib/turkish_cities/data/districts/bitlis.yaml +56 -43
  28. data/lib/turkish_cities/data/districts/bolu.yaml +34 -58
  29. data/lib/turkish_cities/data/districts/burdur.yaml +22 -16
  30. data/lib/turkish_cities/data/districts/bursa.yaml +3 -2
  31. data/lib/turkish_cities/data/districts/canakkale.yaml +46 -47
  32. data/lib/turkish_cities/data/districts/cankiri.yaml +23 -18
  33. data/lib/turkish_cities/data/districts/corum.yaml +25 -15
  34. data/lib/turkish_cities/data/districts/denizli.yaml +1 -1
  35. data/lib/turkish_cities/data/districts/diyarbakir.yaml +6 -6
  36. data/lib/turkish_cities/data/districts/duzce.yaml +83 -74
  37. data/lib/turkish_cities/data/districts/edirne.yaml +37 -23
  38. data/lib/turkish_cities/data/districts/elazig.yaml +74 -54
  39. data/lib/turkish_cities/data/districts/erzincan.yaml +47 -38
  40. data/lib/turkish_cities/data/districts/erzurum.yaml +1 -1
  41. data/lib/turkish_cities/data/districts/giresun.yaml +125 -57
  42. data/lib/turkish_cities/data/districts/gumushane.yaml +61 -81
  43. data/lib/turkish_cities/data/districts/hakkari.yaml +22 -15
  44. data/lib/turkish_cities/data/districts/hatay.yaml +1 -1
  45. data/lib/turkish_cities/data/districts/igdir.yaml +20 -11
  46. data/lib/turkish_cities/data/districts/isparta.yaml +67 -40
  47. data/lib/turkish_cities/data/districts/istanbul.yaml +12 -12
  48. data/lib/turkish_cities/data/districts/izmir.yaml +12 -12
  49. data/lib/turkish_cities/data/districts/kahramanmaras.yaml +3 -2
  50. data/lib/turkish_cities/data/districts/karabuk.yaml +15 -28
  51. data/lib/turkish_cities/data/districts/karaman.yaml +36 -31
  52. data/lib/turkish_cities/data/districts/kars.yaml +5 -4
  53. data/lib/turkish_cities/data/districts/kastamonu.yaml +3 -29
  54. data/lib/turkish_cities/data/districts/kayseri.yaml +8 -8
  55. data/lib/turkish_cities/data/districts/kilis.yaml +3 -2
  56. data/lib/turkish_cities/data/districts/kirikkale.yaml +17 -13
  57. data/lib/turkish_cities/data/districts/kirklareli.yaml +63 -45
  58. data/lib/turkish_cities/data/districts/kirsehir.yaml +25 -16
  59. data/lib/turkish_cities/data/districts/kocaeli.yaml +1 -1
  60. data/lib/turkish_cities/data/districts/konya.yaml +7 -8
  61. data/lib/turkish_cities/data/districts/kutahya.yaml +104 -72
  62. data/lib/turkish_cities/data/districts/malatya.yaml +1 -1
  63. data/lib/turkish_cities/data/districts/manisa.yaml +2 -2
  64. data/lib/turkish_cities/data/districts/mersin.yaml +4 -4
  65. data/lib/turkish_cities/data/districts/mus.yaml +118 -74
  66. data/lib/turkish_cities/data/districts/nevsehir.yaml +51 -43
  67. data/lib/turkish_cities/data/districts/nigde.yaml +135 -76
  68. data/lib/turkish_cities/data/districts/ordu.yaml +3 -3
  69. data/lib/turkish_cities/data/districts/osmaniye.yaml +53 -32
  70. data/lib/turkish_cities/data/districts/rize.yaml +68 -46
  71. data/lib/turkish_cities/data/districts/sakarya.yaml +2 -2
  72. data/lib/turkish_cities/data/districts/samsun.yaml +3 -3
  73. data/lib/turkish_cities/data/districts/sanliurfa.yaml +7 -7
  74. data/lib/turkish_cities/data/districts/siirt.yaml +27 -13
  75. data/lib/turkish_cities/data/districts/sinop.yaml +1 -5
  76. data/lib/turkish_cities/data/districts/sirnak.yaml +78 -40
  77. data/lib/turkish_cities/data/districts/sivas.yaml +49 -52
  78. data/lib/turkish_cities/data/districts/tekirdag.yaml +7 -2
  79. data/lib/turkish_cities/data/districts/tokat.yaml +201 -138
  80. data/lib/turkish_cities/data/districts/trabzon.yaml +1 -0
  81. data/lib/turkish_cities/data/districts/tunceli.yaml +13 -9
  82. data/lib/turkish_cities/data/districts/usak.yaml +40 -24
  83. data/lib/turkish_cities/data/districts/van.yaml +6 -4
  84. data/lib/turkish_cities/data/districts/yalova.yaml +45 -21
  85. data/lib/turkish_cities/data/districts/yozgat.yaml +147 -80
  86. data/lib/turkish_cities/data/districts/zonguldak.yaml +127 -90
  87. data/lib/turkish_cities/data/neighborhoods_parser.rb +4 -4
  88. data/lib/turkish_cities/distance.rb +33 -3
  89. data/lib/turkish_cities/helpers/decomposer_helper.rb +21 -7
  90. data/lib/turkish_cities/population.rb +66 -0
  91. data/lib/turkish_cities/version.rb +1 -1
  92. data/lib/turkish_cities.rb +22 -2
  93. data/turkish_cities.gemspec +2 -3
  94. metadata +11 -8
  95. data/.travis.yml +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d25fd4c984c9526d142458a9a5c3b6cb76b3f9d1c6b97ef97e931aca0bd305d
4
- data.tar.gz: c8ddb6072e8db3c909d2bb023ce86a7c8f9f0b97eb655816aa8c3d4005fc30da
3
+ metadata.gz: 3ec20706a6b0a7afa3bdca2e6dfc0c6e70c2a67b1cfc1f3ce31f6390c107a4ad
4
+ data.tar.gz: 603d48232efc5ada2b0210814be61569f4e547776db4e4cfb9998df5a6e85277
5
5
  SHA512:
6
- metadata.gz: 1543f861a161ca1384261aa85ecb058966e445db3e3c3b39cdab8df1616da101ebaebeb81f7bfd5b402cb85a3fe068c04b9d664f5fee20a8c9487d309bb9504e
7
- data.tar.gz: d1c29d060f7205dc6312027b066f33f87364cdff050df70ca17f0d81a693cde736bfddba48cce46ceb61e3613f121bd9324875cfb6466e1e50ffc9a476f40235
6
+ metadata.gz: 9f55936144b6e0c926e12df2ccc16fa4e52d2a48c28ac248749422122af16a241b5b33501dd8234939bc6ff66278bf02f5bc435cf715ddb1f26c0c68a6197515
7
+ data.tar.gz: 3df41060bd4478b0875f316c358074b5881002a631a1b9fe1bff4864b74de15c6618e2c16c3b59ef2fc8ab5894914da71f9f31a041ca8845f8031b974d1f6468
@@ -0,0 +1,20 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: monthly
7
+ time: "09:00"
8
+ open-pull-requests-limit: 10
9
+ ignore:
10
+ - dependency-name: rubocop
11
+ versions:
12
+ - 1.8.1
13
+ - 1.9.1
14
+ - dependency-name: bundler
15
+ versions:
16
+ - 2.2.6
17
+ - 2.2.7
18
+ - dependency-name: i18n
19
+ versions:
20
+ - 1.8.7
data/.hound.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  rubocop:
2
- version: 0.83.0
2
+ version: 1.22.1
3
3
  config_file: .rubocop.yml
data/.rubocop.yml CHANGED
@@ -4,12 +4,13 @@ AllCops:
4
4
  - 'Gemfile'
5
5
  - 'turkish_cities.gemspec'
6
6
  NewCops: enable
7
+ SuggestExtensions: false
7
8
  Layout/LineLength:
8
9
  Max: 120
9
10
  Metrics/AbcSize:
10
11
  Max: 20
11
12
  Metrics/BlockLength:
12
- ExcludedMethods: ['describe', 'context']
13
+ IgnoredMethods: ['describe', 'context']
13
14
  Metrics/MethodLength:
14
15
  Max: 15
15
16
  Style/Documentation:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0 (2022-02-26)
4
+
5
+ ### New features
6
+
7
+ * [#12](https://github.com/sarslanoglu/turkish_cities/issues/12): Add city population data and ```find_by_population``` method
8
+
9
+ ### Changes
10
+
11
+ * [#103](https://github.com/sarslanoglu/turkish_cities/issues/103): Update city/district/subdistrict informations to 2022
12
+
13
+ ## 0.5.0 (2021-06-06)
14
+
15
+ ### New features
16
+
17
+ * [#68](https://github.com/sarslanoglu/turkish_cities/issues/68): Add localization for all method responses and errors
18
+
19
+ ## 0.4.0 (2021-04-25)
20
+
21
+ ### New features
22
+
23
+ * [#66](https://github.com/sarslanoglu/turkish_cities/issues/66): Add ```distance_between_land``` method for calculating land travel distances between cities
24
+
3
25
  ## 0.3.0 (2020-11-22)
4
26
 
5
27
  ### New features
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turkish_cities (0.3.0)
4
+ turkish_cities (0.6.0)
5
5
  i18n (>= 0.6.4, <= 2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.1)
11
- concurrent-ruby (1.1.6)
10
+ ast (2.4.2)
11
+ concurrent-ruby (1.1.9)
12
12
  coveralls (0.8.23)
13
13
  json (>= 1.8, < 3)
14
14
  simplecov (~> 0.16.1)
@@ -17,15 +17,15 @@ GEM
17
17
  tins (~> 1.6)
18
18
  diff-lcs (1.4.4)
19
19
  docile (1.3.2)
20
- i18n (1.8.5)
20
+ i18n (1.10.0)
21
21
  concurrent-ruby (~> 1.0)
22
22
  json (2.3.0)
23
- parallel (1.20.0)
24
- parser (2.7.2.0)
23
+ parallel (1.21.0)
24
+ parser (3.1.0.0)
25
25
  ast (~> 2.4.1)
26
- rainbow (3.0.0)
27
- regexp_parser (1.8.2)
28
- rexml (3.2.4)
26
+ rainbow (3.1.1)
27
+ regexp_parser (2.2.0)
28
+ rexml (3.2.5)
29
29
  rspec (3.10.0)
30
30
  rspec-core (~> 3.10.0)
31
31
  rspec-expectations (~> 3.10.0)
@@ -39,18 +39,18 @@ GEM
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
40
  rspec-support (~> 3.10.0)
41
41
  rspec-support (3.10.0)
42
- rubocop (1.3.1)
42
+ rubocop (1.25.0)
43
43
  parallel (~> 1.10)
44
- parser (>= 2.7.1.5)
44
+ parser (>= 3.1.0.0)
45
45
  rainbow (>= 2.2.2, < 4.0)
46
- regexp_parser (>= 1.8)
46
+ regexp_parser (>= 1.8, < 3.0)
47
47
  rexml
48
- rubocop-ast (>= 1.1.1)
48
+ rubocop-ast (>= 1.15.1, < 2.0)
49
49
  ruby-progressbar (~> 1.7)
50
- unicode-display_width (>= 1.4.0, < 2.0)
51
- rubocop-ast (1.1.1)
52
- parser (>= 2.7.1.5)
53
- ruby-progressbar (1.10.1)
50
+ unicode-display_width (>= 1.4.0, < 3.0)
51
+ rubocop-ast (1.15.1)
52
+ parser (>= 3.0.1.1)
53
+ ruby-progressbar (1.11.0)
54
54
  simplecov (0.16.1)
55
55
  docile (~> 1.1)
56
56
  json (>= 1.8, < 3)
@@ -62,17 +62,17 @@ GEM
62
62
  thor (1.0.1)
63
63
  tins (1.25.0)
64
64
  sync
65
- unicode-display_width (1.7.0)
65
+ unicode-display_width (2.1.0)
66
66
 
67
67
  PLATFORMS
68
68
  ruby
69
69
 
70
70
  DEPENDENCIES
71
- bundler (~> 2.1.4)
71
+ bundler (~> 2.2.16)
72
72
  coveralls (~> 0.8.23)
73
73
  rspec (~> 3.10.0)
74
- rubocop (~> 1.3.1)
74
+ rubocop (~> 1.25.0)
75
75
  turkish_cities!
76
76
 
77
77
  BUNDLED WITH
78
- 2.1.4
78
+ 2.2.16
data/README.md CHANGED
@@ -7,6 +7,8 @@
7
7
  <img src="https://travis-ci.org/sarslanoglu/turkish_cities.svg?branch=master" alt="BuildStatus"/></a>
8
8
  <a href="https://coveralls.io/github/sarslanoglu/turkish_cities?branch=master">
9
9
  <img src="https://coveralls.io/repos/github/sarslanoglu/turkish_cities/badge.svg?branch=master" alt="CoverageStatus"/></a>
10
+ <a href="https://rubygems.org/gems/turkish_cities">
11
+ <img src="https://img.shields.io/gem/dt/turkish_cities.svg" alt="DownloadCount"/></a>
10
12
  <a href="https://codeclimate.com/github/sarslanoglu/turkish_cities/maintainability">
11
13
  <img src="https://api.codeclimate.com/v1/badges/c1dbe0cef353b152956e/maintainability" alt="Maintainability"/></a>
12
14
  <a href="https://houndci.com">
@@ -20,6 +22,7 @@ https://rubygems.org/gems/turkish_cities
20
22
 
21
23
  ## Table of Contents
22
24
  * [Installation](#installation)
25
+ * [Localization](#localization)
23
26
  * [Documentation](#documentation)
24
27
  * [Finding city name by plate number](#finding-city-name-by-plate-number)
25
28
  * [Finding city name by phone code](#finding-city-name-by-phone-code)
@@ -34,7 +37,13 @@ https://rubygems.org/gems/turkish_cities
34
37
  * [With subdistrict info](#with-subdistrict-info)
35
38
  * [Without subdistrict info](#without-subdistrict-info)
36
39
  * [Finding city, district and subdistrict name by postcode](#finding-city-district-and-subdistrict-name-by-postcode)
40
+ * [Finding city name with population data](#finding-city-name-with-population-data)
41
+ * [Exact search](#exact-search)
42
+ * [Below given](#below-given)
43
+ * [Above given](#above-given)
44
+ * [Between search](#between-search)
37
45
  * [Finding travel distance and time estimation between two cities](#finding-travel-distance-and-time-estimation-between-two-cities)
46
+ * [By land](#by-land)
38
47
  * [By air](#by-air)
39
48
  * [Data sources](#data-sources)
40
49
  * [Compatibility](#compatibility)
@@ -62,6 +71,24 @@ and run
62
71
  $ bundle
63
72
  ```
64
73
 
74
+ ## Localization
75
+
76
+ Currently gem supports two different languages, Turkish and English. English is default, if no action taken.
77
+
78
+ Language can be easily changed by ```change_locale``` method. Valid parameters are 'tr' for Turkish and 'en' for English.
79
+
80
+ ```rb
81
+ TurkishCities.change_locale('tr') # => "Dil Türkçe olarak ayarlandı."
82
+ ```
83
+
84
+ After changing language all errors and result sets will be in desired language
85
+
86
+ ```rb
87
+ TurkishCities.list_districts('Eskişehirrr') # => "'Eskişehirrr' ile bir şehir bulunamadı"
88
+ TurkishCities.distance_between('kirsehir', 'Ordu', 'land')
89
+ # => [533, "Kırşehir ile Ordu arasındaki karayolu mesafesi 533 km"]
90
+ ```
91
+
65
92
  ## Documentation
66
93
 
67
94
  With using irb just require gem and start using
@@ -85,7 +112,7 @@ TurkishCities.find_name_by_plate_number(100) # => 'Given value [100] is outside
85
112
 
86
113
  ### Finding city name by phone code
87
114
 
88
- There are 81 cities in Turkey. By calling a phone code between 212-488 will give city_name. All phone codes are even sending odd number will give error without searching.
115
+ There are 82 phone codes for each city in Turkey (Istanbul is an exception with different phone codes for Anatolian side and European side). By calling a phone code between 212-488 will give city_name. All phone codes ending with even numbers. So sending an odd number will give an error without searching.
89
116
 
90
117
  ```rb
91
118
  TurkishCities.find_name_by_phone_code(312) # => "Ankara"
@@ -135,7 +162,7 @@ TurkishCities.list_cities # => ["Adana", "Adıyaman" ... "Kilis", "Osmaniye", "D
135
162
 
136
163
  ### Listing all cities with only name
137
164
 
138
- While listing cities three additional parameters can be send ```alphabetically_sorted```, ```metropolitan_municipality``` and ```region```. All parameters can be send seperately and together.
165
+ While listing cities three additional parameters can be sent ```alphabetically_sorted```, ```metropolitan_municipality``` and ```region```. All parameters can be sent separately and together.
139
166
 
140
167
  ```rb
141
168
  TurkishCities.list_cities({ alphabetically_sorted: true })
@@ -154,7 +181,7 @@ TurkishCities.list_cities({ alphabetically_sorted: true, metropolitan_municipali
154
181
 
155
182
  ### Listing all cities with other parameters
156
183
 
157
- While listing cities ```with``` parameter can be used for listing cities with other attributes. These parameters are ```alphabetically_sorted```, ```metropolitan_municipality``` and ```region```. All parameters can be send seperately and together.
184
+ While listing cities ```with``` parameter can be used for listing cities with other attributes. These parameters are ```alphabetically_sorted```, ```metropolitan_municipality``` and ```region```. All parameters can be sent separately and together.
158
185
 
159
186
  ```rb
160
187
  TurkishCities.list_cities({ alphabetically_sorted: true, with: { phone_code: true } })
@@ -210,7 +237,7 @@ TurkishCities.list_subdistricts('İstanbul', 'Kadılarköyü')
210
237
 
211
238
  ### With subdistrict info
212
239
 
213
- City name can be given case and turkish character insensitive. District name and subdistrict name should be case and turkish character sensitive.(Correct district names can be obtained by ```list_districts``` method. Correct subdistrict names can be obtained by ```list_subdistricts``` method.) Listing of neighborhoods are alphabetically sorted.
240
+ City name can be given case and turkish character insensitive. District name and subdistrict name should be case and turkish character sensitive.(Correct district names can be obtained by the ```list_districts``` method. Correct subdistrict names can be obtained by ```list_subdistricts``` method.) Listings of neighborhoods are alphabetically sorted.
214
241
 
215
242
  ```rb
216
243
  TurkishCities.list_neighborhoods('Adana', 'Seyhan', 'Emek')
@@ -229,7 +256,7 @@ TurkishCities.list_neighborhoods('Eskişehir', 'Odunpazarı', 'Büyükkkkkdere')
229
256
 
230
257
  Also ```list_neighborhoods``` can work without subdistrict information. This time neighborhoods result will be larger based on searched city and district.
231
258
 
232
- City name can be given case and turkish character insensitive. District name should be case and turkish character sensitive.(Correct district names can be obtained by ```list_districts``` method.) Listing of neighborhoods are alphabetically sorted.
259
+ City name can be given case and turkish character insensitive. District name should be case and turkish character sensitive.(Correct district names can be obtained by the ```list_districts``` method.) Listings of neighborhoods are alphabetically sorted.
233
260
 
234
261
  ```rb
235
262
  TurkishCities.list_neighborhoods('Adana', 'Seyhan')
@@ -254,11 +281,102 @@ TurkishCities.find_by_postcode(34382) # => "Couldn't find any subdistrict wit
254
281
  TurkishCities.find_by_postcode('100000') # => Given value [100000] is outside bounds of 1010 to 81952.
255
282
  ```
256
283
 
284
+ ### Finding city name with population data
285
+
286
+ ### Exact search
287
+
288
+ Search city name with exact population
289
+
290
+ ```rb
291
+ TurkishCities.find_by_population('exact', 15840900)
292
+ # => ["İstanbul"]
293
+ TurkishCities.find_by_population('exatc', 2130432)
294
+ # => "Population type 'exatc' is unsupported"
295
+ TurkishCities.find_by_population('exact', 10432)
296
+ # => []
297
+ TurkishCities.find_by_population('exact', 22130432)
298
+ # => []
299
+ ```
300
+
301
+ ### Below given
302
+
303
+ Search city name with below population
304
+
305
+ ```rb
306
+ TurkishCities.find_by_population('below', 86000)
307
+ # => ["Tunceli", "Bayburt"]
308
+ TurkishCities.find_by_population('below', 500000)
309
+ # => ["Amasya", "Artvin" ... "Kilis", "Düzce"]
310
+ TurkishCities.find_by_population('below', 5000000)
311
+ # => ["Adana", "Adıyaman" ... "Kilis", "Osmaniye", "Düzce"]
312
+ TurkishCities.find_by_population('woleb', 2130432)
313
+ # => "Population type 'woleb' is unsupported"
314
+ TurkishCities.find_by_population('below', 10432)
315
+ # => []
316
+ TurkishCities.find_by_population('below', 22130432)
317
+ # => []
318
+ ```
319
+
320
+ ### Above given
321
+
322
+ Search city name with above population
323
+
324
+ ```rb
325
+ TurkishCities.find_by_population('above', 860000)
326
+ # => ["Adana", "Ankara" ... "Şanlıurfa", "Van"]
327
+ TurkishCities.find_by_population('above', 2500000)
328
+ # => ["Ankara", "Antalya", "Bursa", "İstanbul", "İzmir"]
329
+ TurkishCities.find_by_population('above', 5000000)
330
+ # => ["Ankara", "İstanbul"]
331
+ TurkishCities.find_by_population('abov', 2130432)
332
+ # => "Population type 'abov' is unsupported"
333
+ TurkishCities.find_by_population('above', 10432)
334
+ # => []
335
+ TurkishCities.find_by_population('above', 22130432)
336
+ # => []
337
+ ```
338
+
339
+ ### Between search
340
+
341
+ Search city name with between population
342
+
343
+ ```rb
344
+ TurkishCities.find_by_population('between', 15840900, 3000000)
345
+ # => ["Ankara", "Bursa", "İzmir"]
346
+ TurkishCities.find_by_population('between', 828369, 985732)
347
+ # => ["Eskişehir", "Mardin"]
348
+ TurkishCities.find_by_population('between', 2130432, 3500000)
349
+ # => ["Adana", "Antalya", "Bursa", "Konya", "Şanlıurfa"]
350
+ TurkishCities.find_by_population('between', 10432, 100000)
351
+ # => []
352
+ TurkishCities.find_by_population('between', 2130432, 34000000)
353
+ # => []
354
+ ```
355
+
257
356
  ### Finding travel distance and time estimation between two cities
258
357
 
358
+ ### By land
359
+
360
+ City names can be given case and turkish character insensitive. Travel method should be lower case. Array with 2 elements will be returned. First element is distance between cities in kilometers and the second element is the description created by the first element.
361
+
362
+ ```rb
363
+ TurkishCities.distance_between('Eskişehir', 'Kastamonu', 'land')
364
+ # => [480, "Land travel distance between Eskişehir and Kastamonu is 480 km."]
365
+ TurkishCities.distance_between('kirsehir', 'Ordu', 'land')
366
+ # => [533, "Land travel distance between Kırşehir and Ordu is 533 km."]
367
+ TurkishCities.distance_between('İzmir', 'Antalya', 'land')
368
+ # => [444, "Land travel distance between İzmir and Antalya is 444 km."]
369
+ TurkishCities.distance_between('istanbul', 'kars', 'land')
370
+ # => [1427, "Land travel distance between İstanbul and Kars is 1427 km."]
371
+ TurkishCities.distance_between('Adana', 'Adıyaman', 'time')
372
+ # => "Travel method 'time' is unsupported"
373
+ TurkishCities.distance_between('filansa', 'falansa', 'land')
374
+ # => "Couldn't find cities combination with 'filansa/falansa'"
375
+ ```
376
+
259
377
  ### By air
260
378
 
261
- City names can be given case and turkish character insensitive. Travel method should be lower case. Array with 3 elements will be return. First element is distance between cities in kilometers, second element is estimated travel time and last element is description created by first two element.
379
+ City names can be given case and turkish character insensitive. Travel method should be lower case. Array with 3 elements will be returned. First element is distance between cities in kilometers, the second element is estimated travel time and the last element is the description created by the first two elements.
262
380
 
263
381
  ```rb
264
382
  TurkishCities.distance_between('Eskişehir', 'Kastamonu', 'air')
@@ -283,29 +401,41 @@ All information related with cities can be found at:
283
401
  https://tr.wikipedia.org/wiki/{#city_name_here}
284
402
  ```
285
403
 
286
- Districts, subdisctricts, neighborhoods and postcodes can be found at:
404
+ Districts, subdisctricts, neighborhoods and postcodes information can be found at:
287
405
 
288
406
  ```
289
407
  https://postakodu.ptt.gov.tr/
290
408
  ```
409
+ All districts/subdistricts are up to date at: 23 January 2022 with using PTT file released at 22 November 2021
410
+
411
+ Land distance information can be found at:
412
+
413
+ ```
414
+ https://www.kgm.gov.tr/SiteCollectionDocuments/KGMdocuments/Root/Uzakliklar/ilmesafe.xls
415
+ ```
416
+
417
+ Population of cities are up to date as 15 February 2022 as using February 2022 report of Türkiye İstatistik Kurumu (TÜİK) / Turkish Statistical Institute (TURKSTAT)
418
+
419
+ Statistics for gem can be found at:
420
+ ```
421
+ https://bestgems.org/gems/turkish_cities
422
+ ```
291
423
 
292
424
  ## Compatibility
293
425
 
294
426
  | Ruby Version | Supported |
295
427
  | ------------ | ------------------ |
296
- | 2.7.1 | :white_check_mark: |
297
- | 2.6.6 | :white_check_mark: |
298
- | 2.5.8 | :white_check_mark: |
428
+ | 2.7.x | :white_check_mark: |
429
+ | 2.6.x | :white_check_mark: |
430
+ | 2.5.x | :white_check_mark: |
299
431
  | < 2.5.1 | :x: |
300
432
 
301
433
  - TurkishCities heavily depends on ```:turkic``` case mapping support of Ruby string downcase method. Below Ruby version 2.5.1 some functions will run buggy/false or even won't run at all.
302
434
 
303
435
  ## Roadmap
304
436
 
305
- - Add missing land travel method
306
437
  - Add missing sea travel method
307
- - Add localization to gem
308
- - Refactor tests (seperate test suites with more edge case tests)
438
+ - Refactor tests (separate test suites with more edge case tests)
309
439
 
310
440
  ## Contributing
311
441
 
@@ -0,0 +1,19 @@
1
+ en:
2
+ description_text:
3
+ air_travel: "Air travel distance between %{first_city} and %{second_city} is %{distance} km. Estimated air travel would take %{duration} minutes"
4
+ land_travel: "Land travel distance between %{first_city} and %{second_city} is %{distance} km"
5
+ errors:
6
+ cities_not_found_error: "Couldn't find cities combination with '%{first}/%{second}'"
7
+ city_not_found_error: "Couldn't find city name with '%{input}'"
8
+ city_population_not_found_error: "Couldn't find any city with population data"
9
+ district_not_found_error: "Couldn't find district name with '%{district_input}' of '%{city_input}'"
10
+ not_even_input: "Given value [%{input}] must be an even number"
11
+ outside_bounds: "Given value [%{input}] is outside bounds of %{min} to %{max}"
12
+ postcode_not_found_error: "Couldn't find any subdistrict with postcode '%{postcode_input}'"
13
+ subdistrict_not_found_error: "Couldn't find subdistrict with '%{subdistrict_input}' of '%{district_input}'/'%{city_input}'"
14
+ unsupported_population_type: "Population type '%{input}' is unsupported"
15
+ unsupported_travel_method: "Travel method '%{input}' is unsupported"
16
+ language:
17
+ errors:
18
+ unsupported_language_code: "Unsupported language code. Please use 'tr' for Turkish, 'en' for English"
19
+ success: "Language set to English"
@@ -0,0 +1,19 @@
1
+ tr:
2
+ description_text:
3
+ air_travel: "%{first_city} ile %{second_city} arasındaki havayolu mesafesi %{distance} km. Tahmini uçuş süresi %{duration} dakikadır"
4
+ land_travel: "%{first_city} ile %{second_city} arasındaki karayolu mesafesi %{distance} km"
5
+ errors:
6
+ cities_not_found_error: "'%{first}/%{second}' ile şehir kombinasyonu bulunamadı"
7
+ city_not_found_error: "'%{input}' ile bir şehir bulunamadı"
8
+ city_population_not_found_error: "Verilen nüfus verisi ile şehir bulunamadı"
9
+ district_not_found_error: "'%{city_input}' şehrine ait '%{district_input}' ilçesi ile bir kayıt bulunamadı"
10
+ not_even_input: "Girilen değer [%{input}] çift sayı olmalı"
11
+ outside_bounds: "Girilen değer [%{input}] %{min} ile %{max} değerleri dışında"
12
+ postcode_not_found_error: "'%{postcode_input}' posta kodu ile kayıt bulunamadı"
13
+ subdistrict_not_found_error: "'%{subdistrict_input}' ile '%{district_input}'/'%{city_input}' ait bir kayıt bulunamdı"
14
+ unsupported_population_type: "'%{input}' ile arama methodu desteklenmiyor"
15
+ unsupported_travel_method: "'%{input}' yolculuk methodu desteklenmiyor"
16
+ language:
17
+ errors:
18
+ unsupported_language_code: "Desteklenmeyen dil kodu. Lütfen Türkçe için 'tr', İngilizce için 'en' kullanınız"
19
+ success: "Dil Türkçe olarak ayarlandı"
@@ -8,8 +8,6 @@ require_relative '../turkish_cities/helpers/decomposer_helper'
8
8
  class City
9
9
  include DecomposerHelper
10
10
 
11
- I18n.enforce_available_locales = false
12
-
13
11
  file_path = File.join(File.dirname(__FILE__), 'data/cities.yaml')
14
12
  CITY_LIST = YAML.load_file(file_path)
15
13
 
@@ -67,7 +65,7 @@ class City
67
65
  def check_phone_code(input)
68
66
  return if input.to_i.even?
69
67
 
70
- raise ArgumentError, "Given value [#{input}] must be an even number."
68
+ raise ArgumentError, I18n.t('errors.not_even_input', input: input)
71
69
  end
72
70
 
73
71
  def filter_metropolitan_municipalities(city_list)