diff options
author | Ryan Leckey <ryan@launchbadge.com> | 2017-06-22 15:57:14 -0700 |
---|---|---|
committer | Ryan Leckey <ryan@launchbadge.com> | 2017-06-22 15:57:14 -0700 |
commit | 159bb52c595384fed44a2c669198d50f2a758a9a (patch) | |
tree | 6553ceed3e172115fe8e682bbfc286bf8fd0f004 /src/file/format/yaml.rs | |
parent | a9eecf075cf01f15ef05fea3f1edaa189446d055 (diff) |
Remove `namespace` option for File
Diffstat (limited to 'src/file/format/yaml.rs')
-rw-r--r-- | src/file/format/yaml.rs | 26 |
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 { |