From 96f3523308c9697c92b94f8d23eb4eb218862df4 Mon Sep 17 00:00:00 2001 From: tiye Date: Tue, 30 May 2023 01:27:58 +0800 Subject: [PATCH] upgrade calcit 0.7 ; tag 0.0.2 --- .github/workflows/check.yaml | 27 +++++++++++++++------------ Cargo.lock | 8 ++++---- Cargo.toml | 6 +++--- src/lib.rs | 11 +++++++---- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index a7ac6d6..8c54648 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -13,21 +13,24 @@ jobs: steps: - uses: actions/checkout@v3 - - name: ACTIONS_ALLOW_UNSECURE_COMMANDS - id: ACTIONS_ALLOW_UNSECURE_COMMANDS - run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV - - - name: add cr - run: | - mkdir -p $GITHUB_WORKSPACE/bin - wget -O $GITHUB_WORKSPACE/bin/cr https://github.com/calcit-lang/calcit/releases/download/0.6.21/cr - chmod +x $GITHUB_WORKSPACE/bin/cr - echo "::add-path::$GITHUB_WORKSPACE/bin" - - - uses: actions-rs/toolchain@v1 + - uses: supplypike/setup-bin@v3 + with: + uri: 'https://github.com/calcit-lang/calcit/releases/download/0.7.0-a3/cr' + name: 'cr' + version: '0.7.0-a3' + + - uses: supplypike/setup-bin@v3 + with: + uri: 'https://github.com/calcit-lang/calcit/releases/download/0.7.0-a3/caps' + name: 'caps' + version: '0.7.0-a3' + + - uses: dtolnay/rust-toolchain@stable with: toolchain: stable + - uses: Swatinem/rust-cache@v2 + - run: cargo build --release - run: rm -rfv dylibs/* && mkdir dylibs/ && ls target/release/ && cp -v target/release/*.* dylibs/ diff --git a/Cargo.lock b/Cargo.lock index 9f61c77..a819c8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,8 +3,8 @@ version = 3 [[package]] -name = "calcit_std" -version = "0.0.1" +name = "calcit_json" +version = "0.0.2" dependencies = [ "cirru_edn", "cirru_parser", @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "cirru_edn" -version = "0.2.21" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63c8eadc7d7e440b6e2dce8b6ef16e688dc1a36dfcac8a627a1e769672664955" +checksum = "37f78b9daa64e28a97fb4879b9d3a3c4c0c50ad8e14698a6a4fb9db9868bfd43" dependencies = [ "cirru_parser", "hex", diff --git a/Cargo.toml b/Cargo.toml index 2352a3d..c7344bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "calcit_std" -version = "0.0.1" +name = "calcit_json" +version = "0.0.2" authors = ["jiyinyiyong "] edition = "2021" @@ -13,7 +13,7 @@ crate-type = ["dylib"] # Creates dynamic lib # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cirru_edn = "0.2.21" +cirru_edn = "0.4.0" cirru_parser = "0.1.24" json = "0.12.4" hex = "0.4.3" diff --git a/src/lib.rs b/src/lib.rs index 555a1ab..800f1b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,7 +90,7 @@ fn edn_to_json(edn: &Edn) -> Result { for (k, v) in map { if let Edn::Str(k) = k { obj.insert(k, edn_to_json(v)?); - } else if let Edn::Keyword(k) = k { + } else if let Edn::Tag(k) = k { obj.insert(&k.to_str(), edn_to_json(v)?); } else { return Err(format!("json-parse expected string, got {:?}", k)); @@ -99,7 +99,7 @@ fn edn_to_json(edn: &Edn) -> Result { Ok(JsonValue::Object(obj)) } Edn::Symbol(s) => Ok(JsonValue::String(s.to_string())), - Edn::Keyword(s) => Ok(JsonValue::String(s.to_string())), + Edn::Tag(s) => Ok(JsonValue::String(s.to_string())), Edn::Set(xs) => { let mut arr = Vec::new(); for x in xs { @@ -107,8 +107,11 @@ fn edn_to_json(edn: &Edn) -> Result { } Ok(JsonValue::Array(arr)) } - Edn::Tuple(pair) => { - let arr = vec![edn_to_json(&pair.0.to_owned())?, edn_to_json(&pair.1.to_owned())?]; + Edn::Tuple(tag, extra) => { + let mut arr = vec![edn_to_json(&tag.to_owned())?]; + for item in extra { + arr.push(edn_to_json(&item.to_owned())?); + } Ok(JsonValue::Array(arr)) } Edn::Quote(x) => cirru_to_json(x),