Remove 'curly_quotes' key from the json config

This commit is contained in:
Mathieu David 2017-06-23 00:48:59 +02:00
parent d252dc82d6
commit 26fc980ffb
3 changed files with 7 additions and 31 deletions

View file

@ -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<T: Into<PathBuf>>(&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
}

View file

@ -13,7 +13,6 @@ pub struct JsonConfig {
pub description: Option<String>,
pub theme_path: Option<PathBuf>,
pub curly_quotes: Option<bool>,
pub google_analytics: Option<String>,
}
@ -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<Self, String> {
let config: JsonConfig = serde_json::from_str(input)
.map_err(|e| format!("Could not parse JSON: {}", e))?;
return Ok(config);
}
}

View file

@ -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);
}