Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Database::iter(), docs, DB update, deps bump. #70

Merged
merged 10 commits into from
May 13, 2024
22 changes: 22 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check
on:
pull_request:
paths:
- assets/**

jobs:
check_database_update:
name: Check libphonenumber database update
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Update assets
run: ./assets/update.sh
- name: Check git status
run: |
if [[ -n "$(git status --porcelain=v2)" ]];
then
echo "Found untracked or uncommitted files after updating the libphonenumber database, failing."
exit 1
fi
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "phonenumber"
version = "0.3.4+8.13.34"
version = "0.3.5+8.13.35"
edition = "2021"
rust-version = "1.58.0"

Expand All @@ -14,33 +14,33 @@ readme = "README.md"

[dependencies]
bincode = "1.3"
either = "1.8"
fnv = "1.0"
lazy_static = "1.4"
either = "1.11"
fnv = "1"
itertools = ">=0.10, <= 0.12"
lazy_static = "1.4"
nom = "7.1"
quick-xml = ">=0.28, <= 0.31"
regex = "1.7"
regex = "1.10"
regex-cache = "0.2"
serde = "1.0"
serde_derive = "1.0"
strum = { version = ">=0.24, <=0.25", features = ["derive"] }
strum = { version = ">=0.24, <=0.26", features = ["derive"] }
thiserror = "1.0"

[build-dependencies]
bincode = "1.3"
bincode = "1.0.1"
gferon marked this conversation as resolved.
Show resolved Hide resolved
quick-xml = ">=0.28, <=0.31"
regex = "1.7"
regex = "1.10"
serde = "1.0"
serde_derive = "1.0"
thiserror = "1.0"

[dev-dependencies]
doc-comment = "0.3"
rstest = ">= 0.13, <=0.18"
rstest_reuse = "0.6"
anyhow = "1"
criterion = ">=0.4, <=0.5"
doc-comment = "0.3"
rstest = ">= 0.13, <=0.19"
rstest_reuse = "0.6"

[[bench]]
name = "parsing"
Expand Down
50 changes: 29 additions & 21 deletions assets/PhoneNumberMetadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5721,7 +5721,7 @@
<nationalNumberPattern>
88\d{5}|
(?:
8[0-59]|
8[0-69]|
9[017-9]
)\d{7}
</nationalNumberPattern>
Expand Down Expand Up @@ -11177,15 +11177,14 @@
)|
1(?:
1(?:
00|
[124]\d|
3[01]
[03][01]|
[124]\d
)|
4\d\d
)|
(?:
44|
68
6[89]
)\d\d|
5(?:
[0157-9]\d\d|
Expand Down Expand Up @@ -12421,7 +12420,7 @@
6\d\d|
7(?:
[01]\d|
2[156]|
2[1256]|
3[12]|
49
)
Expand Down Expand Up @@ -18251,14 +18250,19 @@
</fixedLine>
<!-- Adding 202[89], 205[289], 207[68] and 209[135-7] from numbers found online. -->
<mobile>
<possibleLengths national="10"/>
<possibleLengths national="9,10"/>
<exampleNumber>2023123456</exampleNumber>
<nationalNumberPattern>
2088\d{6}|
(?:
20[23579]|
302
)\d{7}
20(?:
[23579]\d|
88
)|
30(?:
2\d|
4
)
)\d{6}
</nationalNumberPattern>
</mobile>
<!-- The Lonely Planet says that newer WIN phones (fixed phones without a physical landline)
Expand All @@ -18267,7 +18271,7 @@
<uan>
<possibleLengths national="9"/>
<exampleNumber>301234567</exampleNumber>
<nationalNumberPattern>30[013-9]\d{6}</nationalNumberPattern>
<nationalNumberPattern>30[0135-9]\d{6}</nationalNumberPattern>
</uan>
</territory>

Expand Down Expand Up @@ -24507,8 +24511,8 @@
9\d
)|
[35]92(?:
3[034]|
9\d
[049]\d|
3[034]
)
)\d{3}|
(?:
Expand Down Expand Up @@ -24597,7 +24601,11 @@
<exampleNumber>600110000</exampleNumber>
<nationalNumberPattern>
600\d{6}|
6[06]923[34]\d{3}
6[06]92(?:
0\d|
3[349]|
49
)\d{3}
</nationalNumberPattern>
</voicemail>
</territory>
Expand Down Expand Up @@ -25082,8 +25090,8 @@
7020\d{5}|
(?:
6(?:
2\d|
40
[04]0|
2\d
)|
7(?:
0[013-9]|
Expand Down Expand Up @@ -26142,9 +26150,9 @@
<exampleNumber>81234567</exampleNumber>
<nationalNumberPattern>
8(?:
09|
95
)[0-2]\d{4}|
09[0-24]|
95[0-2]
)\d{4}|
(?:
8(?:
0[1-8]|
Expand Down Expand Up @@ -27485,7 +27493,7 @@
<exampleNumber>63012345</exampleNumber>
<nationalNumberPattern>
(?:
6[0235689]|
6[0-689]|
77|
9\d
)\d{6}
Expand Down
7 changes: 1 addition & 6 deletions assets/carrier/en/235.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

23560|Airtel
23562|Airtel
23563|Airtel
23565|Airtel
23566|Airtel
23568|Airtel
2356|Airtel
2357|Sotel
2359|Tigo
1 change: 1 addition & 0 deletions assets/carrier/en/243.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
24383|Vodacom
24384|Orange
24385|Orange
24386|Vodacom
24388|Yozma Timeturns sprl -YTT
24389|Orange
24390|Africell
Expand Down
2 changes: 1 addition & 1 deletion assets/carrier/en/244.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
24492|UNITEL
24493|UNITEL
24494|UNITEL
24495|Africell Angola
24495|Africell
24499|Movicel
5 changes: 5 additions & 0 deletions assets/carrier/en/351.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
351609230|NOS
35160929|NOS
3516093|NOS
35163920|Lycamobile
351639230|NOS
351639233|Digi Communications
351639234|G9 Telecom
35163924|MEO
35163929|NOS
3516393|NOS
35165920|Lycamobile
351659230|NOS
351659233|Digi Communications
351659234|G9 Telecom
35165924|MEO
35165929|NOS
3516593|NOS
351669230|NOS
Expand All @@ -39,6 +43,7 @@
3519203|Lycamobile
3519204|Lycamobile
3519205|Lycamobile
3519208|Lycamobile
351921|Vodafone
3519220|Vodafone
3519221|MEO
Expand Down
1 change: 1 addition & 0 deletions assets/carrier/en/40.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

4060|Telekom
4062|Vodafone
4064|Orange
407000|Enigma-System
Expand Down
5 changes: 4 additions & 1 deletion assets/carrier/en/592.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
592708|GTT
592709|GTT
59271|E-Networks
59272|GTT
592721|GTT
592722|Digicel Guyana
592725|GTT
592726|GTT
59273|E-Networks
59274|GTT
1 change: 1 addition & 0 deletions assets/carrier/en/65.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
658090|SingTel
658091|M1
658092|Simba
658094|M1
6581|StarHub
65810|M1
65812|SingTel
Expand Down
1 change: 1 addition & 0 deletions assets/carrier/en/856.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
856208|Best Telecom
856209|Unitel
856302|ETL
856304|Unitel
1 change: 1 addition & 0 deletions assets/carrier/en/995.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
9955055|MagtiCom
995510|Silknet
99551100|MagtiCom
99551101|Silknet
99551107|Silknet
9955111|MagtiCom
9955112|MagtiCom
Expand Down
2 changes: 1 addition & 1 deletion assets/geocoding/de/49.txt
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
492623|Ransbach-Baumbach
492624|Höhr-Grenzhausen
492625|Ochtendung
492626|Selters Westferwald
492626|Selters Westerwald
492627|Braubach
492628|Rhens
492630|Mülheim-Kärlich
Expand Down
2 changes: 1 addition & 1 deletion assets/geocoding/en/49.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
492623|Ransbach-Baumbach
492624|Höhr-Grenzhausen
492625|Ochtendung
492626|Selters Westferwald
492626|Selters Westerwald
492627|Braubach
492628|Rhens
492630|Mülheim-Kärlich
Expand Down
3 changes: 2 additions & 1 deletion assets/update.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
set -eu
cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd

GIT_REF=v8.13.34
GIT_REF=v8.13.35
TMP_CLONE_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_CLONE_DIR"' EXIT

Expand Down
6 changes: 6 additions & 0 deletions src/metadata/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use regex_cache::{CachedRegex, CachedRegexBuilder, RegexCache};

use crate::error;
use crate::metadata::loader;
use crate::Metadata;

const DATABASE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/database.bin"));

Expand Down Expand Up @@ -258,4 +259,9 @@ impl Database {
.get(code)
.map(|m| m.iter().map(AsRef::as_ref).collect())
}

/// Iterator over all `Metadata` entries in this database.
pub fn iter(&self) -> impl Iterator<Item = &Metadata> {
self.by_id.values().map(AsRef::as_ref)
}
}
Loading
Loading