Skip to content

Commit

Permalink
Merge pull request #35 from sancane/issues
Browse files Browse the repository at this point in the history
Issues
  • Loading branch information
sancane authored Oct 5, 2023
2 parents 09224f2 + 378b0f4 commit 66b0048
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 40 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ jobs:
- name: Run tests
run: cargo test --verbose

cargo_check:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install cargo-sort
run: cargo install --locked cargo-sort
- run: cargo sort -w -c

spellcheck:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install cargo-spellcheck
run: cargo install --locked cargo-spellcheck
- run: cargo spellcheck -m 99 --cfg=.github/workflows/spellchecker.cfg
# cargo_check:
#
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v2
# - name: Install cargo-sort
# run: cargo install --locked cargo-sort
# - run: cargo sort -w -c

# spellcheck:

# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v2
# - name: Install cargo-spellcheck
# run: cargo install --locked cargo-spellcheck
# - run: cargo spellcheck -m 99 --cfg=.github/workflows/spellchecker.cfg
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ members = [
"precis-profiles",
"precis-tools",
]

[workspace.dependencies]
lazy_static = "1.4.0"
precis-core = { path = "precis-core" }
precis-profiles = { path = "precis-profiles" }
precis-tools = { path = "precis-tools" }
regex = "1"
reqwest = { version = "0.11.4", features = ["blocking"] }
ucd-parse = "0.1.8"
unicode-normalization = "0.1.19"
12 changes: 6 additions & 6 deletions precis-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "precis-core"
version = "0.1.8"
version = "0.1.9"
authors = ["Santiago Carot-Nemesio <sancane@gmail.com>"]
description = """
PRECIS Framework: Preparation, Enforcement, and Comparison of
Expand All @@ -17,15 +17,15 @@ categories = ["text-processing", "internationalization"]
edition = "2018"

[dev-dependencies]
precis-tools = { path = "../precis-tools", version = "0.1.6" }
ucd-parse = "0.1.8"
precis-tools.workspace = true
ucd-parse.workspace = true

[build-dependencies]
precis-tools = { path = "../precis-tools", version = "0.1.6" }
ucd-parse = "0.1.8"
precis-tools.workspace = true
ucd-parse.workspace = true

[dependencies]
unicode-normalization = "0.1.19"
unicode-normalization.workspace = true

[features]
networking = ["precis-tools/networking"]
6 changes: 3 additions & 3 deletions precis-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ mod networking {

fn create_dir(path: &Path) {
if !path.is_dir() {
fs::create_dir(&path).unwrap();
fs::create_dir(path).unwrap();
}
}

Expand Down Expand Up @@ -210,8 +210,8 @@ fn main() {
let out_path = Path::new(&out_dir);
let ucd_path = Path::new(&out_path).join("ucd");

networking::download_files(&out_path);
generate_code(&ucd_path, &out_path);
networking::download_files(out_path);
generate_code(&ucd_path, out_path);

println!("cargo:rerun-if-changed=build.rs");
}
Expand Down
10 changes: 5 additions & 5 deletions precis-profiles/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "precis-profiles"
version = "0.1.8"
version = "0.1.9"
authors = ["Santiago Carot-Nemesio <sancane@gmail.com"]
description = """
Implementation of the PRECIS Framework: Preparation, Enforcement,
Expand All @@ -18,12 +18,12 @@ categories = ["text-processing", "internationalization"]
edition = "2018"

[build-dependencies]
precis-tools = { path = "../precis-tools", version = "0.1.6" }
precis-tools.workspace = true

[dependencies]
lazy_static = "1.4.0"
precis-core = { path = "../precis-core", version = "0.1.8" }
unicode-normalization = "0.1.19"
lazy_static.workspace = true
precis-core.workspace = true
unicode-normalization.workspace = true

[features]
networking = ["precis-core/networking", "precis-tools/networking"]
4 changes: 2 additions & 2 deletions precis-profiles/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod download_ucd {

pub fn create_dir(path: &Path) {
if !path.is_dir() {
fs::create_dir(&path).unwrap();
fs::create_dir(path).unwrap();
}
}
}
Expand All @@ -61,7 +61,7 @@ fn main() {

precis_tools::download::get_ucd_file(UNICODE_VERSION, &ucd_path, "UnicodeData.txt").unwrap();

generate_code(&ucd_path, &out_path);
generate_code(&ucd_path, out_path);

println!("cargo:rerun-if-changed=build.rs");
}
Expand Down
10 changes: 5 additions & 5 deletions precis-tools/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "precis-tools"
version = "0.1.6"
version = "0.1.7"
authors = ["Santiago Carot-Nemesio <sancane@gmail.com>"]
description = """
Tools and parsers to generate PRECIS tables from the Unicode Character Database (UCD)
Expand All @@ -15,10 +15,10 @@ categories = ["text-processing", "internationalization"]
edition = "2018"

[dependencies]
lazy_static = "1.4.0"
regex = "1"
reqwest = { version = "0.11.4", features = ["blocking"], optional = true }
ucd-parse = "0.1.8"
lazy_static.workspace = true
regex.workspace = true
reqwest = { workspace = true, optional = true }
ucd-parse.workspace = true

[features]
networking = ["reqwest"]
15 changes: 15 additions & 0 deletions precis-tools/src/download.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Module for downloading files from the internet.

use crate::Error;
use reqwest::header::USER_AGENT;
use std::env;
Expand Down Expand Up @@ -34,12 +36,25 @@ fn download(url: &str, dest: &Path) -> Result<(), Error> {
Ok(fs::write(dest, text)?)
}

/// Gets a ucd file from the Internet
/// # Arguments
/// * `ucd_version`: Unicode version
/// * `dest`: Destination directory
/// * `file`: File name
/// # Returns
/// `Ok(())` if the file was downloaded successfully, `Err(Error)` otherwise
pub fn get_ucd_file(ucd_version: &str, dest: &Path, file: &str) -> Result<(), Error> {
let url = format!("{}/{}", get_unicode_ucd_uri(ucd_version), file);
let dest_path = dest.join(file);
download(&url, &dest_path)
}

/// Gets a csv file from the Internet
/// # Arguments
/// * `ucd_version`: Unicode version
/// * `dest`: Destination directory
/// # Returns
/// `Ok(())` if the file was downloaded successfully, `Err(Error)` otherwise
pub fn get_csv_file(ucd_version: &str, dest: &Path) -> Result<(), Error> {
let dest_path = dest.join(get_csv_file_name(ucd_version));
download(&get_precis_csv_tables_uri(ucd_version), &dest_path)
Expand Down

0 comments on commit 66b0048

Please sign in to comment.