Refacto on function eval_predicate_func by splitting into multiple functions.

This commit is contained in:
jcamiel 2023-07-23 18:07:21 +02:00
parent 4b821f6c7b
commit 5f6879e779
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
3 changed files with 710 additions and 748 deletions

File diff suppressed because it is too large Load Diff

View File

@ -51,3 +51,15 @@ pub fn eval_predicate_value(
PredicateValue::Regex(regex) => Ok(Value::Regex(regex.inner.clone())),
}
}
pub fn eval_predicate_value_template(
predicate_value: &PredicateValue,
variables: &HashMap<String, Value>,
) -> Result<String, Error> {
match predicate_value {
PredicateValue::String(template) => eval_template(template, variables),
PredicateValue::Regex(regex) => Ok(regex.inner.to_string()),
// All others value should have failed in parsing:
_ => panic!("expect a string or a regex predicate value"),
}
}

View File

@ -456,6 +456,8 @@ pub enum PredicateFuncValue {
value: PredicateValue,
operator: bool,
},
// FIXME: `countEquals` predicate should be replace by `count` filter. This variant should be
// removed.
CountEqual {
space0: Whitespace,
value: PredicateValue,
@ -480,6 +482,7 @@ pub enum PredicateFuncValue {
space0: Whitespace,
value: PredicateValue,
},
// FIXME: why use an empty struct here ?
IsInteger {},
IsFloat {},
IsBoolean {},