Skip to content

Commit

Permalink
upgrade calcit 0.7 ; tag 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed May 29, 2023
1 parent 97a0149 commit 96f3523
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit_std"
version = "0.0.1"
name = "calcit_json"
version = "0.0.2"
authors = ["jiyinyiyong <[email protected]>"]
edition = "2021"

Expand All @@ -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"
11 changes: 7 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn edn_to_json(edn: &Edn) -> Result<JsonValue, String> {
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));
Expand All @@ -99,16 +99,19 @@ fn edn_to_json(edn: &Edn) -> Result<JsonValue, String> {
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 {
arr.push(edn_to_json(x)?);
}
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),
Expand Down

0 comments on commit 96f3523

Please sign in to comment.