From 26fc980ffb8fd690115025f0d99c101660736e9a Mon Sep 17 00:00:00 2001 From: Mathieu David Date: Fri, 23 Jun 2017 00:48:59 +0200 Subject: [PATCH] Remove 'curly_quotes' key from the json config --- src/config/bookconfig.rs | 14 ++++---------- src/config/jsonconfig.rs | 9 +++------ tests/jsonconfig.rs | 15 --------------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/config/bookconfig.rs b/src/config/bookconfig.rs index 32182854..e78dcabc 100644 --- a/src/config/bookconfig.rs +++ b/src/config/bookconfig.rs @@ -113,7 +113,7 @@ impl BookConfig { htmlconfig.fill_from_tomlconfig(root, tomlhtmlconfig); } } - + self } @@ -160,12 +160,6 @@ impl BookConfig { } } - if let Some(curly_quotes) = jsonconfig.curly_quotes { - if let Some(htmlconfig) = self.get_mut_html_config() { - htmlconfig.set_curly_quotes(curly_quotes); - } - } - self } @@ -177,16 +171,16 @@ impl BookConfig { pub fn get_root(&self) -> &Path { &self.root } - + pub fn set_source>(&mut self, source: T) -> &mut Self { let mut source = source.into(); - + // If the source path is relative, start with the root path if source.is_relative() { source = self.root.join(source); } - self.source = source; + self.source = source; self } diff --git a/src/config/jsonconfig.rs b/src/config/jsonconfig.rs index 3aa264f1..f41f8763 100644 --- a/src/config/jsonconfig.rs +++ b/src/config/jsonconfig.rs @@ -13,7 +13,6 @@ pub struct JsonConfig { pub description: Option, pub theme_path: Option, - pub curly_quotes: Option, pub google_analytics: Option, } @@ -25,9 +24,9 @@ pub struct JsonConfig { /// # use std::path::PathBuf; /// let json = r#"{ /// "title": "Some title", -/// "dest": "htmlbook" +/// "dest": "htmlbook" /// }"#; -/// +/// /// let config = JsonConfig::from_json(&json).expect("Should parse correctly"); /// assert_eq!(config.title, Some(String::from("Some title"))); /// assert_eq!(config.dest, Some(PathBuf::from("htmlbook"))); @@ -36,9 +35,7 @@ impl JsonConfig { pub fn from_json(input: &str) -> Result { let config: JsonConfig = serde_json::from_str(input) .map_err(|e| format!("Could not parse JSON: {}", e))?; - + return Ok(config); } } - - diff --git a/tests/jsonconfig.rs b/tests/jsonconfig.rs index 64029aff..12b8d58b 100644 --- a/tests/jsonconfig.rs +++ b/tests/jsonconfig.rs @@ -85,18 +85,3 @@ fn from_json_output_html_theme() { assert_eq!(htmlconfig.get_theme().expect("the theme key was provided"), &PathBuf::from("root/theme")); } - -// Tests that the `curly_quotes` key is correctly parsed in the JSON config -#[test] -fn from_json_output_html_curly_quotes() { - let json = r#"{ - "curly_quotes": true - }"#; - - let parsed = JsonConfig::from_json(&json).expect("This should parse"); - let config = BookConfig::from_jsonconfig("root", parsed); - - let htmlconfig = config.get_html_config().expect("There should be an HtmlConfig"); - - assert_eq!(htmlconfig.get_curly_quotes(), true); -}