-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support top level items and add LOC to CI
- Loading branch information
1 parent
9b4ffae
commit 65901fd
Showing
8 changed files
with
212 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Update LOC metrics (lines of code) | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Download scc | ||
run: | | ||
mkdir scc | ||
cd scc | ||
gh release download v3.1.0 -R boyter/scc -p '*Linux_x86_64.tar.gz' -O scc.tar.gz | ||
tar -xf scc.tar.gz | ||
chmod +x scc | ||
pwd >> $GITHUB_PATH | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
|
||
- name: Run update script | ||
run: | | ||
name="simple-json-parser" | ||
lines_of_code=$(scc -c --no-cocomo -f json -i rs lib.rs | jq '.[] | .Code'); | ||
echo "\`$name\` has $lines_of_code lines of code" >> $GITHUB_STEP_SUMMARY; | ||
curl \ | ||
--header "Content-Type: application/json" \ | ||
--header "X-POST-ACCESS-KEY: ${{ secrets.PROJECTS_POST_ACCESS_KEY }}" \ | ||
--data "{\"project\":\"$name\",\"language\":\"rust\",\"loc\":$lines_of_code}" \ | ||
-w "\nUpdated-project: \n" \ | ||
https://kaleidawave-projectinformation.web.val.run/update-project; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,3 @@ path = "lib.rs" | |
|
||
[lints.clippy] | ||
pedantic = "deny" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
# JSON parser/lexer | ||
|
||
![lines of code](https://kaleidawave-projectinformation.web.val.run/project/simple-json-parser/badge) | ||
[![crates.io badge](https://img.shields.io/crates/v/simple-json-parser?style=flat-square)](https://crates.io/crates/simple-json-parser) | ||
[![docs.rs badge](https://img.shields.io/docsrs/simple-json-parser?style=flat-square)](https://docs.rs/simple-json-parser/latest) | ||
|
||
Features | ||
- Under < 200 LOC Rust lexer (+ no dependencies) | ||
- Visiting / callback based API (no allocation) | ||
- Under < 200 LOC Rust lexer | ||
- No dependencies | ||
- Visiting / callback based API (avoids allocations) | ||
- Handles single and multiline comments in JSON | ||
|
||
See examples and tests for usage. | ||
See [examples](/examples/) and [tests](/tests/) for usage. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use simple_json_parser::parse; | ||
|
||
fn main() { | ||
let content = r#"// Something | ||
{ | ||
"a": 2, | ||
// Another | ||
"b": 5, | ||
# another comment | ||
}"#; | ||
|
||
let result = parse(content, |keys, value| { | ||
eprintln!("{keys:?} -> {value:?}"); | ||
}); | ||
|
||
assert!(result.is_ok()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use simple_json_parser::parse; | ||
|
||
fn main() { | ||
let to_parse = &[ | ||
"199", | ||
"\"Hiya\"", | ||
"[1, 2, \"something\"]", | ||
"true", | ||
"false", | ||
"null", | ||
]; | ||
|
||
for item in to_parse { | ||
eprintln!("parsing {item} as JSON"); | ||
let result = parse(item, |keys, value| { | ||
eprintln!("{keys:?} -> {value:?}"); | ||
}); | ||
|
||
assert!(result.is_ok()); | ||
} | ||
} |
Oops, something went wrong.