Ruby client for the FlightStats Flex API.
In your Gemfile:
gem "flightstats-flex", "~> 0.3.0"
or
gem 'flightstats-flex', :git => 'https://github.com/diditclear/flightstats-client-ruby'
Note that there is an old flightstats gem on Rubygems, hence the name flightstats-flex for this library.
You only need to configure your FlightStats app id and keys:
FlightStats.app_id = '1234'
FlightStats.app_key = '5678'
You can also specify your own logger:
FlightStats.logger = Logger.new
When using Rails, you can set it up in an initializer (e.g. config/initializers/flightstats.rb):
require 'flightstats'
FlightStats.app_id = '1234'
FlightStats.app_key = '5678'
FlightStats.logger = Rails.logger
airports = FlightStats::Airport.actives
airports = FlightStats::Airport.actives_for_date 2013, 5, 1
airports = FlightStats::Airport.all
airports = FlightStats::Airport.current 'PDX'
airports = FlightStats::Airport.on_date 'PDX', 2013, 5, 1
airports = FlightStats::Airport.by_city_code 'ABC'
airports = FlightStats::Airport.by_country_code 'GB'
airport = FlightStats::Airport.by_flight_stats_code 'PDX'
airports = FlightStats::Airport.by_iata_code 'PDX'
airport = FlightStats::Airport.by_iata_code_on_date 'PDX', 2013, 5, 1
airports = FlightStats::Airport.by_icao_code 'KPDX'
airport = FlightStats::Airport.by_icao_code_on_date 'KPDX', 2013, 5, 1
airports = FlightStats::Airport.within_radius 17, 39, 150
airports.size # => 9
airports[5].name # => "Papola Casale Airport"
flight_status = FlightStats::FlightStatus.by_flight_id 1234
flight_statuses = FlightStats::FlightStatus.departing_on 'UA', 901, 2013, 5, 1
flight_statuses = FlightStats::FlightStatus.arriving_on 'UA', 901, 2013, 5, 1
flight_track = FlightStats::FlightStatus.track_by_flight_id 1234
flight_tracks = FlightStats::FlightStatus.track_arriving_on 'UA', 901, 2013, 5, 1
flight_tracks = FlightStats::FlightStatus.track_departing_on 'UA', 901, 2013, 5, 1
flights = FlightStats::Flight.direct_arriving_at 'EWR', 2013, 5, 1
flights = FlightStats::Flight.direct_departing_from 'EWR', 2013, 5, 1
flights = FlightStats::Flight.direct_arriving_by_flight_number 'UA', 901, 2013, 5, 1
flights = FlightStats::Flight.direct_arriving_by_flight_number_and_location 'UA', 901, 'FRA', 2013, 5, 1
flights = FlightStats::Flight.direct_arriving_by_flight_number 'UA', 901, 2013, 5, 1
flights = FlightStats::Flight.direct_arriving_by_flight_number_and_location 'UA', 901, 'FRA', 2013, 5, 1
flights = FlightStats::Flight.direct_and_connecting_arriving 'SFO', 'FRA', 2013, 5, 1
flights = FlightStats::Flight.direct_and_connecting_departing 'SFO', 'FRA', 2013, 5, 1
There are two sets of tests.
The default one uses mock HTTP calls and can be run via:
rake test:spec
The remote ones will issue HTTP calls to FlightStats. You need to update your API credentials in spec/spec_helper.rb before running them:
rake test:remote:spec
(The MIT License.)
© 2013 DidItClear
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.