airports 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/airports.gemspec +2 -2
- data/lib/airports.rb +17 -16
- data/lib/airports/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd6eb797344db6298be1e177fe7a24372708f3656965a549a2bc363ecc8028f9
|
4
|
+
data.tar.gz: bb94c1025b93602d478a2babadcc38f6f03b28578428ea3d2bfd1246adb7fd66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e27d0d368ade101807f015ac7271f3b556d66d9e67aa96c2f325697c1fcd75e6bfb1b03e58a51996326fab224aa99d4c57169b0801534d5ed2df4eaee08eaac8
|
7
|
+
data.tar.gz: d28ea2d9e45464493eb7bdbfeb75a9ee1d4426bdc737160a7e430dc3da69a67ec76af30830a49b0d5faa13697eb7eda12782a6a954cff0bbaf8f0025bb83b013
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# v1.5.0 (5 December 2019)
|
2
|
+
|
3
|
+
* Support looking up airports by the name of the city they
|
4
|
+
are located in with `Airports.find_all_by_city_name` (@viral810, @timrogers)
|
5
|
+
* Refactor `Airports` so `Airport` objects are only generated once
|
6
|
+
and the code is cleaner (@timrogers)
|
7
|
+
|
1
8
|
# v1.4.1 (14 November 2019)
|
2
9
|
|
3
10
|
* Correct the time zone of Istanbul Airport (`IST`) (@aliismayilov)
|
data/airports.gemspec
CHANGED
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.required_ruby_version = ">= 2.4"
|
26
26
|
|
27
|
-
spec.add_development_dependency "gc_ruboconfig", "~> 2.
|
27
|
+
spec.add_development_dependency "gc_ruboconfig", "~> 2.8.0"
|
28
28
|
spec.add_development_dependency "pry", "~> 0.12.2"
|
29
|
-
spec.add_development_dependency "rake", "~>
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.9.0"
|
31
31
|
spec.add_development_dependency "rspec-its", "~> 1.3.0"
|
32
32
|
spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.0"
|
data/lib/airports.rb
CHANGED
@@ -8,25 +8,17 @@ module Airports
|
|
8
8
|
def self.find_by_iata_code(iata_code)
|
9
9
|
return unless iata_code.length == 3
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
return unless airport_data
|
14
|
-
|
15
|
-
Airport.
|
16
|
-
new(airport_data.each_with_object({}) { |(k, v), h| h[k.to_sym] = v })
|
11
|
+
all.find { |airport| airport.iata == iata_code }
|
17
12
|
end
|
18
13
|
|
19
14
|
def self.find_by_icao_code(icao_code)
|
20
15
|
return unless icao_code.length == 4
|
21
16
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
return unless airport_data
|
17
|
+
all.find { |airport| airport.icao == icao_code }
|
18
|
+
end
|
27
19
|
|
28
|
-
|
29
|
-
|
20
|
+
def self.find_all_by_city_name(city_name)
|
21
|
+
all.select { |airport| airport.city.casecmp(city_name).zero? }
|
30
22
|
end
|
31
23
|
|
32
24
|
def self.iata_codes
|
@@ -34,9 +26,8 @@ module Airports
|
|
34
26
|
end
|
35
27
|
|
36
28
|
def self.all
|
37
|
-
@all ||= parsed_data.map do |
|
38
|
-
|
39
|
-
new(airport_data.each_with_object({}) { |(k, v), h| h[k.to_sym] = v })
|
29
|
+
@all ||= parsed_data.values.map do |airport_data|
|
30
|
+
airport_from_parsed_data_element(airport_data)
|
40
31
|
end
|
41
32
|
end
|
42
33
|
|
@@ -44,6 +35,16 @@ module Airports
|
|
44
35
|
@parsed_data ||= JSON.parse(data)
|
45
36
|
end
|
46
37
|
|
38
|
+
def self.airport_from_parsed_data_element(parsed_data_element)
|
39
|
+
# TODO: Once we're using Ruby 2.5+, use Hash#transform_keys here to symbolize the keys
|
40
|
+
transformed_hash = parsed_data_element.each_with_object({}) do |(k, v), hash|
|
41
|
+
hash[k.to_sym] = v
|
42
|
+
end
|
43
|
+
|
44
|
+
Airport.new(transformed_hash)
|
45
|
+
end
|
46
|
+
private_class_method :airport_from_parsed_data_element
|
47
|
+
|
47
48
|
def self.data
|
48
49
|
@data ||= File.read(data_path)
|
49
50
|
end
|
data/lib/airports/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Rogers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gc_ruboconfig
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.8.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|