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

Makefile #11

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,26 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose --all-features && ls -sh target/debug/*.rlib
- name: Build single feature
run: |
set -xe
cargo build --verbose --features=add-ordinal-suffix && ls -sh target/debug/*.rlib
cargo build --verbose --features=commas && ls -sh target/debug/*.rlib
cargo build --verbose --features=digits && ls -sh target/debug/*.rlib
cargo build --verbose --features=find-capital-by-province && ls -sh target/debug/*.rlib
cargo build --verbose --features=is-persian && ls -sh target/debug/*.rlib
cargo build --verbose --features=national-id && ls -sh target/debug/*.rlib
cargo build --verbose --features=remove-ordinal-suffix && ls -sh target/debug/*.rlib
cargo build --verbose --features=to-persian-chars && ls -sh target/debug/*.rlib
cargo build --verbose --features=url-fix && ls -sh target/debug/*.rlib
cargo build --verbose --features=verity-card-number && ls -sh target/debug/*.rlib
- name: Check style
run: make lint

lint:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check style
run: cargo fmt --check --verbose
- name: Clippy
run: cargo clippy --no-deps --verbose --all-features
run: make clippy

docs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check style
run: cargo doc --all-features --verbose
- name: Build
run: make build

test:
runs-on: ubuntu-latest
Expand All @@ -56,4 +41,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Test
run: cargo test --verbose --all-features -- --nocapture
run: make test

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check style
run: make docs
18 changes: 16 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,23 @@ urlencoding = { version = "2.1.3", optional = true }
regex = "1.10.2"
serde = { version = "1.0.193", features = ["derive"], optional = true }


# Edit `Makefile` after making changes in this section:
[features]
default = []

serialize = ["dep:serde"]
full = [
"add-ordinal-suffix",
"commas",
"digits",
"find-capital-by-province",
"is-persian",
"national-id",
"remove-ordinal-suffix",
"to-persian-chars",
"url-fix",
"verity-card-number",
"phone-number",
]
add-ordinal-suffix = []
commas = []
digits = []
Expand All @@ -35,6 +48,7 @@ to-persian-chars = []
url-fix = ["dep:urlencoding"]
verity-card-number = []
phone-number = []
serde = ["dep:serde"]

[package.metadata.docs.rs]
all-features = true
90 changes: 90 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
all: build check test docs

fmt:
cargo fmt


build: full default add-ordinal-suffix commas digits find-capital-by-province is-persian national-id remove-ordinal-suffix to-persian-chars url-fix verity-card-number phone-number

check: clippy lint

test:
cargo test --all-features -- --nocapture

docs:
cargo doc --all-features


clippy:
cargo clippy --all-features --no-deps

lint:
cargo fmt --check --verbose


full:
@ echo ""
cargo build --no-default-features --features=full
@ ls -sh target/debug/*.rlib

default:
@ echo ""
cargo build
@ ls -sh target/debug/*.rlib

add-ordinal-suffix:
@ echo ""
cargo build --no-default-features --features=add-ordinal-suffix
@ ls -sh target/debug/*.rlib

commas:
@ echo ""
cargo build --no-default-features --features=commas
@ ls -sh target/debug/*.rlib

digits:
@ echo ""
cargo build --no-default-features --features=digits
@ ls -sh target/debug/*.rlib

find-capital-by-province:
@ echo ""
cargo build --no-default-features --features=find-capital-by-province
@ ls -sh target/debug/*.rlib

is-persian:
@ echo ""
cargo build --no-default-features --features=is-persian
@ ls -sh target/debug/*.rlib

national-id:
@ echo ""
cargo build --no-default-features --features=national-id
@ ls -sh target/debug/*.rlib

remove-ordinal-suffix:
@ echo ""
cargo build --no-default-features --features=remove-ordinal-suffix
@ ls -sh target/debug/*.rlib

to-persian-chars:
@ echo ""
cargo build --no-default-features --features=to-persian-chars
@ ls -sh target/debug/*.rlib

url-fix:
@ echo ""
cargo build --no-default-features --features=url-fix
@ ls -sh target/debug/*.rlib

verity-card-number:
@ echo ""
cargo build --no-default-features --features=verity-card-number
@ ls -sh target/debug/*.rlib

phone-number:
@ echo ""
cargo build --no-default-features --features=phone-number
@ ls -sh target/debug/*.rlib
cargo build --no-default-features --features="phone-number serde"
@ ls -sh target/debug/*.rlib
9 changes: 3 additions & 6 deletions src/phone_number/operators.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use std::collections::HashMap;

#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};

#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Operators {
ShatelMobile,
MCI,
Expand All @@ -13,15 +10,15 @@ pub enum Operators {
RightTel,
}

#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SimType {
Permanent,
Credit,
}

#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OperatorDetails<'a> {
pub province: Vec<&'a str>,
pub base: &'a str,
Expand Down