packages feed

aeson-yaml 1.0.6.0 → 1.1.0.0

raw patch · 4 files changed

+29/−19 lines, 4 filesdep ~bytestringdep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: bytestring, text

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,15 @@ # Changelog +## 1.1.0.0 - 2020-06-25++### Changed++  - Every change to the YAML output format will now result in a bump of B+    in A.B.C.D to more closely follow the Haskell PVP. B will be bumped in+    case of small changes and bug fixes, and A if a change is expected to+    cause problems with common YAML 1.1 or 1.2 decoders.+  - `encodeDocuments` and `encodeQuotedDocuments` now output a leading `---`+ ## 1.0.6.0 - 2020-02-27  ### Changed
aeson-yaml.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12  name:           aeson-yaml-version:        1.0.6.0+version:        1.1.0.0 homepage:       https://github.com/clovyr/aeson-yaml bug-reports:    https://github.com/clovyr/aeson-yaml/issues author:         Patrick Nielsen@@ -37,7 +37,7 @@   exposed-modules:       Data.Aeson.Yaml   build-depends:-      aeson >= 0.4.0.0 && < 1.5+      aeson >= 0.4.0.0 && < 1.6     , base >= 4.8.2.0 && < 5     , bytestring >= 0.10.4.0 && < 0.11     , text >= 0.1 && < 1.3
src/Data/Aeson/Yaml.hs view
@@ -52,15 +52,15 @@   ByteString.Builder.toLazyByteString $   encodeBuilder False False 0 (toJSON v) <> bs "\n" --- | Encode multiple values separated by '\n---\n'. To encode values of different+-- | Encode multiple values prefixed by @---\n@. To encode values of different -- types, @import Data.Aeson(ToJSON(toJSON))@ and do -- @encodeDocuments [toJSON x, toJSON y, toJSON z]@. encodeDocuments :: ToJSON a => [a] -> ByteString.Lazy.ByteString-encodeDocuments vs = ByteString.Builder.toLazyByteString $ output <> bs "\n"+encodeDocuments vs =+    ByteString.Builder.toLazyByteString (foldMap encodeDocument vs)   where-    output =-      mconcat $-      intersperse (bs "\n---\n") $ map (encodeBuilder False False 0 . toJSON) vs+    encodeDocument document =+        "---\n" <> encodeBuilder False False 0 (toJSON document) <> "\n"  -- | Encode a value as YAML (lazy bytestring). Keys and strings are always -- quoted.@@ -73,11 +73,10 @@ -- quoted. encodeQuotedDocuments :: ToJSON a => [a] -> ByteString.Lazy.ByteString encodeQuotedDocuments vs =-  ByteString.Builder.toLazyByteString $ output <> bs "\n"+    ByteString.Builder.toLazyByteString (foldMap encodeDocument vs)   where-    output =-      mconcat $-      intersperse (bs "\n---\n") $ map (encodeBuilder True False 0 . toJSON) vs+    encodeDocument document =+        "---\n" <> encodeBuilder True False 0 (toJSON document) <> "\n"  encodeBuilder :: Bool -> Bool -> Int -> Data.Aeson.Value -> Builder encodeBuilder alwaysQuote newlineBeforeObject level value =
test/Test/Data/Aeson/Yaml.hs view
@@ -20,12 +20,13 @@  import Data.Aeson.Yaml -data TestCase = TestCase-  { tcName :: String-  , tcInput :: Data.ByteString.Lazy.ByteString-  , tcOutput :: Data.ByteString.Lazy.ByteString-  , tcAlwaysQuote :: Bool-  }+data TestCase =+  TestCase+    { tcName :: String+    , tcInput :: Data.ByteString.Lazy.ByteString+    , tcOutput :: Data.ByteString.Lazy.ByteString+    , tcAlwaysQuote :: Bool+    }  testCases :: [TestCase] testCases =@@ -257,11 +258,11 @@         if tcAlwaysQuote           then assertEqual                  "Expected documents output"-                 ("'foo': 'bar'" <> "\n---\n" <> output)+                 ("---\n'foo': 'bar'" <> "\n---\n" <> output)                  (encodeQuotedDocuments [foo, decodedInput])           else assertEqual                  "Expected documents output"-                 ("foo: bar" <> "\n---\n" <> output)+                 ("---\nfoo: bar" <> "\n---\n" <> output)                  (encodeDocuments [foo, decodedInput])       where         output =