turkish_cities 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +34 -0
- data/.github/workflows/ruby.yml +39 -0
- data/.hound.yml +1 -1
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +26 -0
- data/Gemfile.lock +38 -46
- data/README.md +301 -30
- data/Rakefile +11 -0
- data/{config → lib/config}/locales/en.yml +3 -0
- data/{config → lib/config}/locales/tr.yml +3 -0
- data/lib/turkish_cities/data/cities.yaml +243 -0
- data/lib/turkish_cities/data/districts/adana.yaml +1 -1
- data/lib/turkish_cities/data/districts/adiyaman.yaml +184 -176
- data/lib/turkish_cities/data/districts/afyon.yaml +295 -189
- data/lib/turkish_cities/data/districts/agri.yaml +28 -28
- data/lib/turkish_cities/data/districts/aksaray.yaml +90 -61
- data/lib/turkish_cities/data/districts/amasya.yaml +17 -6
- data/lib/turkish_cities/data/districts/ankara.yaml +22 -22
- data/lib/turkish_cities/data/districts/antalya.yaml +3 -3
- data/lib/turkish_cities/data/districts/ardahan.yaml +10 -7
- data/lib/turkish_cities/data/districts/artvin.yaml +0 -60
- data/lib/turkish_cities/data/districts/bartin.yaml +23 -19
- data/lib/turkish_cities/data/districts/batman.yaml +45 -28
- data/lib/turkish_cities/data/districts/bayburt.yaml +12 -6
- data/lib/turkish_cities/data/districts/bilecik.yaml +18 -14
- data/lib/turkish_cities/data/districts/bingol.yaml +29 -35
- data/lib/turkish_cities/data/districts/bitlis.yaml +56 -43
- data/lib/turkish_cities/data/districts/bolu.yaml +34 -58
- data/lib/turkish_cities/data/districts/burdur.yaml +22 -16
- data/lib/turkish_cities/data/districts/bursa.yaml +3 -2
- data/lib/turkish_cities/data/districts/canakkale.yaml +46 -47
- data/lib/turkish_cities/data/districts/cankiri.yaml +23 -18
- data/lib/turkish_cities/data/districts/corum.yaml +25 -15
- data/lib/turkish_cities/data/districts/denizli.yaml +1 -1
- data/lib/turkish_cities/data/districts/diyarbakir.yaml +6 -6
- data/lib/turkish_cities/data/districts/duzce.yaml +83 -74
- data/lib/turkish_cities/data/districts/edirne.yaml +37 -23
- data/lib/turkish_cities/data/districts/elazig.yaml +74 -54
- data/lib/turkish_cities/data/districts/erzincan.yaml +47 -38
- data/lib/turkish_cities/data/districts/erzurum.yaml +1 -1
- data/lib/turkish_cities/data/districts/giresun.yaml +125 -57
- data/lib/turkish_cities/data/districts/gumushane.yaml +61 -81
- data/lib/turkish_cities/data/districts/hakkari.yaml +22 -15
- data/lib/turkish_cities/data/districts/hatay.yaml +1 -1
- data/lib/turkish_cities/data/districts/igdir.yaml +20 -11
- data/lib/turkish_cities/data/districts/isparta.yaml +67 -40
- data/lib/turkish_cities/data/districts/istanbul.yaml +12 -12
- data/lib/turkish_cities/data/districts/izmir.yaml +12 -12
- data/lib/turkish_cities/data/districts/kahramanmaras.yaml +3 -2
- data/lib/turkish_cities/data/districts/karabuk.yaml +15 -28
- data/lib/turkish_cities/data/districts/karaman.yaml +36 -31
- data/lib/turkish_cities/data/districts/kars.yaml +5 -4
- data/lib/turkish_cities/data/districts/kastamonu.yaml +3 -29
- data/lib/turkish_cities/data/districts/kayseri.yaml +8 -8
- data/lib/turkish_cities/data/districts/kilis.yaml +3 -2
- data/lib/turkish_cities/data/districts/kirikkale.yaml +17 -13
- data/lib/turkish_cities/data/districts/kirklareli.yaml +63 -45
- data/lib/turkish_cities/data/districts/kirsehir.yaml +25 -16
- data/lib/turkish_cities/data/districts/kocaeli.yaml +1 -1
- data/lib/turkish_cities/data/districts/konya.yaml +7 -8
- data/lib/turkish_cities/data/districts/kutahya.yaml +104 -72
- data/lib/turkish_cities/data/districts/malatya.yaml +1 -1
- data/lib/turkish_cities/data/districts/manisa.yaml +2 -2
- data/lib/turkish_cities/data/districts/mersin.yaml +4 -4
- data/lib/turkish_cities/data/districts/mus.yaml +118 -74
- data/lib/turkish_cities/data/districts/nevsehir.yaml +51 -43
- data/lib/turkish_cities/data/districts/nigde.yaml +135 -76
- data/lib/turkish_cities/data/districts/ordu.yaml +3 -3
- data/lib/turkish_cities/data/districts/osmaniye.yaml +53 -32
- data/lib/turkish_cities/data/districts/rize.yaml +68 -46
- data/lib/turkish_cities/data/districts/sakarya.yaml +2 -2
- data/lib/turkish_cities/data/districts/samsun.yaml +3 -3
- data/lib/turkish_cities/data/districts/sanliurfa.yaml +7 -7
- data/lib/turkish_cities/data/districts/siirt.yaml +27 -13
- data/lib/turkish_cities/data/districts/sinop.yaml +1 -5
- data/lib/turkish_cities/data/districts/sirnak.yaml +78 -40
- data/lib/turkish_cities/data/districts/sivas.yaml +49 -52
- data/lib/turkish_cities/data/districts/tekirdag.yaml +7 -2
- data/lib/turkish_cities/data/districts/tokat.yaml +201 -138
- data/lib/turkish_cities/data/districts/trabzon.yaml +1 -0
- data/lib/turkish_cities/data/districts/tunceli.yaml +13 -9
- data/lib/turkish_cities/data/districts/usak.yaml +40 -24
- data/lib/turkish_cities/data/districts/van.yaml +6 -4
- data/lib/turkish_cities/data/districts/yalova.yaml +45 -21
- data/lib/turkish_cities/data/districts/yozgat.yaml +147 -80
- data/lib/turkish_cities/data/districts/zonguldak.yaml +127 -90
- data/lib/turkish_cities/data/neighborhoods_parser.rb +3 -3
- data/lib/turkish_cities/elevation.rb +42 -0
- data/lib/turkish_cities/helpers/decomposer_helper.rb +28 -0
- data/lib/turkish_cities/population.rb +60 -0
- data/lib/turkish_cities/version.rb +1 -1
- data/lib/turkish_cities.rb +12 -1
- data/turkish_cities.gemspec +4 -3
- metadata +31 -13
- data/.travis.yml +0 -21
@@ -11,6 +11,10 @@ module DecomposerHelper
|
|
11
11
|
I18n.t('errors.city_not_found_error', input: input)
|
12
12
|
end
|
13
13
|
|
14
|
+
def city_population_not_found_error
|
15
|
+
I18n.t('errors.city_population_not_found_error')
|
16
|
+
end
|
17
|
+
|
14
18
|
def cities_not_found_error(first, second)
|
15
19
|
I18n.t('errors.cities_not_found_error', first: first, second: second)
|
16
20
|
end
|
@@ -38,6 +42,14 @@ module DecomposerHelper
|
|
38
42
|
I18n.t('errors.district_not_found_error', district_input: district_input, city_input: city_input)
|
39
43
|
end
|
40
44
|
|
45
|
+
def find_by_between(search_type, city_list, input_one, input_two)
|
46
|
+
sorted_inputs = sort_input_numbers(input_one, input_two)
|
47
|
+
|
48
|
+
city_list.map do |city|
|
49
|
+
city['name'] if city[search_type] > sorted_inputs[0] && city[search_type] < sorted_inputs[1]
|
50
|
+
end.compact
|
51
|
+
end
|
52
|
+
|
41
53
|
def postcode_not_found_error(postcode_input)
|
42
54
|
I18n.t('errors.postcode_not_found_error', postcode_input: postcode_input)
|
43
55
|
end
|
@@ -75,6 +87,14 @@ module DecomposerHelper
|
|
75
87
|
end
|
76
88
|
end
|
77
89
|
|
90
|
+
def sort_input_numbers(input_one, input_two)
|
91
|
+
if input_one > input_two
|
92
|
+
[input_two, input_one]
|
93
|
+
else
|
94
|
+
[input_one, input_two]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
78
98
|
def subdistrict_not_found_error(subdistrict_input, district_input, city_input)
|
79
99
|
I18n.t('errors.subdistrict_not_found_error', subdistrict_input: subdistrict_input, district_input: district_input,
|
80
100
|
city_input: city_input)
|
@@ -100,6 +120,14 @@ module DecomposerHelper
|
|
100
120
|
result[:metropolitan_municipality_since] = city['metropolitan_municipality_since']
|
101
121
|
end
|
102
122
|
|
123
|
+
def unsupported_elevation_type(input)
|
124
|
+
raise ArgumentError, I18n.t('errors.unsupported_elevation_type', input: input)
|
125
|
+
end
|
126
|
+
|
127
|
+
def unsupported_population_type(input)
|
128
|
+
I18n.t('errors.unsupported_population_type', input: input)
|
129
|
+
end
|
130
|
+
|
103
131
|
def unsupported_travel_method(input)
|
104
132
|
I18n.t('errors.unsupported_travel_method', input: input)
|
105
133
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'i18n'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
require_relative '../turkish_cities/helpers/decomposer_helper'
|
7
|
+
|
8
|
+
class Population
|
9
|
+
include DecomposerHelper
|
10
|
+
|
11
|
+
file_path = File.join(File.dirname(__FILE__), 'data/cities.yaml')
|
12
|
+
CITY_LIST = YAML.load_file(file_path)
|
13
|
+
|
14
|
+
MIN_POPULATION = 83_644
|
15
|
+
MAX_POPULATION = 15_840_901
|
16
|
+
|
17
|
+
def find_by_population(type, population_one, population_two = nil)
|
18
|
+
result = find_population(type, population_one, population_two)
|
19
|
+
|
20
|
+
result.length.positive? ? result : city_population_not_found_error
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def find_population(type, population_one, population_two)
|
26
|
+
city_list = CITY_LIST
|
27
|
+
|
28
|
+
case type
|
29
|
+
when 'exact'
|
30
|
+
check_input_range(population_one, self.class::MIN_POPULATION, self.class::MAX_POPULATION)
|
31
|
+
exact_population(city_list, population_one)
|
32
|
+
when 'below'
|
33
|
+
check_input_range(population_one, self.class::MIN_POPULATION, Float::INFINITY)
|
34
|
+
below_population(city_list, population_one)
|
35
|
+
when 'above'
|
36
|
+
check_input_range(population_one, 0, self.class::MAX_POPULATION)
|
37
|
+
above_population(city_list, population_one)
|
38
|
+
when 'between'
|
39
|
+
between_population(city_list, population_one.to_i, population_two.to_i)
|
40
|
+
else
|
41
|
+
unsupported_population_type(type)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def exact_population(city_list, population)
|
46
|
+
city_list.map { |city| city['name'] if city['population'] == population }.compact
|
47
|
+
end
|
48
|
+
|
49
|
+
def below_population(city_list, population)
|
50
|
+
city_list.map { |city| city['name'] if city['population'] < population }.compact
|
51
|
+
end
|
52
|
+
|
53
|
+
def above_population(city_list, population)
|
54
|
+
city_list.map { |city| city['name'] if city['population'] > population }.compact
|
55
|
+
end
|
56
|
+
|
57
|
+
def between_population(city_list, population_one, population_two)
|
58
|
+
find_by_between('population', city_list, population_one, population_two)
|
59
|
+
end
|
60
|
+
end
|
data/lib/turkish_cities.rb
CHANGED
@@ -3,12 +3,15 @@
|
|
3
3
|
require_relative '../lib/turkish_cities/city'
|
4
4
|
require_relative '../lib/turkish_cities/distance'
|
5
5
|
require_relative '../lib/turkish_cities/district'
|
6
|
+
require_relative '../lib/turkish_cities/elevation'
|
7
|
+
require_relative '../lib/turkish_cities/population'
|
6
8
|
require_relative '../lib/turkish_cities/postcode'
|
7
9
|
require_relative '../lib/turkish_cities/version'
|
8
10
|
|
9
11
|
require 'i18n'
|
10
12
|
|
11
|
-
I18n.load_path <<
|
13
|
+
I18n.load_path << "#{File.dirname(__FILE__)}/config/locales/en.yml"
|
14
|
+
I18n.load_path << "#{File.dirname(__FILE__)}/config/locales/tr.yml"
|
12
15
|
|
13
16
|
class TurkishCities
|
14
17
|
PLATE_NUMBER = 'plate_number'
|
@@ -58,6 +61,14 @@ class TurkishCities
|
|
58
61
|
District.new(city_name, district_name).neighborhoods(subdistrict_name)
|
59
62
|
end
|
60
63
|
|
64
|
+
def self.find_by_elevation(type, elevation_one, elevation_two = nil)
|
65
|
+
Elevation.new.find_by_elevation(type, elevation_one, elevation_two)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.find_by_population(type, population_one, population_two = nil)
|
69
|
+
Population.new.find_by_population(type, population_one, population_two)
|
70
|
+
end
|
71
|
+
|
61
72
|
def self.find_by_postcode(postcode)
|
62
73
|
Postcode.new.find_by_postcode(postcode)
|
63
74
|
end
|
data/turkish_cities.gemspec
CHANGED
@@ -21,9 +21,10 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency 'i18n', ['>= 0.6.4', '<= 2']
|
22
22
|
|
23
23
|
s.add_development_dependency 'bundler', '~> 2.2.16'
|
24
|
-
s.add_development_dependency '
|
25
|
-
s.add_development_dependency '
|
26
|
-
s.add_development_dependency '
|
24
|
+
s.add_development_dependency 'codecov', '~> 0.6.0'
|
25
|
+
s.add_development_dependency 'rake', '~> 13.0.6'
|
26
|
+
s.add_development_dependency 'rspec', '~> 3.11.0'
|
27
|
+
s.add_development_dependency 'rubocop', '~> 1.27.0'
|
27
28
|
|
28
29
|
if s.respond_to?(:metadata)
|
29
30
|
s.metadata['changelog_uri'] = 'https://github.com/sarslanoglu/turkish_cities/blob/master/CHANGELOG.md'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turkish_cities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Semih Arslanoglu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -45,47 +45,61 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 2.2.16
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: codecov
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
53
|
+
version: 0.6.0
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.
|
60
|
+
version: 0.6.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 13.0.6
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 13.0.6
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: rspec
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
79
|
- - "~>"
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version: 3.
|
81
|
+
version: 3.11.0
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version: 3.
|
88
|
+
version: 3.11.0
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: rubocop
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
78
92
|
requirements:
|
79
93
|
- - "~>"
|
80
94
|
- !ruby/object:Gem::Version
|
81
|
-
version: 1.
|
95
|
+
version: 1.27.0
|
82
96
|
type: :development
|
83
97
|
prerelease: false
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
100
|
- - "~>"
|
87
101
|
- !ruby/object:Gem::Version
|
88
|
-
version: 1.
|
102
|
+
version: 1.27.0
|
89
103
|
description: List and find Turkish cities via name, district name, post code, plate
|
90
104
|
number. Calculate air travel distance between cities and get realistic estimates
|
91
105
|
of travel time
|
@@ -94,16 +108,17 @@ executables: []
|
|
94
108
|
extensions: []
|
95
109
|
extra_rdoc_files: []
|
96
110
|
files:
|
111
|
+
- ".circleci/config.yml"
|
97
112
|
- ".codeclimate.yml"
|
98
113
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
99
114
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
100
115
|
- ".github/dependabot.yml"
|
101
116
|
- ".github/pull_request_template.md"
|
117
|
+
- ".github/workflows/ruby.yml"
|
102
118
|
- ".gitignore"
|
103
119
|
- ".hound.yml"
|
104
120
|
- ".rspec"
|
105
121
|
- ".rubocop.yml"
|
106
|
-
- ".travis.yml"
|
107
122
|
- CHANGELOG.md
|
108
123
|
- CODE_OF_CONDUCT.md
|
109
124
|
- CONTRIBUTING.md
|
@@ -111,8 +126,9 @@ files:
|
|
111
126
|
- Gemfile.lock
|
112
127
|
- LICENSE.txt
|
113
128
|
- README.md
|
114
|
-
-
|
115
|
-
- config/locales/
|
129
|
+
- Rakefile
|
130
|
+
- lib/config/locales/en.yml
|
131
|
+
- lib/config/locales/tr.yml
|
116
132
|
- lib/turkish_cities.rb
|
117
133
|
- lib/turkish_cities/city.rb
|
118
134
|
- lib/turkish_cities/data/cities.yaml
|
@@ -200,7 +216,9 @@ files:
|
|
200
216
|
- lib/turkish_cities/data/neighborhoods_parser.rb
|
201
217
|
- lib/turkish_cities/distance.rb
|
202
218
|
- lib/turkish_cities/district.rb
|
219
|
+
- lib/turkish_cities/elevation.rb
|
203
220
|
- lib/turkish_cities/helpers/decomposer_helper.rb
|
221
|
+
- lib/turkish_cities/population.rb
|
204
222
|
- lib/turkish_cities/postcode.rb
|
205
223
|
- lib/turkish_cities/version.rb
|
206
224
|
- public/assets/img/TurkishCities_darkblue-on-yellow_800X800@3x-8.png
|
@@ -232,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
250
|
- !ruby/object:Gem::Version
|
233
251
|
version: '0'
|
234
252
|
requirements: []
|
235
|
-
rubygems_version: 3.
|
253
|
+
rubygems_version: 3.3.7
|
236
254
|
signing_key:
|
237
255
|
specification_version: 4
|
238
256
|
summary: List and find Turkish cities
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
env:
|
2
|
-
global:
|
3
|
-
- CC_TEST_REPORTER_ID=23062197f289fd0ae7601ae06c2dd4a0af4e16c436f2428b99ab4b64a7e4a587
|
4
|
-
language: ruby
|
5
|
-
dist: trusty
|
6
|
-
rvm:
|
7
|
-
- 2.5
|
8
|
-
- 2.6
|
9
|
-
- 2.7
|
10
|
-
before_install:
|
11
|
-
- gem install bundler
|
12
|
-
before_script:
|
13
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
-
- chmod +x ./cc-test-reporter
|
15
|
-
- ./cc-test-reporter before-build
|
16
|
-
script: bundle exec rspec spec
|
17
|
-
after_script:
|
18
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
19
|
-
notifications:
|
20
|
-
email:
|
21
|
-
- arslanoglusemih93@gmail.com
|