packages feed

yaml 0.8.1.2 → 0.8.2

raw patch · 4 files changed

+41/−11 lines, 4 files

Files

Data/Yaml.hs view
@@ -114,15 +114,15 @@ objToEvents' (Object pairs) rest =     EventMappingStart Nothing   : foldr ($) (EventMappingEnd : rest) (map pairToEvents $ M.toList pairs)-objToEvents' (String s) rest = EventScalar (encodeUtf8 s) NoTag Any Nothing : rest-objToEvents' Null rest = EventScalar "null" NoTag Literal Nothing : rest-objToEvents' (Bool True) rest = EventScalar "true" NoTag Literal Nothing : rest-objToEvents' (Bool False) rest = EventScalar "false" NoTag Literal Nothing : rest-objToEvents' (Number n) rest = EventScalar (S8.pack $ show n) NoTag Literal Nothing : rest+objToEvents' (String s) rest = EventScalar (encodeUtf8 s) StrTag PlainNoTag Nothing : rest+objToEvents' Null rest = EventScalar "null" NullTag PlainNoTag Nothing : rest+objToEvents' (Bool True) rest = EventScalar "true" BoolTag PlainNoTag Nothing : rest+objToEvents' (Bool False) rest = EventScalar "false" BoolTag PlainNoTag Nothing : rest+objToEvents' (Number n) rest = EventScalar (S8.pack $ show n) IntTag PlainNoTag Nothing : rest  pairToEvents :: Pair -> [Y.Event] -> [Y.Event] pairToEvents (k, v) rest =-    EventScalar (encodeUtf8 k) NoTag Any Nothing+    EventScalar (encodeUtf8 k) StrTag PlainNoTag Nothing   : objToEvents' v rest  -- Parsing
Text/Libyaml.hs view
@@ -67,6 +67,7 @@            | DoubleQuoted            | Literal            | Folded+           | PlainNoTag     deriving (Show, Read, Eq, Enum, Bounded, Ord, Data, Typeable)  data Tag = StrTag@@ -378,13 +379,17 @@             c_simple_document_start er         EventDocumentEnd ->             c_yaml_document_end_event_initialize er 1-        EventScalar bs thetag style anchor -> do+        EventScalar bs thetag style0 anchor -> do             BU.unsafeUseAsCStringLen bs $ \(value, len) -> do                 let value' = castPtr value :: Ptr CUChar                     len' = fromIntegral len :: CInt                 let thetag' = tagToString thetag                 withCString thetag' $ \tag' -> do-                    let style' = toEnum $ fromEnum style+                    let (pi, style) =+                            case style0 of+                                PlainNoTag -> (1, Plain)+                                x -> (0, x)+                        style' = toEnum $ fromEnum style                         tagP = castPtr tag'                         qi = if null thetag' then 1 else 0                     case anchor of@@ -395,7 +400,7 @@                                 tagP    -- tag                                 value'  -- value                                 len'    -- length-                                0       -- plain_implicit+                                pi      -- plain_implicit                                 qi      -- quoted_implicit                                 style'  -- style                         Just anchor' ->
test/main.hs view
@@ -17,7 +17,7 @@ import Test.Hspec  import qualified Data.Yaml as D-import Data.Yaml (object, array)+import Data.Yaml (object, array, (.=)) import Data.Maybe import qualified Data.HashMap.Strict as M import qualified Data.Text as T@@ -68,6 +68,31 @@         checkNull "NULL"         checkNull "~"         checkNull ""+    describe "pretty output" $ do+        it "simple nulls" $ D.encode (object ["foo" .= D.Null]) `shouldBe` "foo: null\n"+        it "simple numbers" $ D.encode (object ["foo" .= (4 :: Int)]) `shouldBe` "foo: 4\n"+        it "True" $ D.encode (object ["foo" .= True]) `shouldBe` "foo: true\n"+        it "False" $ D.encode (object ["foo" .= False]) `shouldBe` "foo: false\n"+        it "simple string" $ D.encode (object ["foo" .= ("bar" :: T.Text)]) `shouldBe` "foo: bar\n"+    describe "special keys" $ do+        let tester key = it (T.unpack key) $+                let value = object [key .= True]+                 in D.decode (D.encode value) `shouldBe` Just value+        mapM_ tester specialStrings+    describe "special values" $ do+        let tester value = it (T.unpack value) $+                let value' = object ["foo" .= value]+                 in D.decode (D.encode value') `shouldBe` Just value'+        mapM_ tester specialStrings++specialStrings :: [T.Text]+specialStrings =+    [ "fo\"o"+    , "fo\'o"+    , "fo\\'o"+    , "fo: o"+    , "foo\nbar\nbaz\n"+    ]  counter :: Monad m => (Y.Event -> Bool) -> C.Sink Y.Event m Int counter pred' =
yaml.cabal view
@@ -1,5 +1,5 @@ name:            yaml-version:         0.8.1.2+version:         0.8.2 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov