From a75f77f8f37a385e2555f0b4ac53a41736ba0fdf Mon Sep 17 00:00:00 2001 From: Лач Date: Sat, 27 Jun 2020 20:22:50 +0000 Subject: [PATCH] feat(evaluator): utility methods for bindings --- --- a/crates/jrsonnet-evaluator/src/lib.rs +++ b/crates/jrsonnet-evaluator/src/lib.rs @@ -116,6 +116,12 @@ ..Default::default() })) } + pub fn evaluate_file_to_json( + &self, + path: &PathBuf, + ) -> std::result::Result, LocError> { + self.import_file(&PathBuf::new(), &path).and_then(|v|v.into_json(4)) + } pub fn add_file( &self, name: Rc, --- a/crates/jrsonnet-evaluator/src/obj.rs +++ b/crates/jrsonnet-evaluator/src/obj.rs @@ -52,6 +52,9 @@ value_cache: RefCell::new(HashMap::new()), })) } + pub fn new_empty() -> ObjValue { + Self::new(None, Rc::new(BTreeMap::new())) + } pub fn with_super(&self, super_obj: ObjValue) -> ObjValue { match &self.0.super_obj { None => ObjValue::new(Some(super_obj), self.0.this_entries.clone()), -- gitstuff