git.delta.rocks / jrsonnet / refs/commits / a75f77f8f37a

difftreelog

feat(evaluator) utility methods for bindings

Лач2020-06-27parent: #2cabc72.patch.diff
in: master

2 files changed

modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- 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<Rc<str>, LocError> {
+		self.import_file(&PathBuf::new(), &path).and_then(|v|v.into_json(4))
+	}
 	pub fn add_file(
 		&self,
 		name: Rc<PathBuf>,
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
52 value_cache: RefCell::new(HashMap::new()),52 value_cache: RefCell::new(HashMap::new()),
53 }))53 }))
54 }54 }
55 pub fn new_empty() -> ObjValue {
56 Self::new(None, Rc::new(BTreeMap::new()))
57 }
55 pub fn with_super(&self, super_obj: ObjValue) -> ObjValue {58 pub fn with_super(&self, super_obj: ObjValue) -> ObjValue {
56 match &self.0.super_obj {59 match &self.0.super_obj {
57 None => ObjValue::new(Some(super_obj), self.0.this_entries.clone()),60 None => ObjValue::new(Some(super_obj), self.0.this_entries.clone()),