Commit a8d53e51 authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

feat: Add toml library; minor tweak to EnvironmentValue method

parent feadcb7c
Loading
Loading
Loading
Loading
Loading
+49 −2
Original line number Diff line number Diff line
@@ -2252,6 +2252,7 @@ dependencies = [
 "serde_yml",
 "sha2",
 "tokio",
 "toml",
 "tracing",
 "tracing-log",
 "tracing-subscriber",
@@ -2360,7 +2361,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
dependencies = [
 "once_cell",
 "toml_edit",
 "toml_edit 0.19.15",
]

[[package]]
@@ -2733,6 +2734,15 @@ dependencies = [
 "syn 2.0.76",
]

[[package]]
name = "serde_spanned"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
dependencies = [
 "serde",
]

[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -3130,11 +3140,26 @@ dependencies = [
 "tokio",
]

[[package]]
name = "toml"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
dependencies = [
 "serde",
 "serde_spanned",
 "toml_datetime",
 "toml_edit 0.22.22",
]

[[package]]
name = "toml_datetime"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
dependencies = [
 "serde",
]

[[package]]
name = "toml_edit"
@@ -3144,7 +3169,20 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
 "indexmap",
 "toml_datetime",
 "winnow",
 "winnow 0.5.40",
]

[[package]]
name = "toml_edit"
version = "0.22.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
dependencies = [
 "indexmap",
 "serde",
 "serde_spanned",
 "toml_datetime",
 "winnow 0.6.20",
]

[[package]]
@@ -3774,6 +3812,15 @@ dependencies = [
 "memchr",
]

[[package]]
name = "winnow"
version = "0.6.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
dependencies = [
 "memchr",
]

[[package]]
name = "winsafe"
version = "0.0.19"
+1 −32
Original line number Diff line number Diff line
%% Cell type:code id: tags:

``` rust
:dep pipe-lib = { path = "../pipe-lib" }
```

%% Cell type:code id: tags:

``` rust
:dep reqwest
:dep tokio = { version = "1.39.2", features = ["rt", "time", "rt-multi-thread"] }
:dep bytes
```

%% Cell type:code id: tags:

``` rust
use std::fs;
use std::path::PathBuf;

fn path_to_string(value: PathBuf) -> String {
    let path = value.as_path().as_os_str().to_str().unwrap().to_string();
    match fs::canonicalize(path.clone()) {
        | Ok(value) => value.to_str().unwrap().to_string(),
        | Err(_) => path,
    }
}

let path = "../";
let children = match fs::read_dir(path) {
    | Ok(value) => value.flat_map(|x| x).map(|x| x.path()).map(path_to_string).collect::<Vec<_>>(),
    | Err(_) => Vec::new(),
};

children
:dep toml
```

%% Output

    ["/root/dev/command/pipe-py", "/root/dev/command/pipe-cli", "/root/dev/command/.git", "/root/dev/command/CITATION.cff", "/root/dev/command/pipe-lib", "/root/dev/command/tests", "/root/dev/command/Makefile", "/root/dev/command/ROADMAP.md", "/root/dev/command/notebooks", "/root/dev/command/Cargo.lock", "/root/dev/command/target", "/root/dev/command/Cross.toml", "/root/dev/command/.rustfmt.toml", "/root/dev/command/.vscode", "/root/dev/command/.gitlab-ci.yml", "/root/dev/command/ARCHITECTURE.md", "/root/dev/command/LICENSE", "/root/dev/command/CONTRIBUTING.md", "/root/dev/command/README.md", "/root/dev/command/lcov.info", "/root/dev/command/.gitignore", "/root/dev/command/Cargo.toml"]

%% Cell type:code id: tags:

``` rust
std::env::current_dir()
```

%% Output

    Ok("/root/dev/command/notebooks")

%% Cell type:code id: tags:

``` rust
```
+1 −0
Original line number Diff line number Diff line
@@ -33,3 +33,4 @@ which = "6.0.3"
reqwest = "0.12.8"
bytes = "1.7.2"
is_executable = "1.0.4"
toml = "0.8.19"
+4 −5
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use rayon::prelude::*;
use serde::ser::StdError;
use serde::{Deserialize, Serialize};
use serde_json::{Map, Number, Value};
use serde_yml;
use sha2::{Digest, Sha256};
use std::collections::HashMap;
use std::convert::TryFrom;
@@ -943,10 +944,8 @@ impl PartialEq for Details {
}
impl EnvironmentValue {
    pub const PREFIX: &'static str = "pipe";

    fn from_string(value: String) -> EnvironmentValue {
        EnvironmentValue::String(value)
    }
    /// Convert serde Value to EnvironmentValue
    /// 
    fn from_value(value: Value) -> EnvironmentValue {
        match value {
            | Value::String(val) => EnvironmentValue::String(val),
@@ -1005,7 +1004,7 @@ impl EnvironmentValue {
    pub fn set_variables(values: HashMap<String, String>) {
        values
            .into_iter()
            .for_each(|(key, value)| EnvironmentValue::from_string(value).set_variable(key));
            .for_each(|(key, value)| EnvironmentValue::String(value).set_variable(key));
    }
}
impl Extension {