turkish_cities 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/pull_request_template.md +38 -0
- data/.hound.yml +2 -2
- data/.rubocop.yml +1 -20
- data/CHANGELOG.md +11 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +18 -13
- data/README.md +22 -17
- data/lib/turkish_cities/district.rb +16 -8
- data/lib/turkish_cities/helpers/decomposer_helper.rb +4 -0
- data/lib/turkish_cities/version.rb +1 -1
- data/turkish_cities.gemspec +1 -1
- metadata +6 -4
- data/.older.rubocop.yml +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf40e5e9b493d00931c7cda7597941d09a589f18eacaace649659bbc3018324e
|
|
4
|
+
data.tar.gz: 25776268893ae75242c27025bfc581bb50a6aa77154fef88c4bd584434456e8b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d69c0c456c33731de3b9c02a63a90f18893d761c6fad0cf688fb0af350e9263411ef4f15fe5588732048b9d351491c80cbe023376ecf747fa80631fede07ddf
|
|
7
|
+
data.tar.gz: f4d429988cfc994842db241e3ae0e5440de8a6c8be09d691bdd5037492d73f95c7d347b9bb4c6a088e546c5e6b3083ef80dbe1dea7f81fb34a913410300556e4
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: "[BUG] - (Fill here)"
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. In terminal ```require 'turkish_cities'```
|
|
16
|
+
2. Call method ```'....'```
|
|
17
|
+
|
|
18
|
+
**Expected behavior**
|
|
19
|
+
A clear and concise description of what you expected to happen.
|
|
20
|
+
|
|
21
|
+
**Additional context**
|
|
22
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: "[FEAT] - (Fill here)"
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
### Related github issue for this PR
|
|
2
|
+
|
|
3
|
+
Resolves #001 <!--fill issue number-->
|
|
4
|
+
|
|
5
|
+
### Checklist
|
|
6
|
+
|
|
7
|
+
* [ ] I have performed a self-review of my own code
|
|
8
|
+
* [ ] I added comments, particularly in hard-to-understand areas
|
|
9
|
+
* [ ] I have made corresponding changes to the documentation `README.md`
|
|
10
|
+
* [ ] I added tests that prove my fix is effective or that my feature works
|
|
11
|
+
* [ ] `bundle exec rake` passes locally
|
|
12
|
+
* [ ] `rubocop` gives no error locally
|
|
13
|
+
* [ ] My PR title includes "WIP" or is [draft PR](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests) if work is in progress
|
|
14
|
+
|
|
15
|
+
### Description
|
|
16
|
+
|
|
17
|
+
<!-- Please include a summary of the change and which issue is fixed.
|
|
18
|
+
Please also include relevant motivation and context.
|
|
19
|
+
Guide questions:
|
|
20
|
+
- What changed, and why?
|
|
21
|
+
- What alternative solutions did you consider?
|
|
22
|
+
- What are the tradeoffs for your solution?
|
|
23
|
+
|
|
24
|
+
Include anything else we should know about. -->
|
|
25
|
+
|
|
26
|
+
### Type of change
|
|
27
|
+
|
|
28
|
+
<!-- Please delete options that are not relevant. -->
|
|
29
|
+
|
|
30
|
+
* Bug fix (non-breaking change which fixes an issue)
|
|
31
|
+
* New feature (non-breaking change which adds functionality)
|
|
32
|
+
* Breaking change (fix or feature that would cause existing functionality to not
|
|
33
|
+
work as expected)
|
|
34
|
+
* Documentation update
|
|
35
|
+
|
|
36
|
+
### Which tests are written for this PR? And what are the expected results for these tests?
|
|
37
|
+
|
|
38
|
+
<!-- Please describe the tests that you ran to verify your changes. -->
|
data/.hound.yml
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
rubocop:
|
|
2
|
-
version: 0.
|
|
3
|
-
config_file: .
|
|
2
|
+
version: 0.83.0
|
|
3
|
+
config_file: .rubocop.yml
|
data/.rubocop.yml
CHANGED
|
@@ -3,16 +3,9 @@ AllCops:
|
|
|
3
3
|
Exclude:
|
|
4
4
|
- 'Gemfile'
|
|
5
5
|
- 'turkish_cities.gemspec'
|
|
6
|
-
|
|
7
|
-
Enabled: true
|
|
6
|
+
NewCops: enable
|
|
8
7
|
Layout/LineLength:
|
|
9
8
|
Max: 100
|
|
10
|
-
Layout/SpaceAroundMethodCallOperator:
|
|
11
|
-
Enabled: true
|
|
12
|
-
Lint/RaiseException:
|
|
13
|
-
Enabled: true
|
|
14
|
-
Lint/StructNewOverride:
|
|
15
|
-
Enabled: true
|
|
16
9
|
Metrics/AbcSize:
|
|
17
10
|
Max: 20
|
|
18
11
|
Metrics/BlockLength:
|
|
@@ -21,15 +14,3 @@ Metrics/MethodLength:
|
|
|
21
14
|
Max: 15
|
|
22
15
|
Style/Documentation:
|
|
23
16
|
Enabled: false
|
|
24
|
-
Style/ExponentialNotation:
|
|
25
|
-
Enabled: true
|
|
26
|
-
Style/HashEachMethods:
|
|
27
|
-
Enabled: true
|
|
28
|
-
Style/HashTransformKeys:
|
|
29
|
-
Description: 'Prefer `transform_keys` over `each_with_object` and `map`.'
|
|
30
|
-
Enabled: true
|
|
31
|
-
Style/HashTransformValues:
|
|
32
|
-
Description: 'Prefer `transform_values` over `each_with_object` and `map`.'
|
|
33
|
-
Enabled: true
|
|
34
|
-
Style/SlicingWithRange:
|
|
35
|
-
Enabled: true
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 (2020-06-29)
|
|
4
|
+
|
|
5
|
+
### Bug fixes
|
|
6
|
+
|
|
7
|
+
* [#38](https://github.com/sarslanoglu/turkish_cities/issues/38): ```NoMethodError``` on ```list_neighborhoods``` when called with wrong subdistrict name
|
|
8
|
+
|
|
9
|
+
### Changes
|
|
10
|
+
|
|
11
|
+
* [#39](https://github.com/sarslanoglu/turkish_cities/issues/39): May maintenance of gem - 2020-05-24
|
|
12
|
+
|
|
3
13
|
## 0.2.0 (2020-05-18)
|
|
4
14
|
|
|
5
15
|
### New features
|
|
@@ -23,6 +33,7 @@
|
|
|
23
33
|
### New features
|
|
24
34
|
|
|
25
35
|
* [#22](https://github.com/sarslanoglu/turkish_cities/issues/22): Add region data to cities.yaml and update ```list_cities``` method to support regions
|
|
36
|
+
|
|
26
37
|
* [#20](https://github.com/sarslanoglu/turkish_cities/issues/20): Add city finding with phone code and vice versa. ```find_name_by_phone_code``` and ```find_phone_code_by_name``` methods are added
|
|
27
38
|
|
|
28
39
|
### Bug fixes
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
turkish_cities (0.1
|
|
4
|
+
turkish_cities (0.2.1)
|
|
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.
|
|
10
|
+
ast (2.4.1)
|
|
11
11
|
concurrent-ruby (1.1.6)
|
|
12
12
|
coveralls (0.8.23)
|
|
13
13
|
json (>= 1.8, < 3)
|
|
@@ -17,34 +17,39 @@ GEM
|
|
|
17
17
|
tins (~> 1.6)
|
|
18
18
|
diff-lcs (1.3)
|
|
19
19
|
docile (1.3.2)
|
|
20
|
-
i18n (1.8.
|
|
20
|
+
i18n (1.8.3)
|
|
21
21
|
concurrent-ruby (~> 1.0)
|
|
22
22
|
json (2.3.0)
|
|
23
|
-
parallel (1.19.
|
|
24
|
-
parser (2.7.1.
|
|
25
|
-
ast (~> 2.4.
|
|
23
|
+
parallel (1.19.2)
|
|
24
|
+
parser (2.7.1.4)
|
|
25
|
+
ast (~> 2.4.1)
|
|
26
26
|
rainbow (3.0.0)
|
|
27
|
+
regexp_parser (1.7.1)
|
|
27
28
|
rexml (3.2.4)
|
|
28
29
|
rspec (3.9.0)
|
|
29
30
|
rspec-core (~> 3.9.0)
|
|
30
31
|
rspec-expectations (~> 3.9.0)
|
|
31
32
|
rspec-mocks (~> 3.9.0)
|
|
32
|
-
rspec-core (3.9.
|
|
33
|
-
rspec-support (~> 3.9.
|
|
34
|
-
rspec-expectations (3.9.
|
|
33
|
+
rspec-core (3.9.2)
|
|
34
|
+
rspec-support (~> 3.9.3)
|
|
35
|
+
rspec-expectations (3.9.2)
|
|
35
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
36
37
|
rspec-support (~> 3.9.0)
|
|
37
38
|
rspec-mocks (3.9.1)
|
|
38
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
39
40
|
rspec-support (~> 3.9.0)
|
|
40
|
-
rspec-support (3.9.
|
|
41
|
-
rubocop (0.
|
|
41
|
+
rspec-support (3.9.3)
|
|
42
|
+
rubocop (0.86.0)
|
|
42
43
|
parallel (~> 1.10)
|
|
43
44
|
parser (>= 2.7.0.1)
|
|
44
45
|
rainbow (>= 2.2.2, < 4.0)
|
|
46
|
+
regexp_parser (>= 1.7)
|
|
45
47
|
rexml
|
|
48
|
+
rubocop-ast (>= 0.0.3, < 1.0)
|
|
46
49
|
ruby-progressbar (~> 1.7)
|
|
47
50
|
unicode-display_width (>= 1.4.0, < 2.0)
|
|
51
|
+
rubocop-ast (0.0.3)
|
|
52
|
+
parser (>= 2.7.0.1)
|
|
48
53
|
ruby-progressbar (1.10.1)
|
|
49
54
|
simplecov (0.16.1)
|
|
50
55
|
docile (~> 1.1)
|
|
@@ -55,7 +60,7 @@ GEM
|
|
|
55
60
|
term-ansicolor (1.7.1)
|
|
56
61
|
tins (~> 1.0)
|
|
57
62
|
thor (1.0.1)
|
|
58
|
-
tins (1.
|
|
63
|
+
tins (1.25.0)
|
|
59
64
|
sync
|
|
60
65
|
unicode-display_width (1.7.0)
|
|
61
66
|
|
|
@@ -66,7 +71,7 @@ DEPENDENCIES
|
|
|
66
71
|
bundler (~> 2.1.4)
|
|
67
72
|
coveralls (~> 0.8.23)
|
|
68
73
|
rspec (~> 3.9.0)
|
|
69
|
-
rubocop (~> 0.
|
|
74
|
+
rubocop (~> 0.86.0)
|
|
70
75
|
turkish_cities!
|
|
71
76
|
|
|
72
77
|
BUNDLED WITH
|
data/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* [Listing all subdistricts of given city and district](#listing-all-subdistricts-of-given-city-and-district)
|
|
24
24
|
* [Listing all neighborhoods of given city and district](#listing-all-neighborhoods-of-given-city-and-district)
|
|
25
25
|
* [With subdistrict info](#with-subdistrict-info)
|
|
26
|
-
* [Without subdistrict info](#
|
|
26
|
+
* [Without subdistrict info](#without-subdistrict-info)
|
|
27
27
|
* [Finding city, district and subdistrict name by postcode](#finding-city-district-and-subdistrict-name-by-postcode)
|
|
28
28
|
* [Compatibility](#compatibility)
|
|
29
29
|
* [Contributing](#contributing)
|
|
@@ -54,7 +54,7 @@ $ bundle
|
|
|
54
54
|
|
|
55
55
|
With using irb just require gem and start using
|
|
56
56
|
|
|
57
|
-
```
|
|
57
|
+
```rb
|
|
58
58
|
require 'turkish_cities'
|
|
59
59
|
```
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ require 'turkish_cities'
|
|
|
62
62
|
|
|
63
63
|
There are 81 cities in Turkey. By calling a plate number between 1-81 will give city_name.
|
|
64
64
|
|
|
65
|
-
```
|
|
65
|
+
```rb
|
|
66
66
|
TurkishCities.find_name_by_plate_number(26) # => "Eskişehir"
|
|
67
67
|
TurkishCities.find_name_by_plate_number(7) # => "Antalya"
|
|
68
68
|
TurkishCities.find_name_by_plate_number(0007) # => "Antalya"
|
|
@@ -75,7 +75,7 @@ TurkishCities.find_name_by_plate_number(100) # => 'Given value [100] is outside
|
|
|
75
75
|
|
|
76
76
|
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.
|
|
77
77
|
|
|
78
|
-
```
|
|
78
|
+
```rb
|
|
79
79
|
TurkishCities.find_name_by_phone_code(312) # => "Ankara"
|
|
80
80
|
TurkishCities.find_name_by_phone_code(242) # => "Antalya"
|
|
81
81
|
TurkishCities.find_name_by_phone_code(000222) # => "Eskişehir"
|
|
@@ -91,7 +91,7 @@ TurkishCities.find_name_by_phone_code(213) # => 'Given value [213] must be an
|
|
|
91
91
|
|
|
92
92
|
City name can be given case and turkish character insensitive.
|
|
93
93
|
|
|
94
|
-
```
|
|
94
|
+
```rb
|
|
95
95
|
TurkishCities.find_plate_number_by_name('Ankara') # => 6
|
|
96
96
|
TurkishCities.find_plate_number_by_name('Eskişehir') # => 26
|
|
97
97
|
TurkishCities.find_plate_number_by_name('Canakkale') # => 17
|
|
@@ -104,7 +104,7 @@ TurkishCities.find_plate_number_by_name('falansehir') # => "Couldn't find city n
|
|
|
104
104
|
|
|
105
105
|
City name can be given case and turkish character insensitive.
|
|
106
106
|
|
|
107
|
-
```
|
|
107
|
+
```rb
|
|
108
108
|
TurkishCities.find_phone_code_by_name('Ankara') # => 312
|
|
109
109
|
TurkishCities.find_phone_code_by_name('Eskişehir') # => 222
|
|
110
110
|
TurkishCities.find_phone_code_by_name('Canakkale') # => 286
|
|
@@ -117,7 +117,7 @@ TurkishCities.find_phone_code_by_name('filansehir') # => "Couldn't find city nam
|
|
|
117
117
|
|
|
118
118
|
By default cities will be listed by their plate number ascending.
|
|
119
119
|
|
|
120
|
-
```
|
|
120
|
+
```rb
|
|
121
121
|
TurkishCities.list_cities # => ["Adana", "Adıyaman" ... "Kilis", "Osmaniye", "Düzce"]
|
|
122
122
|
```
|
|
123
123
|
|
|
@@ -125,7 +125,7 @@ TurkishCities.list_cities # => ["Adana", "Adıyaman" ... "Kilis", "Osmaniye", "D
|
|
|
125
125
|
|
|
126
126
|
While listing cities three additional parameters can be send ```alphabetically_sorted```, ```metropolitan_municipality``` and ```region```. All parameters can be send seperately and together.
|
|
127
127
|
|
|
128
|
-
```
|
|
128
|
+
```rb
|
|
129
129
|
TurkishCities.list_cities({ alphabetically_sorted: true })
|
|
130
130
|
# => ["Adana", "Adıyaman" ... "Yalova", "Yozgat", "Zonguldak"]
|
|
131
131
|
TurkishCities.list_cities({ metropolitan_municipality: true })
|
|
@@ -144,7 +144,7 @@ TurkishCities.list_cities({ alphabetically_sorted: true, metropolitan_municipali
|
|
|
144
144
|
|
|
145
145
|
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.
|
|
146
146
|
|
|
147
|
-
```
|
|
147
|
+
```rb
|
|
148
148
|
TurkishCities.list_cities({ alphabetically_sorted: true, with: { phone_code: true } })
|
|
149
149
|
# => [{:name=>"Adana", :phone_code=>322}, {:name=>"Adıyaman", :phone_code=>416}, {:name=>"Afyon", :phone_code=>272} .
|
|
150
150
|
# .. {:name=>"Yozgat", :phone_code=>354}, {:name=>"Zonguldak", :phone_code=>372}]
|
|
@@ -162,7 +162,7 @@ TurkishCities.list_cities({ metropolitan_municipality: true, region: 'Karadeniz'
|
|
|
162
162
|
|
|
163
163
|
City name can be given case and turkish character insensitive. Listing of districts are alphabetically sorted.
|
|
164
164
|
|
|
165
|
-
```
|
|
165
|
+
```rb
|
|
166
166
|
TurkishCities.list_districts('Ankara')
|
|
167
167
|
# => ["Akyurt", "Altındağ" ... "Sincan", "Şereflikoçhisar", "Yenimahalle"]
|
|
168
168
|
TurkishCities.list_districts('Eskişehir')
|
|
@@ -181,7 +181,7 @@ TurkishCities.list_districts('filansehir')
|
|
|
181
181
|
|
|
182
182
|
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 subdistricts are alphabetically sorted.
|
|
183
183
|
|
|
184
|
-
```
|
|
184
|
+
```rb
|
|
185
185
|
TurkishCities.list_subdistricts('Adana', 'Seyhan')
|
|
186
186
|
# => ["Akkapı", "Denizli" ... "Yeşiloba", "Yeşilyurt", "Ziyapaşa"]
|
|
187
187
|
TurkishCities.list_subdistricts('Eskişehir', 'Odunpazarı')
|
|
@@ -200,7 +200,7 @@ TurkishCities.list_subdistricts('İstanbul', 'Kadılarköyü')
|
|
|
200
200
|
|
|
201
201
|
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.
|
|
202
202
|
|
|
203
|
-
```
|
|
203
|
+
```rb
|
|
204
204
|
TurkishCities.list_neighborhoods('Adana', 'Seyhan', 'Emek')
|
|
205
205
|
# => ["Emek Mah", "Ova Mah", "Şakirpaşa Mah", "Uçak Mah"]
|
|
206
206
|
TurkishCities.list_neighborhoods('Eskişehir', 'Odunpazarı', 'Büyükdere')
|
|
@@ -209,6 +209,8 @@ TurkishCities.list_neighborhoods('Istanbul', 'Beşiktaş', 'Gayrettepe')
|
|
|
209
209
|
# => ["Balmumcu Mah", "Dikilitaş Mah", "Gayrettepe Mah", "Yıldız Mah"]
|
|
210
210
|
TurkishCities.list_neighborhoods('Adana', 'Beşiktaş', 'Emek')
|
|
211
211
|
# => "Couldn't find district name with 'Beşiktaş' of 'Adana'"
|
|
212
|
+
TurkishCities.list_neighborhoods('Eskişehir', 'Odunpazarı', 'Büyükkkkkdere')
|
|
213
|
+
# => "Couldn't find subdistrict with 'Büyükkkkkdere' of 'Odunpazarı'/'Eskişehir'"
|
|
212
214
|
```
|
|
213
215
|
|
|
214
216
|
### Without subdistrict info
|
|
@@ -217,7 +219,7 @@ Also ```list_neighborhoods``` can work without subdistrict information. This tim
|
|
|
217
219
|
|
|
218
220
|
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.
|
|
219
221
|
|
|
220
|
-
```
|
|
222
|
+
```rb
|
|
221
223
|
TurkishCities.list_neighborhoods('Adana', 'Seyhan')
|
|
222
224
|
# => ["2000 Evler Mah", "Ahmet Remzi Yüreğir Mah", "Akkapı Mah" ... "Zeytinli Mah", "Ziyapaşa Mah"]
|
|
223
225
|
TurkishCities.list_neighborhoods('Eskişehir', 'Odunpazarı')
|
|
@@ -232,7 +234,7 @@ TurkishCities.list_neighborhoods('İstanbul', 'filanmevki')
|
|
|
232
234
|
|
|
233
235
|
In Turkey postcodes are uniq for subdistricts. Basically when a postcode is search through ```find_by_postcode``` it will give city, district and subdistrict information of postcode if valid and found
|
|
234
236
|
|
|
235
|
-
```
|
|
237
|
+
```rb
|
|
236
238
|
TurkishCities.find_by_postcode(34380) # => ["İstanbul", "Şişli", "Cumhuriyet"]
|
|
237
239
|
TurkishCities.find_by_postcode(34433) # => ["İstanbul", "Beyoğlu", "Cihangir"]
|
|
238
240
|
TurkishCities.find_by_postcode('26040') # => ["Eskişehir", "Odunpazarı", "Büyükdere"]
|
|
@@ -242,9 +244,12 @@ TurkishCities.find_by_postcode('100000') # => Given value [100000] is outside bo
|
|
|
242
244
|
|
|
243
245
|
## Compatibility
|
|
244
246
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
| Ruby Version | Supported |
|
|
248
|
+
| ------------ | ------------------ |
|
|
249
|
+
| 2.7.1 | :white_check_mark: |
|
|
250
|
+
| 2.6.6 | :white_check_mark: |
|
|
251
|
+
| 2.5.8 | :white_check_mark: |
|
|
252
|
+
| < 2.5.1 | :x: |
|
|
248
253
|
|
|
249
254
|
- This gem 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.
|
|
250
255
|
|
|
@@ -26,14 +26,10 @@ class District
|
|
|
26
26
|
district_list = create_district_list(city_name)
|
|
27
27
|
|
|
28
28
|
if !district_list[district_name].nil?
|
|
29
|
-
neighborhoods =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
district_name,
|
|
34
|
-
subdistrict_name)
|
|
35
|
-
end
|
|
36
|
-
sort_alphabetically(neighborhoods)
|
|
29
|
+
neighborhoods = create_neighborhoods(district_list, city_name,
|
|
30
|
+
district_name, subdistrict_name)
|
|
31
|
+
|
|
32
|
+
neighborhoods.is_a?(Array) ? sort_alphabetically(neighborhoods) : neighborhoods
|
|
37
33
|
else
|
|
38
34
|
district_not_found_error(district_name, city_name)
|
|
39
35
|
end
|
|
@@ -41,6 +37,18 @@ class District
|
|
|
41
37
|
|
|
42
38
|
private
|
|
43
39
|
|
|
40
|
+
def create_neighborhoods(district_list, city_name, district_name, subdistrict_name)
|
|
41
|
+
if subdistrict_name.nil?
|
|
42
|
+
create_neighborhoods_without_subdistrict_name(district_list, district_name)
|
|
43
|
+
else
|
|
44
|
+
if district_list[district_name][subdistrict_name].nil?
|
|
45
|
+
return subdistrict_not_found_error(subdistrict_name, district_name, city_name)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
create_neighborhoods_with_subdistrict_name(district_list, district_name, subdistrict_name)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
44
52
|
def create_neighborhoods_without_subdistrict_name(district_list, district_name)
|
|
45
53
|
neighborhoods = []
|
|
46
54
|
district_list[district_name].each do |subdistrict|
|
|
@@ -70,6 +70,10 @@ module DecomposerHelper
|
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
+
def subdistrict_not_found_error(subdistrict_input, district_input, city_input)
|
|
74
|
+
"Couldn't find subdistrict with '#{subdistrict_input}' of '#{district_input}'/'#{city_input}'"
|
|
75
|
+
end
|
|
76
|
+
|
|
73
77
|
private
|
|
74
78
|
|
|
75
79
|
def add_plate_number_if_requested(result, city, options = nil)
|
data/turkish_cities.gemspec
CHANGED
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
|
24
24
|
s.add_development_dependency 'bundler', '~> 2.1.4'
|
|
25
25
|
s.add_development_dependency 'coveralls', '~> 0.8.23'
|
|
26
26
|
s.add_development_dependency 'rspec', '~> 3.9.0'
|
|
27
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
|
27
|
+
s.add_development_dependency 'rubocop', '~> 0.86.0'
|
|
28
28
|
|
|
29
29
|
if s.respond_to?(:metadata)
|
|
30
30
|
s.metadata['changelog_uri'] = 'https://github.com/sarslanoglu/turkish_cities/blob/master/CHANGELOG.md'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: turkish_cities
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Semih Arslanoglu
|
|
@@ -78,14 +78,14 @@ dependencies:
|
|
|
78
78
|
requirements:
|
|
79
79
|
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 0.
|
|
81
|
+
version: 0.86.0
|
|
82
82
|
type: :development
|
|
83
83
|
prerelease: false
|
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.
|
|
88
|
+
version: 0.86.0
|
|
89
89
|
description: Simple ruby gem for listing and finding Turkish cities via name, plate
|
|
90
90
|
number or size
|
|
91
91
|
email: arslanoglusemih93@gmail.com
|
|
@@ -94,9 +94,11 @@ extensions: []
|
|
|
94
94
|
extra_rdoc_files: []
|
|
95
95
|
files:
|
|
96
96
|
- ".codeclimate.yml"
|
|
97
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
|
98
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
|
99
|
+
- ".github/pull_request_template.md"
|
|
97
100
|
- ".gitignore"
|
|
98
101
|
- ".hound.yml"
|
|
99
|
-
- ".older.rubocop.yml"
|
|
100
102
|
- ".rspec"
|
|
101
103
|
- ".rubocop.yml"
|
|
102
104
|
- ".travis.yml"
|
data/.older.rubocop.yml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
TargetRubyVersion: 2.5.1
|
|
3
|
-
Exclude:
|
|
4
|
-
- 'Gemfile'
|
|
5
|
-
- 'turkish_cities.gemspec'
|
|
6
|
-
Layout/LineLength:
|
|
7
|
-
Max: 100
|
|
8
|
-
Metrics/AbcSize:
|
|
9
|
-
Max: 20
|
|
10
|
-
Metrics/BlockLength:
|
|
11
|
-
ExcludedMethods: ['describe', 'context']
|
|
12
|
-
Metrics/MethodLength:
|
|
13
|
-
Max: 15
|
|
14
|
-
Style/Documentation:
|
|
15
|
-
Enabled: false
|
|
16
|
-
Style/HashEachMethods:
|
|
17
|
-
Enabled: true
|
|
18
|
-
Style/HashTransformKeys:
|
|
19
|
-
Description: 'Prefer `transform_keys` over `each_with_object` and `map`.'
|
|
20
|
-
Enabled: true
|
|
21
|
-
Style/HashTransformValues:
|
|
22
|
-
Description: 'Prefer `transform_values` over `each_with_object` and `map`.'
|
|
23
|
-
Enabled: true
|