diff options
author | Ryan Leckey <ryan@launchbadge.com> | 2017-06-16 11:45:23 -0700 |
---|---|---|
committer | Ryan Leckey <ryan@launchbadge.com> | 2017-06-16 11:45:23 -0700 |
commit | be251fef2cfcf79a34f5c4e5086c715234281b5e (patch) | |
tree | e60fcfd50c24b047d9b1d28c4a5ac08363db7bf2 | |
parent | 05e9cd421e75173462072e57ab7e27881730d250 (diff) |
Fix a couple issues, mainly with env source
-rw-r--r-- | src/config.rs | 9 | ||||
-rw-r--r-- | src/env.rs | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/config.rs b/src/config.rs index c355f2d..44c51d1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use std::str::FromStr; use serde::de::Deserialize; use error::*; @@ -88,7 +89,13 @@ impl Config { for source in sources { let props = source.collect()?; for (key, val) in &props { - path::Expression::Identifier(key.clone()).set(&mut cache, val.clone()); + match path::Expression::from_str(key) { + // Set using the path + Ok(expr) => expr.set(&mut cache, val.clone()), + + // Set diretly anyway + _ => path::Expression::Identifier(key.clone()).set(&mut cache, val.clone()) + } } } @@ -28,8 +28,8 @@ impl Environment { Environment::default() } - pub fn with_prefix(s: String) -> Self { - Environment { separator: s, ..Environment::default() } + pub fn with_prefix(s: &str) -> Self { + Environment { prefix: Some(s.into()), ..Environment::default() } } pub fn prefix(&mut self, s: String) -> &mut Self { @@ -68,7 +68,7 @@ impl Source for Environment { // Check for prefix if let Some(ref prefix_pattern) = prefix_pattern { - if key.starts_with(prefix_pattern) { + if key.to_lowercase().starts_with(prefix_pattern) { // Remove this prefix from the key key = key[prefix_pattern.len()..].to_string(); } else { @@ -80,7 +80,7 @@ impl Source for Environment { // Replace `separator` with `.` key = key.replace(&self.separator, "."); - m.insert(key, Value::new(Some(&uri), ValueKind::String(value))); + m.insert(key.to_lowercase(), Value::new(Some(&uri), ValueKind::String(value))); } Ok(m) |