summaryrefslogtreecommitdiffstats
path: root/src/file/format/yaml.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/file/format/yaml.rs')
-rw-r--r--src/file/format/yaml.rs26
1 files changed, 3 insertions, 23 deletions
diff --git a/src/file/format/yaml.rs b/src/file/format/yaml.rs
index b1afce7..1cba0d3 100644
--- a/src/file/format/yaml.rs
+++ b/src/file/format/yaml.rs
@@ -6,14 +6,10 @@ use std::collections::{BTreeMap, HashMap};
use std::mem;
use value::{Value, ValueKind};
-pub fn parse(uri: Option<&String>,
- text: &str,
- namespace: Option<&String>)
- -> Result<HashMap<String, Value>, Box<Error>> {
+pub fn parse(uri: Option<&String>, text: &str) -> Result<HashMap<String, Value>, Box<Error>> {
+ // Parse a YAML object from file
let mut docs = yaml::YamlLoader::load_from_str(text)?;
-
- // Designate root
- let mut root = match docs.len() {
+ let root = match docs.len() {
0 => yaml::Yaml::Hash(BTreeMap::new()),
1 => mem::replace(&mut docs[0], yaml::Yaml::Null),
n => {
@@ -21,22 +17,6 @@ pub fn parse(uri: Option<&String>,
}
};
- // Limit to namespace
- if let Some(namespace) = namespace {
- root = yaml::Yaml::Hash(match root {
- yaml::Yaml::Hash(ref mut table) => {
- if let Some(yaml::Yaml::Hash(table)) =
- table.remove(&yaml::Yaml::String(namespace.clone())) {
- table
- } else {
- BTreeMap::new()
- }
- }
-
- _ => BTreeMap::new(),
- });
- };
-
// TODO: Have a proper error fire if the root of a file is ever not a Table
let value = from_yaml_value(uri, &root);
match value.kind {