From ddec342b0102095e389cbe716cc4d16eb54d7dba Mon Sep 17 00:00:00 2001 From: Mathieu David Date: Fri, 19 Feb 2016 14:21:40 +0100 Subject: [PATCH] Add implementation for retrieving title and description from toml configuration file, the incomplete test now passes --- src/config/mod.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 8721622a..65ff91cd 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -141,7 +141,19 @@ impl Config { }, }; - // Retrieve toml values + // Retrieve toml value + if let Some(value) = config.get("title") { + if let Some(title) = value.as_str() { + self.title = String::from(title) + } + } + + if let Some(value) = config.get("description") { + if let Some(description) = value.as_str() { + self.description = String::from(description) + } + } + Ok(()) } @@ -309,8 +321,7 @@ mod tests { let toml = r##"title = "mdBook" description = """ -This is a command line utility to generate books from markdown files -""" +This is a command line utility to generate books from markdown files""" [[author]] name = "Mathieu David" @@ -359,6 +370,6 @@ rust-playpen = { enabled = true } config.fill_config(toml); assert_eq!(config.title(), "mdBook"); - assert_eq!(config.description(), "mdBook is a utility to create books from markdown files"); + assert_eq!(config.description(), "This is a command line utility to generate books from markdown files"); } }