packages feed

configurator-pg 0.2.10 → 0.2.11

raw patch · 6 files changed

+32/−8 lines, 6 filesdep +bytestringPVP ok

version bump matches the API change (PVP)

Dependencies added: bytestring

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for configurator-pg +## 0.2.11 -- 2025-10-10++* Fix loading `utf-8` file when locale encoding is set to `ASCII`+ ## 0.2.10 -- 2024-03-06  * Allow megaparsec-9.6
configurator-pg.cabal view
@@ -1,6 +1,6 @@ cabal-version:       1.12 name:                configurator-pg-version:             0.2.10+version:             0.2.11 synopsis:            Reduced parser for configurator-ng config files description:   This module provides a simplified and updated interface to the@@ -33,9 +33,10 @@                        Data.Configurator.Parser                        Data.Configurator.Syntax                        Data.Configurator.Types-  build-depends:       base                 >= 4.9 && < 4.20-                     , megaparsec           >= 7.0.0 && < 9.7-                     , containers           >= 0.5.6.2 && < 0.7+  build-depends:       base                 >= 4.9 && < 4.22+                     , bytestring           >= 0.10.8 && < 0.13+                     , megaparsec           >= 7.0.0 && < 9.8+                     , containers           >= 0.5.6.2 && < 0.8                      , protolude            >= 0.1.10 && < 0.4                      , scientific           >= 0.3.4.9 && < 0.4                      , text                 >= 1.2.2.2 && < 2.2@@ -48,10 +49,10 @@   type:                exitcode-stdio-1.0   main-is:             Test.hs   hs-source-dirs:      tests-  build-depends:       base                 >= 4.9 && < 4.20+  build-depends:       base                 >= 4.9 && < 4.22                      , configurator-pg                      , HUnit                >= 1.3.1.2 && < 1.7-                     , filepath             >= 1.4 && < 1.5+                     , filepath             >= 1.4 && < 1.6                      , protolude            >= 0.1.10 && < 0.4                      , test-framework       >= 0.8.1.1 && < 0.9                      , test-framework-hunit >= 0.3.0.2 && < 0.4
src/Data/Configurator/Load.hs view
@@ -6,10 +6,12 @@  import           Control.Exception                (throw) import           Text.Megaparsec                  (parse, errorBundlePretty)+import qualified Data.ByteString                  as BS import qualified Data.Map.Strict                  as M import           Data.Scientific                  (toBoundedInteger,                                                    toRealFloat) import qualified Data.Text                        as T+import qualified Data.Text.Encoding               as T import qualified Data.Text.Lazy                   as TL import           Data.Text.Lazy.Builder           (fromString,                                                    fromText,@@ -31,7 +33,7 @@  loadOne :: Path -> IO [Directive] loadOne path = do-  s <- readFile (T.unpack path)+  s <- T.decodeUtf8 <$> BS.readFile (T.unpack path)   case parse topLevel (T.unpack path) s of     Left err         -> throw $ ParseError $ T.pack $ errorBundlePretty err     Right directives -> return directives
tests/Test.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE CPP #-}  module Main where @@ -7,6 +8,8 @@  import           Data.Configurator import qualified Data.Text                      as T+import qualified GHC.IO.Encoding                as E+import qualified GHC.IO.Encoding.Latin1         as E import           System.Environment import           System.FilePath import           Test.Framework@@ -20,6 +23,7 @@ tests =     [ testCase "read-simple" $ readTest "simple.cfg"     , testCase "read-pathological" $ readTest "pathological.cfg"+    , testCase "read-utf-8-with-ascii-locale" $ readTestWithLocale "utf-8.cfg" E.ascii     , testCase "load" loadTest     , testCase "load" loadTest     , testCase "types" typesTest@@ -51,6 +55,9 @@ errorFile :: FilePath -> FilePath errorFile name = testFile name <> ".err" +errorFileGHC8 :: FilePath -> FilePath+errorFileGHC8 name = testFile name <> ".err.ghc8"+ parse :: Config -> Parser Value a -> Key -> Either Text a parse cfg p key = runParser (required key p) cfg @@ -63,6 +70,10 @@ readTest :: FilePath -> Assertion readTest file = load (testFile file) >> return () +readTestWithLocale :: FilePath -> E.TextEncoding -> Assertion+readTestWithLocale file locale =+  E.setLocaleEncoding locale >> load (testFile file) >> return ()+ loadTest :: Assertion loadTest =   withLoad "pathological.cfg" $ \cfg -> do@@ -233,7 +244,11 @@  ioErrorTest :: FilePath -> Assertion ioErrorTest file = do+#if __GLASGOW_HASKELL__ >= 900   err <- readFile $ errorFile file+#else+  err <- readFile $ errorFileGHC8 file+#endif   (load (testFile file) >> assertFailure "expected an IO error")     `catch` \ (ex :: IOException) -> do        assertEqual "" err (show ex)
tests/resources/err-import.cfg.err view
@@ -1,1 +1,1 @@-tests/resources/not-exist.cfg: openFile: does not exist (No such file or directory)+tests/resources/not-exist.cfg: withBinaryFile: does not exist (No such file or directory)
+ tests/resources/utf-8.cfg view
@@ -0,0 +1,2 @@+# Commènt utf-8 chàrs+utf-kèy = "utf-8-vàlue"