airports 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 332ef524c4fb151babbb5320022c34a4071b0c1e
4
+ data.tar.gz: 32b07c85f58729a7078aea634ae42ddcab86a565
5
+ SHA512:
6
+ metadata.gz: 4cf7aab3281b1cc33ae43241f484d000b280b598170f36cd0346fe3e2231d006cd902dbfe2cd2a3a9090e6c439deb84393db137ebe534cb395d9fa332f7cd6ad
7
+ data.tar.gz: db4ba4a265f7ebd01c2d15208ed0394d86522fa051ab649a84391b542e98a2d03e00c0f3d56fa0b8eb6f62fd8353ef797ce27817611caf4c9f796d92129a9483
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "data"]
2
+ path = data
3
+ url = https://github.com/ram-nadella/airport-codes.git
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ - 2.1.0
5
+ before_install: gem install bundler -v 1.10.4
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Tim Rogers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Airports
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/airports.svg)](http://badge.fury.io/rb/airports) [![Build Status](https://travis-ci.org/timrogers/airports.svg)](https://travis-ci.org/timrogers/airports)
4
+
5
+ Airports gives you access to data on airports around the world.
6
+
7
+ ## Usage
8
+
9
+ Install the gem *(Ruby 2.1.0 and later only)*:
10
+
11
+ ```bash
12
+ $ gem install airports
13
+ ```
14
+
15
+ 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`:
16
+
17
+ ```ruby
18
+ Airports.find_by_iata_code("LHR")
19
+ => #<Airports::Airport:0x007fd9a1bbd550 @name="Heathrow", @city="London", @country="United Kingdom", @iata="LHR", @icao="EGLL", @latitude="51.4775", @longitude="-0.461389", @altitude="83", @timezone="0", @dst="E">
20
+ ```
21
+
22
+ A couple of other methods provide access to aggregate data.
23
+
24
+ You can call `Airports.iata_codes` for a list of valid IATA codes, perfect for Rails validations:
25
+
26
+ ```ruby
27
+ validates :destination_airport, inclusion: { in: Airports.iata_codes, message: "is not a valid airport" }
28
+ ```
29
+
30
+ Or `Airport.all` will provide `Airports::Airport` objects representing all the airports the gem knows about.
31
+
32
+ ## Development
33
+
34
+ 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.
35
+
36
+ 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).
37
+
38
+ ## Contributing
39
+
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/timrogers/mummy. 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
+
42
+ ## Acknowledgements
43
+
44
+ The data is taken from <https://github.com/ram-nadella/airport-codes>, which uses source data from [OpenFlights](http://openflights.org/). Source data is included using [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules).
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
49
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/airports.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'airports/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "airports"
8
+ spec.version = Airports::VERSION
9
+ spec.authors = ["Tim Rogers"]
10
+ spec.email = ["me@timrogers.co.uk"]
11
+
12
+ spec.summary = %q{Access data on airports from around the world}
13
+ spec.description = %q{Access data on airports from around the world}
14
+ spec.homepage = "https://github.com/timrogers/airports"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>= 2.1'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0", ">= 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.3.0", ">= 3.3.0"
26
+ spec.add_development_dependency "rspec-its", "~> 1.2.0", ">= 1.2.0"
27
+ spec.add_development_dependency "pry", "~> 0.10.3", ">= 0.10.3"
28
+ end
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'airports'
5
+ require 'pry'
6
+
7
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
data/lib/airports.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'json'
2
+ require 'airports/version'
3
+ require 'airports/airport'
4
+
5
+ module Airports
6
+ def self.find_by_iata_code(iata_code)
7
+ return unless iata_code.length == 3
8
+ return unless airport_data = parsed_data.fetch(iata_code, nil)
9
+
10
+ Airport.
11
+ new(airport_data.each_with_object({}) { |(k,v), h| h[k.to_sym] = v })
12
+ end
13
+
14
+ def self.iata_codes
15
+ parsed_data.keys
16
+ end
17
+
18
+ def self.all
19
+ @all ||= parsed_data.map do |_iata_code, airport_data|
20
+ Airport.
21
+ new(airport_data.each_with_object({}) { |(k,v), h| h[k.to_sym] = v })
22
+ end
23
+ end
24
+
25
+ def self.parsed_data
26
+ @parsed_data ||= JSON.parse(data)
27
+ end
28
+
29
+ def self.data
30
+ @data ||= File.read(data_path)
31
+ end
32
+ private_class_method :data
33
+
34
+ def self.data_path
35
+ File.expand_path("../../data/airports.json", __FILE__)
36
+ end
37
+ private_class_method :data_path
38
+ end
@@ -0,0 +1,20 @@
1
+ module Airports
2
+ class Airport
3
+ attr_reader :name, :city, :country, :iata, :icao, :latitude, :longitude,
4
+ :altitude, :timezone, :dst
5
+
6
+ def initialize(name:, city:, country:, iata:, icao:, latitude:, longitude:,
7
+ altitude:, timezone:, dst:)
8
+ @name = name
9
+ @city = city
10
+ @country = country
11
+ @iata = iata
12
+ @icao = icao
13
+ @latitude = latitude
14
+ @longitude = longitude
15
+ @altitude = altitude
16
+ @timezone = timezone
17
+ @dst = dst
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Airports
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: airports
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tim Rogers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '10.0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '10.0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '10.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 3.3.0
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.3.0
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: 3.3.0
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 3.3.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec-its
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: 1.2.0
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.2.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 1.2.0
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 1.2.0
87
+ - !ruby/object:Gem::Dependency
88
+ name: pry
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: 0.10.3
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.3
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.10.3
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 0.10.3
107
+ description: Access data on airports from around the world
108
+ email:
109
+ - me@timrogers.co.uk
110
+ executables: []
111
+ extensions: []
112
+ extra_rdoc_files: []
113
+ files:
114
+ - ".gitignore"
115
+ - ".gitmodules"
116
+ - ".rspec"
117
+ - ".travis.yml"
118
+ - CODE_OF_CONDUCT.md
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - airports.gemspec
124
+ - bin/console
125
+ - bin/setup
126
+ - lib/airports.rb
127
+ - lib/airports/airport.rb
128
+ - lib/airports/version.rb
129
+ homepage: https://github.com/timrogers/airports
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '2.1'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.4.7
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Access data on airports from around the world
153
+ test_files: []
154
+ has_rdoc: