airports 0.0.2 → 1.0.0
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/README.md +9 -5
- data/Rakefile +45 -0
- data/data/airports.json +1 -1
- data/lib/airports/version.rb +1 -1
- metadata +3 -8
- data/.gitmodules +0 -3
- data/data/README.md +0 -54
- data/data/airports.dat +0 -7733
- data/data/reformat.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8815f8b4415b254f726bb075910b58c5110cc4fd
|
4
|
+
data.tar.gz: 55c2474dc7966cff0f68a7d82fbf68639c9a0267
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e0197e308c2f232ad49b566a13d19007bcf9224969e90135dc160431b36fffb0ee8be589727ae2fec670be4028d74c77aaf6dbbfeb49725d09856e1cfbce3f
|
7
|
+
data.tar.gz: 4f6d93a9bf1d3740ec5dc6ae32f02cf103b07f060c4c593cfb25c443c024c6f00707091f002aaa0342d7e0fc2b3e1c035a25a2a6bd36facfae52075493beb270
|
data/README.md
CHANGED
@@ -4,12 +4,14 @@
|
|
4
4
|
|
5
5
|
Airports gives you access to data on airports around the world.
|
6
6
|
|
7
|
+
It's based on data from [OpenFlights](http://openflights.org), with a bit of massaging on the way (dropping airports without an IATA code, giving Doha its IATA code and adding Hyderabad which is missing entirely).
|
8
|
+
|
7
9
|
## Usage
|
8
10
|
|
9
|
-
Install the gem
|
11
|
+
Install the gem by adding it to your Gemfile:
|
10
12
|
|
11
|
-
```
|
12
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'airports', '~> 1.0.0'
|
13
15
|
```
|
14
16
|
|
15
17
|
You can then look up an airport by its IATA code (e.g. `LHR` for London Heathrow) using `Airports.find_by_iata_code`, which returns an object with a bunch of accessors like `name` and `city`:
|
@@ -37,11 +39,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
37
39
|
|
38
40
|
## Contributing
|
39
41
|
|
40
|
-
|
42
|
+
To update the data included in the gem, just run `bundle exec rake update` and make a pull request with the changes. This will pull the latest data from [OpenFlights](http://openflights.org).
|
43
|
+
|
44
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/timrogers/airports. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
41
45
|
|
42
46
|
## Acknowledgements
|
43
47
|
|
44
|
-
|
48
|
+
Big thanks to [OpenFlights](http://openflights.org) for collecting and making this data available. Check out their website for additional data about airlines, routes etc.
|
45
49
|
|
46
50
|
## License
|
47
51
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,51 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require "csv"
|
4
|
+
require "json"
|
5
|
+
require "open-uri"
|
3
6
|
|
4
7
|
RSpec::Core::RakeTask.new(:spec)
|
5
8
|
|
9
|
+
task :update do
|
10
|
+
raw_data = open("https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat").read
|
11
|
+
cleaned_data = raw_data.gsub(/\\"/,'""')
|
12
|
+
|
13
|
+
data = CSV.parse(cleaned_data).each_with_object({}) do |row, accumulator|
|
14
|
+
# Doha is missing its IATA code, for some reason 🙄
|
15
|
+
iata_code = row[5] == "OTBD" ? "DOH" : row[4]
|
16
|
+
|
17
|
+
accumulator[iata_code] = {
|
18
|
+
name: row[1],
|
19
|
+
city: row[2],
|
20
|
+
country: row[3],
|
21
|
+
iata: iata_code,
|
22
|
+
icao: row[5],
|
23
|
+
latitude: row[6],
|
24
|
+
longitude: row[7],
|
25
|
+
altitude: row[8],
|
26
|
+
timezone: row[9],
|
27
|
+
dst: row[10]
|
28
|
+
}
|
29
|
+
end.
|
30
|
+
tap do |data|
|
31
|
+
# Hyderabad (HYD) is missing, so add it in
|
32
|
+
data["HYD"] = {
|
33
|
+
name: "Rajiv Gandhi International Airport",
|
34
|
+
city: "Hyderabad",
|
35
|
+
country: "India",
|
36
|
+
iata: "HYD",
|
37
|
+
icao: "VOHS",
|
38
|
+
latitude: "17.2403",
|
39
|
+
longitude: "78.4294",
|
40
|
+
altitude: nil,
|
41
|
+
timezone: "N",
|
42
|
+
dst: "5.5",
|
43
|
+
}
|
44
|
+
end.
|
45
|
+
# We aren't interested in airports with no IATA code
|
46
|
+
reject { |code, _| code.nil? || code == "" }
|
47
|
+
|
48
|
+
File.open("data/airports.json", "w").puts JSON.generate(data)
|
49
|
+
end
|
50
|
+
|
6
51
|
task :default => :spec
|