packages feed

yaml-light 0.1.3 → 0.1.4

raw patch · 2 files changed

+49/−4 lines, 2 files

Files

Data/Yaml/YamlLight.hs view
@@ -18,7 +18,8 @@     -- * YamlLight versions of Syck functions   , parseYaml, parseYamlFile, parseYamlBytes     -- * YamlLight utility functions-  , fromYamlNode, lookupYL, lookupYLWith, combineSequencedMaps, combineMappedSequences+  , fromYamlNode, lookupYL, lookupYLWith+  , combineSequencedMaps, combineMappedSequences, getTerminalsKeys     -- ** Extractors   , unSeq, unMap, unStr   ) where@@ -130,7 +131,6 @@      Any values of keys that are not sequences will not appear in the output list.      Returns Nothing if not called on a YMap.    -}-   combineMappedSequences :: YamlLight -> Maybe [(YamlLight, YamlLight)]   combineMappedSequences (YMap m) = Just . concatMap flattenTags . removeSndMaybes $ mapThenList unSeq m   combineMappedSequences _        = Nothing@@ -145,6 +145,39 @@   flattenTags (a,bs) = map ((,) a) bs  +  {- | Create a list of all the terminal YStrs in a YamlLight tree, and couple them with a list of all the keys+       above them.++       Example:++       @+        - key1:+            key1_1:+              - \"str1\"+              - \"str2\"+            key1_2:+              - \"str2\"+              - \"str3\"+        - key2:+            \"str4\"+        - \"str5\"+        @++        Would become:++        @+        [(\"str1\",[key1_1, key1]), (\"str2\", [key1_1, key1]), (\"str2\", [key1_2, key1]), (\"str3\",[key1_2, key1]), (\"str4\",[key2]), (\"str5\",[])+        @+   -}+  getTerminalsKeys :: YamlLight -> [(ByteString.ByteString,[YamlLight])]+  getTerminalsKeys = getTerminalsKeys' []++  getTerminalsKeys' :: [YamlLight] -> YamlLight -> [(ByteString.ByteString,[YamlLight])]+  getTerminalsKeys' hist (YStr s) = [(s,hist)]+  getTerminalsKeys' hist (YSeq s) = concatMap (getTerminalsKeys' hist) s+  getTerminalsKeys' hist (YMap m) = concat . Map.elems $ Map.mapWithKey (\k -> getTerminalsKeys' (k : hist)) m+  getTerminalsKeys' _ _ = []+   -- | Get the contents of a sequence   unSeq :: YamlLight -> Maybe [YamlLight]   unSeq (YSeq s) = Just s@@ -168,9 +201,21 @@    cSeqMap1 = "[{key1: val1, key2: val2}, {key3: val3}]"   cMapSeq1 = "{key1: [val1, val2, val3], key2: [val4, val5]}"+  gtKeys1  = " [{key1:                     \+             \   { key1_1: [str1, str2]    \+             \   , key1_2: [str2, str3] }} \+             \ , {key2: [str4]}            \+             \ , str5                      \+             \ ] "+  gtKeys2 = "[a, b, c]"+  gtKeys3 = "a: {b: [c, {d: [e, f]}]}"+  gtKeys4 = "[{a: {b: [c1, c2], d: [e1, e2]}, f: [g]}, h]"    testCombineSequencedMaps1 = performTest combineSequencedMaps cSeqMap1    testCombineMappedSequences1 = performTest combineMappedSequences cMapSeq1 -+  testGetTerminalsKeys1 = performTest getTerminalsKeys gtKeys1+  testGetTerminalsKeys2 = performTest getTerminalsKeys gtKeys2+  testGetTerminalsKeys3 = performTest getTerminalsKeys gtKeys3+  testGetTerminalsKeys4 = performTest getTerminalsKeys gtKeys4
yaml-light.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.1.3+Version:             0.1.4  -- A short (one-line) description of the package. Synopsis:            A light-weight wrapper with utility functions around HsSyck