packages feed

app-settings 0.2.0.2 → 0.2.0.3

raw patch · 5 files changed

+33/−23 lines, 5 filesdep ~hspecPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hspec

API changes (from Hackage documentation)

Files

Data/AppSettings.hs view
@@ -19,6 +19,7 @@ import System.Directory import qualified Data.Map as M import Control.Monad.State+import Control.Applicative  import Data.Serialization import Data.AppSettingsInternal@@ -105,8 +106,8 @@ -- readResult <- try $ readSettings (Path \"my.config\") -- case readResult of -- 	Right (conf, GetSetting getSetting) -> do--- 		let textSize = getSetting textSizeFromWidth--- 		saveSettings getDefaultConfig (Path \"my.config\") conf+-- 		let textSize = getSetting fontSize+-- 		saveSettings emptyDefaultConfig (Path \"my.config\") conf -- 	Left (x :: SomeException) -> error \"Error reading the config file!\" -- @ readSettings :: FileLocation -> IO (Conf, GetSetting)@@ -152,7 +153,7 @@ 	return result  getConfigFileName :: String -> IO String-getConfigFileName appName = fmap (++"config.ini") $ getSettingsFolder appName+getConfigFileName appName = (++"config.ini") <$> getSettingsFolder appName  -- $intro --@@ -237,10 +238,12 @@ -- > readResult <- try $ readSettings (AutoFromAppName "test") -- > case readResult of -- > 	Right (conf, GetSetting getSetting) -> do--- > 		let textSize = getSetting textSizeFromWidth--- > 		saveSettings getDefaultConfig (AutoFromAppName "test") conf+-- > 		let textSize = getSetting fontSize+-- > 		saveSettings emptyDefaultConfig (AutoFromAppName "test") conf -- > 	Left (x :: SomeException) -> error "Error reading the config file!" -- -- 'AutoFromAppName' specifies where to save the configuration file. -- And we've already covered the getSetting in this snippet, see  -- the 'readSettings' documentation for further information.+-- +-- You can also look at the tests of the library on the github project for sample use.
Data/AppSettingsInternal.hs view
@@ -60,7 +60,7 @@  isKeyForListSetting :: String -> String -> Bool isKeyForListSetting settingKey key = (settingKey ++ "_") `isPrefixOf` key-	&& (all isDigit $ drop (length settingKey+1) key)+	&& all isDigit (drop (length settingKey+1) key)   -- TODO maybe another getSetting that'll tell you
Data/Serialization.hs view
@@ -31,7 +31,8 @@ readConfigFile path = do 	contents <- T.readFile path 	case parse parseConfigFile "" contents of-		Left _ -> throwIO $ ParseException path "Invalid configuration file"+		Left pe -> throwIO (ParseException path+			$ "Invalid configuration file " ++ show (errorPos pe)) 		Right v -> return v  data ConfigElement = ConfigEntry String String@@ -43,25 +44,31 @@  parseConfigFile :: T.GenParser st Conf parseConfigFile = do-	elements <- many $ parseComment <|> parseConfigEntry+	elements <- many $ comment <|> configEntry <|> emptyLine 	let configEntries = filter isConfigEntry elements 	return $ M.fromList $ map (\(ConfigEntry a b) -> 		(a, SettingInfo {value=b, userSet=True})) configEntries -parseComment :: T.GenParser st ConfigElement-parseComment = do+comment :: T.GenParser st ConfigElement+comment = do 	char '#' 	many $ noneOf "\r\n"-	many $ oneOf "\r\n"+	many1 $ oneOf "\r\n" 	return Comment -parseConfigEntry :: T.GenParser st ConfigElement-parseConfigEntry = do-	key <- many $ noneOf "=\r\n"+configEntry :: T.GenParser st ConfigElement+configEntry = do+	key <- many1 $ noneOf " \t=\r\n" 	char '=' 	val <- many $ noneOf "\r\n"-	many $ oneOf "\r\n"+	many1 $ oneOf "\r\n" 	return $ ConfigEntry key val++emptyLine :: T.GenParser st ConfigElement+emptyLine = do+	many $ oneOf " \t"+	many1 $ oneOf "\r\n"+	return Comment  writeConfigFile :: FilePath -> Conf -> IO () writeConfigFile path config = do
app-settings.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                app-settings-version:             0.2.0.2+version:             0.2.0.3 synopsis:            A library to manage application settings (INI file-like) description:            A library to deal with application settings.@@ -74,13 +74,15 @@   > readResult <- try $ readSettings (AutoFromAppName "test")   > case readResult of   > 	Right (conf, GetSetting getSetting) -> do-  > 		let textSize = getSetting textSizeFromWidth-  > 		saveSettings getDefaultConfig (AutoFromAppName "test") conf+  > 		let textSize = getSetting fontSize+  > 		saveSettings emptyDefaultConfig (AutoFromAppName "test") conf   > 	Left (x :: SomeException) -> error "Error reading the config file!"   .   'AutoFromAppName' specifies where to save the configuration file.   And we've already covered the getSetting in this snippet, see    the 'readSettings' documentation for further information.+  .+  You can also look at the tests of the library on the github project for sample use.  homepage:            https://github.com/emmanueltouzery/app-settings license:             BSD3@@ -114,7 +116,7 @@   main-is: Tests.hs   default-language:    Haskell2010   build-depends:       base,-                       hspec >= 1.8 && <1.10,+                       hspec >= 1.8 && <1.11,                        HUnit >= 1.2 && <1.3,                        mtl >= 2.1 && <2.3,                        containers == 0.5.*,
tests/Tests.hs view
@@ -34,8 +34,7 @@  main :: IO () main = hspec $ do-	describe "unit tests" $ do-		testIsKeyForListSetting+	describe "unit tests" testIsKeyForListSetting 	describe "load config" $ do 		testEmptyFileDefaults 		testPartialFileDefaults@@ -47,8 +46,7 @@ 	describe "save config" $ do 		testSaveUserSetAndDefaults 		createBakBeforeSaving-	describe "set setting" $ do-		testSetListSetting+	describe "set setting" testSetListSetting  testEmptyFileDefaults :: Spec testEmptyFileDefaults = it "parses correctly an empty file with defaults" $ do