Skip to content

Commit

Permalink
Merge pull request #23 from lilopkins/develop
Browse files Browse the repository at this point in the history
0.7.7
  • Loading branch information
lilopkins authored Oct 4, 2023
2 parents eea2b71 + 1847a3b commit ea3f741
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 29 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_size = 2
42 changes: 42 additions & 0 deletions .github/workflows/rust-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Check Format

on:
push:

jobs:
check-fmt:
name: Check formatting
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Check cargo fmt
run: cargo fmt --check


check-clippy:
name: Check code style (clippy)
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Check cargo clippy
run: cargo clippy
33 changes: 33 additions & 0 deletions .github/workflows/rust-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish to crates.io

on:
push:
branches:
- main

jobs:
publish:
name: Publish
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Build and Test
run: |
cargo build --release
cargo test
- name: Sign in to crates.io
run: cargo login ${{ secrets.CARGO_TOKEN }}

- name: Publish
run: cargo publish
26 changes: 26 additions & 0 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test

on:
push:

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
15 changes: 0 additions & 15 deletions .github/workflows/rust.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "metar"
version = "0.7.6"
version = "0.7.7"
authors = ["Lily Hopkins <lily@hpkns.uk>"]
edition = "2021"
description = "A fast METAR parsing library in pure Rust"
Expand All @@ -10,13 +10,13 @@ repository = "https://github.com/lilopkins/metar-rs"
readme = "README.md"

[dependencies]
pest = "2.1.3"
pest_derive = "2.1.0"
pest = "2.7.4"
pest_derive = "2.7.4"

[dev-dependencies]
anyhow = "1.0"
async-trait = "0.1"
cucumber = "0.19.1"
cucumber = "0.20.0"
futures = "0.3"

[[test]]
Expand Down
27 changes: 18 additions & 9 deletions src/parser/metar.pest
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ metar = {
station ~
observation_time ~
(method)? ~
wind ~
(wind)? ~
(wind_varying)? ~
atmos_condition ~
temperatures ~
pressure ~
(recents)? ~
(atmos_condition)? ~
(temperatures)? ~
(pressure)? ~
(recents)? ~
(windshear)* ~
(runway_state)* ~
(trend)* ~
(cloud_direction)* ~
(remarks)? ~
"="? ~
EOI
Expand Down Expand Up @@ -80,13 +81,13 @@ wind_varying = ${
atmos_condition = {
"CAVOK" |
"SKC" |
(visibility_horizontal ~
((visibility_horizontal)? ~
restricted_visibility_horizontal* ~
rvr* ~
("CLR" |
("SKC" | "CLR" |
(wx)* ~
(visibility_vertical)? ~
("NCD" |"NSC" | (cloud)*)))
("NCD" | "NSC" | "CLR" | (cloud)*)))
}

visibility_horizontal = @{
Expand All @@ -97,8 +98,12 @@ visibility_horizontal = @{
(ASCII_DIGIT ~ "/" ~ ASCII_DIGIT ~ "SM")
}

compass_direction = _{
"NE" | "NW" | "N" | "SE" | "SW" | "S" | "E" | "W"
}

restricted_visibility_horizontal = ${
visibility_horizontal ~ ("NE" | "NW" | "N" | "SE" | "SW" | "S" | "E" | "W")
visibility_horizontal ~ compass_direction
}

visibility_vertical = @{
Expand Down Expand Up @@ -235,6 +240,10 @@ wx_change_conditions = {
wx_significant_conditions? ~ (wind ~ wind_varying?)? ~ visibility_horizontal? ~ wx* ~ cloud*
}

cloud_direction = ${
cloud_type ~ ("/" ~ compass_direction)+
}

remarks = {
"RMK" ~
(ASCII_ALPHANUMERIC | "$" | "/" | "-")*
Expand Down
6 changes: 5 additions & 1 deletion tests/cucumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ fn parse_successful(w: &mut World) {

let metar_result = w.metar.as_ref().unwrap();
if metar_result.is_err() {
panic!("{:#?}\n{}", metar_result, metar_result.as_ref().unwrap_err());
panic!(
"{:#?}\n{}",
metar_result,
metar_result.as_ref().unwrap_err()
);
}
assert!(metar_result.is_ok());
}
Expand Down
9 changes: 9 additions & 0 deletions tests/features/parsing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ Feature: METAR Parsing
| UUDD | 15 | 12 | 30 | 260 | 7 mps | none | none | CAVOK | 23 | 09 | 1008 hPa | UUDD 151230Z 26007MPS CAVOK 23/09 Q1008 WS R32L R32L/CLRD60 NOSIG |
| KLAX | 28 | 12 | 53 | 240 | 5 kt | none | none | 0.125 mi | 17 | 16 | 29.99 inHg | KLAX 281253Z 24005KT 1/8SM R25L/2600VP6000FT FG VV002 17/16 A2999 RMK AO2 SLP152 VIS E 1/4 T01720161 |
| KMHT | 02 | 18 | 53 | 050 | 6 kt | none | none | 10 mi | 33 | 13 | 29.81 inHg | KMHT 021853Z COR 05006KT 10SM TS SCT075CB BKN150 33/13 A2981 RMK |
| KPVG | 18 | 19 | 56 | unknown | unknown | none | none | 10 mi | unk | unk | 29.82 inHg | KPVG 181956Z AUTO 10SM FEW030 SCT035 BKN050 A2982 RMK AO2 SLPNO FZRANO PNO $ |
| KPVG | 18 | 18 | 55 | unknown | unknown | none | none | 10 mi | unk | unk | 29.83 inHg | KPVG 181855Z 10SM FEW025 OVC034 A2983 RMK AO2 PWINO PNO FZRANO RVRNO |
| KGWW | 19 | 11 | 50 | 000 | 0 kt | none | none | unknown | 14 | 14 | 30.07 inHg | KGWW 191150Z AUTO 00000KT 14/14 A3007 RMK AO2 70001 T01410140 10145 20122 |
| CYWG | 19 | 05 | 00 | 160 | 14 kt | none | none | 10 mi | 19 | 11 | 29.59 inHg | CYWG 190500Z 16014KT 10SM SKC 19/11 A2959 RMK SLP022 DENSITY ALT 1800FT |
| CYWG | 19 | 04 | 00 | 150 | 11 kt | none | none | 9 mi | 18 | 12 | 29.60 inHg | CYWG 190400Z 15011KT 9SM SKC 18/12 A2960 RMK SLP027 DENSITY ALT 1700FT |
| KFCI | 20 | 03 | 56 | 000 | 0 kt | none | none | unknown | 15 | 15 | unknown | KFCI 200356Z AUTO 00000KT SCT070 15/15 RMK AO2 SLPNO T01500150 402610111 PWINO $ |
| KFCI | 20 | 02 | 56 | 000 | 0 kt | none | none | unknown | 16 | 16 | unknown | KFCI 200256Z AUTO 00000KT BKN070 16/16 RMK AO2 SLPNO T01610156 PWINO $ |
| KPHF | 19 | 10 | 54 | 000 | 0 kt | none | none | 5 mi | 11 | 11 | 30.03 inHg | KPHF 191054Z 00000KT 5SM BR CLR 11/11 A3003 RMK AO2 SLP168 T01110111 |
| MDSD | 19 | 20 | 00 | 080 | 8 kt | none | none | 9999 m | 32 | 25 | 1012 hPa | MDSD 192000Z 08008KT 9999 FEW020CB FEW022 BKN300 32/25 Q1012 CB/NE/E/W |
#| UUDD | 25 | 08 | 30 | 030 | 4 mps | 350 150 | none | CAVOK | 25 | 11 | 1019 hPa | UUDD 250830Z 03004MPS 350V150 CAVOK 25/11 Q1019 R88/60D NOSIG |
#| EDDK | 07 | 13 | 50 | 250 | 4 kt | 220 280 | none | 9999 m | 17 | 14 | 1013 hPa | EDDK 071350Z AUTO 25004KT 220V280 9999 3100 SHRA BKN036 BKN046 SCT///TCU 17/14 Q1013 BECMG NSW |
# | UUDD | 29 | 10 | 00 | 120 | 2 mps | none | none | CAVOK | 22 | 4 | 1022 hPa | UUDD 291000Z 12002MPS CAVOK 22/04 Q1022 R88/60D NOSIG |
Expand Down

0 comments on commit ea3f741

Please sign in to comment.