Skip to content

Commit

Permalink
feat(parser): auto convert keys to snake_case unless uuid or string
Browse files Browse the repository at this point in the history
  • Loading branch information
kkharji committed Jun 6, 2022
1 parent d15ef62 commit 83e09d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ tracing-subscriber = { version = "0.3.9", features = ["env-filter"], optiona
pest = { version = "2.1.3", features = ["pretty-print", "serde"] }
pest_derive = "2.1.0"
pest_consume = "1.1.1"
convert_case = "0.5.0"

[dev-dependencies]
tracing-test = "0.2.1"
Expand Down
9 changes: 7 additions & 2 deletions src/parser/pbxproj/serialize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(missing_docs)]
use super::object::PBXObjectKind;
use convert_case::{Case, Casing};
use itertools::Itertools;
use std::{collections::HashMap, isize, num::ParseIntError};

Expand All @@ -18,8 +19,12 @@ pub(crate) type Node<'i> = pest_consume::Node<'i, Rule, ()>;
impl PBXProjectParser {
fn key(input: Node) -> NodeResult<String> {
let inner = input.into_children().next().unwrap();
let value = inner.as_str();
value.to_string().pipe(Ok)

if inner.as_rule() == Rule::ident {
Ok(inner.as_str().to_case(Case::Snake))
} else {
Ok(inner.as_str().to_string())
}
}

fn string(input: Node) -> NodeResult<PBXValue> {
Expand Down

0 comments on commit 83e09d0

Please sign in to comment.