Skip to content

Commit

Permalink
Merge pull request #1 from martide/master
Browse files Browse the repository at this point in the history
Update airports
  • Loading branch information
sjoulbak authored Feb 21, 2022
2 parents 1e2063c + d2fcc97 commit eeecf28
Show file tree
Hide file tree
Showing 14 changed files with 71,330 additions and 7,218 deletions.
5 changes: 5 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
inputs: [
"{lib,priv,test}/**/*.{ex,exs}",
]
]
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 99
- package-ecosystem: mix
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 99
74 changes: 74 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Elixir
on: push

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MIX_ENV: test

# https://github.com/elixir-lang/elixir/blob/master/lib/elixir/pages/compatibility-and-deprecations.md
jobs:
elixir_1_13:
runs-on: ubuntu-20.04
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp: [22.x, 23.x, 24.x]
elixir: [1.13.x]
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-elixir@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- run: mix do deps.get, compile --warnings-as-errors
- run: mix format --dry-run --check-formatted
- run: mix coveralls.github

elixir_1_12:
runs-on: ubuntu-20.04
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp: [22.x, 23.x, 24.x]
elixir: [1.12.x]
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-elixir@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- run: mix do deps.get, compile --warnings-as-errors
- run: mix format --dry-run --check-formatted
- run: mix coveralls.github

elixir_1_11:
runs-on: ubuntu-20.04
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp: [21.x, 22.x, 23.x, 24.x]
elixir: [1.11.x]
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-elixir@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- run: mix do deps.get, compile --warnings-as-errors
- run: mix coveralls.github

elixir_1_10:
runs-on: ubuntu-20.04
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp: [21.x, 22.x, 23.x]
elixir: [1.10.x]
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-elixir@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- run: mix do deps.get, compile --warnings-as-errors
- run: mix coveralls.github
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore .elixir_ls file from Elixir Language Server
*.elixir_ls
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
elixir 1.13.0-otp-24
erlang 24.1.7
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## 1.0.0 (2022-02-17)

- **Breaking change:** Swapped to new airports datasource as old has not been [updated since 2019](https://github.com/jpatokal/openflights/commits/master/data/airports.dat) where as the new source (which is listed on the openflights website) is [updated daily(!)](https://github.com/davidmegginson/ourairports-data/commits/main/airports.csv)
- Added dependabot
- Added Github Actions
- Swap csv for nimble_csv

## v0.1.0 (2017-06-09)

- Initial Release
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Airports

Airports is a collection of all known airports. Data source is https://openflights.org/data.html
Airports is a collection of all known airports. Data source is https://github.com/davidmegginson/ourairports-data

## Installation

Expand All @@ -9,7 +9,7 @@ by adding `airports` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[{:airports, "~> 0.1.0"}]
[{:airports, "~> 1.0"}]
end
```

Expand Down
23 changes: 20 additions & 3 deletions lib/airport.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
defmodule Airports.Airport do
defstruct [:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude,
:timezone, :dst, :tz]
end
defstruct [
:ident,
:type,
:name,
:latitude,
:longitude,
:elevation_ft,
:continent,
:iso_country,
:iso_region,
:municipality,
:scheduled_service,
:gps_code,
:iata_code,
:local_code,
:home_link,
:wikipedia_link,
:keywords
]
end
61 changes: 52 additions & 9 deletions lib/airports.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,56 @@
NimbleCSV.define(AirportsParser, separator: ",", escape: "\"")

defmodule Airports do
data_file = Path.join([__DIR__,"../priv", "airports.dat"])
@airports File.stream!(data_file, [], :line) |> CSV.decode |> Stream.map(fn(line) ->
[_, name, city, country, iata, icao, latitude, longitude, altitude, timezone, dst, tz, _, _] = line
@moduledoc """
Airports main API
"""
@airports [__DIR__, "../priv", "airports.csv"]
|> Path.join()
|> File.stream!([], :line)
|> AirportsParser.parse_stream(skip_headers: false)
|> Stream.map(fn line ->
[
_,
ident,
type,
name,
latitude,
longitude,
elevation_ft,
continent,
iso_country,
iso_region,
municipality,
scheduled_service,
gps_code,
iata_code,
local_code,
home_link,
wikipedia_link,
keywords
] = line

%Airports.Airport{name: name, city: city, country: country, iata: iata, icao: icao, latitude: latitude,
longitude: longitude, altitude: altitude, timezone: timezone, dst: dst, tz: tz}
end) |> Enum.to_list
%Airports.Airport{
ident: ident,
type: type,
name: name,
latitude: latitude,
longitude: longitude,
elevation_ft: elevation_ft,
continent: continent,
iso_country: iso_country,
iso_region: iso_region,
municipality: municipality,
scheduled_service: scheduled_service,
gps_code: gps_code,
iata_code: iata_code,
local_code: local_code,
home_link: home_link,
wikipedia_link: wikipedia_link,
keywords: keywords
}
end)
|> Enum.to_list()

def all() do
@airports
end
def all, do: @airports
end
35 changes: 20 additions & 15 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ defmodule Airports.Mixfile do
@project_url "https://github.com/nerds-and-company/airports"

def project do
[app: :airports,
version: "0.1.0",
elixir: "~> 1.4",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps(),
description: description(),
package: package(),
source_url: @project_url]
[
app: :airports,
version: "1.0.0",
elixir: "~> 1.10",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
deps: deps(),
description: description(),
package: package(),
source_url: @project_url,
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
coveralls: :test
]
]
end

def application do
Expand All @@ -21,21 +27,20 @@ defmodule Airports.Mixfile do

defp deps do
[
{:csv, "~> 1.4.2"},

{:nimble_csv, "~> 1.1"},
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
{:excoveralls, "~> 0.12", only: :test},
{:ex_doc, ">= 0.0.0", only: :dev}
]
end

defp description do
"""
Airports is a collection of all known airports. Data source is https://openflights.org/data.html
Airports is a collection of all known airports. Data source is https://davidmegginson.github.io/ourairports-data/airports.csv
"""
end

defp package do
[maintainers: ["Don Pinkster"],
licenses: ["MIT"],
links: %{"GitHub" => @project_url}]
[maintainers: ["Don Pinkster"], licenses: ["MIT"], links: %{"GitHub" => @project_url}]
end
end
25 changes: 21 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
%{"csv": {:hex, :csv, "1.4.4", "992f2e1418849a326fd1d9287801fa2d86091db4f9611f60781da6d236f64cd4", [:mix], [{:parallel_stream, "~> 1.0.4", [hex: :parallel_stream, optional: false]}]},
"earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.16.1", "b4b8a23602b4ce0e9a5a960a81260d1f7b29635b9652c67e95b0c2f7ccee5e81", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
"parallel_stream": {:hex, :parallel_stream, "1.0.5", "4c78d3e675f9eff885cbe252c89a8fc1d2fb803c0d03a914281e587834e09431", [:mix], []}}
%{
"certifi": {:hex, :certifi, "2.8.0", "d4fb0a6bb20b7c9c3643e22507e42f356ac090a1dcea9ab99e27e0376d695eba", [:rebar3], [], "hexpm", "6ac7efc1c6f8600b08d625292d4bbf584e14847ce1b6b5c44d983d273e1097ea"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark_parser": {:hex, :earmark_parser, "1.4.19", "de0d033d5ff9fc396a24eadc2fcf2afa3d120841eb3f1004d138cbf9273210e8", [:mix], [], "hexpm", "527ab6630b5c75c3a3960b75844c314ec305c76d9899bb30f71cb85952a9dc45"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.28.0", "7eaf526dd8c80ae8c04d52ac8801594426ae322b52a6156cd038f30bafa8226f", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e55cdadf69a5d1f4cfd8477122ebac5e1fadd433a8c1022dafc5025e48db0131"},
"excoveralls": {:hex, :excoveralls, "0.14.4", "295498f1ae47bdc6dce59af9a585c381e1aefc63298d48172efaaa90c3d251db", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e3ab02f2df4c1c7a519728a6f0a747e71d7d6e846020aae338173619217931c1"},
"hackney": {:hex, :hackney, "1.18.0", "c4443d960bb9fba6d01161d01cd81173089686717d9490e5d3606644c48d121f", [:rebar3], [{:certifi, "~>2.8.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "9afcda620704d720db8c6a3123e9848d09c87586dc1c10479c42627b905b5c5e"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"nimble_csv": {:hex, :nimble_csv, "1.2.0", "4e26385d260c61eba9d4412c71cea34421f296d5353f914afe3f2e71cce97722", [:mix], [], "hexpm", "d0628117fcc2148178b034044c55359b26966c6eaa8e2ce15777be3bbc91b12a"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
}
Loading

0 comments on commit eeecf28

Please sign in to comment.