Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timrogers/airports
Access data on airports from around the world using Ruby
https://github.com/timrogers/airports
Last synced: about 14 hours ago
JSON representation
Access data on airports from around the world using Ruby
- Host: GitHub
- URL: https://github.com/timrogers/airports
- Owner: timrogers
- License: mit
- Created: 2015-10-24T22:35:39.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T15:25:32.000Z (3 months ago)
- Last Synced: 2024-10-26T21:33:28.408Z (15 days ago)
- Language: Ruby
- Size: 1.62 MB
- Stars: 32
- Watchers: 5
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Airports
[![Gem Version](https://badge.fury.io/rb/airports.svg)](http://badge.fury.io/rb/airports)
Airports gives you access to data on airports around the world from your Ruby applications.
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 `HYD` and `BER` which are missing entirely).
## Usage
Install the gem by adding it to your Gemfile:
```ruby
gem "airports", "~> 1.9.0"
```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`:
```ruby
Airports.find_by_iata_code("LHR")
=> #
```You can also look up an airport by its ICAO code.
```ruby
Airports.find_by_icao_code("KCRG")
=> #
```A couple of other methods provide access to aggregate data.
You can call `Airports.iata_codes` for a list of valid IATA codes, perfect for Rails validations:
```ruby
validates :destination_airport, inclusion: { in: Airports.iata_codes, message: "is not a valid airport" }
```Or `Airports.all` will provide `Airports::Airport` objects representing all the airports the gem knows about.
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
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).
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](https://contributor-covenant.org) code of conduct.
## Acknowledgements
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.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).