etc 0.0.0.2 → 0.1.0.0
raw patch · 6 files changed
+68/−6 lines, 6 filesdep ~aesonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson
API changes (from Hackage documentation)
- System.Etc: parseConfigSpec :: (MonadCatch m, FromJSON cmd) => Text -> m (ConfigSpec cmd)
+ System.Etc: parseConfigSpec :: (MonadCatch m) => Text -> m (ConfigSpec ())
- System.Etc: readConfigSpec :: FromJSON cmd => Text -> IO (ConfigSpec cmd)
+ System.Etc: readConfigSpec :: Text -> IO (ConfigSpec ())
- System.Etc.Spec: parseConfigSpec :: (MonadCatch m, FromJSON cmd) => Text -> m (ConfigSpec cmd)
+ System.Etc.Spec: parseConfigSpec :: (MonadCatch m) => Text -> m (ConfigSpec ())
- System.Etc.Spec: readConfigSpec :: FromJSON cmd => Text -> IO (ConfigSpec cmd)
+ System.Etc.Spec: readConfigSpec :: Text -> IO (ConfigSpec ())
Files
- CHANGELOG.md +15/−0
- etc.cabal +3/−3
- src/System/Etc/Internal/Extra/Printer.hs +3/−0
- src/System/Etc/Spec.hs +17/−1
- test/System/Etc/Resolver/DefaultTest.hs +26/−2
- test/System/Etc/SpecTest.hs +4/−0
CHANGELOG.md view
@@ -1,3 +1,18 @@+0.1.0.0+----+* Add support for null values on Default (issue #3)+* If cli cabal flag is false, have `parseConfigSpec` return `ConfigSpec ()`+ instead of ambiguous `FromJSON` value (issue #3)+* Bump aeson dependency to `<1.3`++0.0.0.2+----+* Rename System.Etc.Internal.Util module to System.Etc.Internal.Extra+* Rename cabal flag from printer to extra+* Add feature for Environment Variable misspelling reports+* Add misspelling reports to example projects+* Improvements on README+ 0.0.0.1 ---- * Various changes to source code to comply with previous resolvers
etc.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: etc-version: 0.0.0.2+version: 0.1.0.0 synopsis: Declarative configuration spec for Haskell projects description: Please see README.md category: Configuration, System@@ -50,7 +50,7 @@ ghc-options: -Wall build-depends: base >=4.7 && <5- , aeson >=0.11 && <1.2+ , aeson >=0.11 && <1.3 , bytestring >=0.10 && <0.11 , containers >=0.5 && <0.6 , text >=1.2 && <1.3@@ -113,7 +113,7 @@ ghc-options: -Wall build-depends: base >=4.7 && <5- , aeson >=0.11 && <1.2+ , aeson >=0.11 && <1.3 , bytestring >=0.10 && <0.11 , containers >=0.5 && <0.6 , text >=1.2 && <1.3
src/System/Etc/Internal/Extra/Printer.hs view
@@ -21,6 +21,9 @@ renderJsonValue :: JSON.Value -> (Doc, Int) renderJsonValue value' = case value' of+ JSON.Null ->+ (text "null", 4)+ JSON.String str -> (text $ Text.unpack str, Text.length str)
src/System/Etc/Spec.hs view
@@ -15,7 +15,9 @@ import Control.Monad.Catch (MonadCatch (..)) -import qualified Data.Aeson as JSON+#ifdef WITH_CLI+import qualified Data.Aeson as JSON+#endif import qualified Data.Text as Text import qualified Data.Text.IO as Text (readFile) @@ -30,10 +32,18 @@ flag is set). -}+#ifdef WITH_CLI parseConfigSpec :: (MonadCatch m, JSON.FromJSON cmd) => Text -- ^ Text to be parsed -> m (ConfigSpec cmd) -- ^ returns ConfigSpec+#else+parseConfigSpec+ :: (MonadCatch m)+ => Text -- ^ Text to be parsed+ -> m (ConfigSpec ()) -- ^ returns ConfigSpec+#endif+ #ifdef WITH_YAML parseConfigSpec input = catch (JSON.parseConfigSpec input)@@ -49,10 +59,16 @@ either JSON or YAML (if cabal flag is set). -}+#ifdef WITH_CLI readConfigSpec :: JSON.FromJSON cmd => Text -- ^ Filepath where contents are going to be read from and parsed -> IO (ConfigSpec cmd) -- ^ returns ConfigSpec+#else+readConfigSpec+ :: Text -- ^ Filepath where contents are going to be read from and parsed+ -> IO (ConfigSpec ()) -- ^ returns ConfigSpec+#endif readConfigSpec filepath = do contents <- Text.readFile $ Text.unpack filepath parseConfigSpec contents
test/System/Etc/Resolver/DefaultTest.hs view
@@ -5,8 +5,9 @@ import Protolude -import Test.Tasty (TestTree, testGroup)-import Test.Tasty.HUnit (assertBool, assertFailure, testCase)+import qualified Data.Aeson as JSON+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.HUnit (assertBool, assertFailure, testCase) import qualified Data.Set as Set@@ -60,5 +61,28 @@ Just set -> assertBool ("expecting to see entry from env; got " <> show set) (Set.member (Default "hello default") set)++ , testCase "default can be a null JSON value" $ do+ let+ input =+ mconcat+ [+ "{\"etc/entries\": {"+ , " \"greeting\": null}}"+ ]+ (spec :: ConfigSpec ()) <- parseConfigSpec input++ let+ config =+ resolveDefault spec++ case getAllConfigSources ["greeting"] config of+ Nothing ->+ assertFailure ("expecting to get entries for greeting\n"+ <> show config)+ Just set ->+ assertBool ("expecting to see entry from env; got " <> show set)+ (Set.member (Default JSON.Null) set)+ ]
test/System/Etc/SpecTest.hs view
@@ -170,6 +170,7 @@ assertBool "" True ] +#ifdef WITH_CLI cli_tests :: TestTree cli_tests = testGroup "cli"@@ -273,6 +274,7 @@ assertBool "" True ]+#endif envvar_tests :: TestTree envvar_tests =@@ -330,5 +332,7 @@ , yaml_tests #endif , envvar_tests+#ifdef WITH_CLI , cli_tests+#endif ]