packages feed

ldif 0.0.7 → 0.0.8

raw patch · 6 files changed

+34/−13 lines, 6 filesdep +directorydep −haskell98dep ~CabalPVP ok

version bump matches the API change (PVP)

Dependencies added: directory

Dependencies removed: haskell98

Dependency ranges changed: Cabal

API changes (from Hackage documentation)

+ Text.LDIF.Types: DNi :: [AttrValue] -> DN
+ Text.LDIF.Utils: dn2dnI :: DN -> DN
+ Text.LDIF.Utils: ldif2ldifI :: LDIF -> LDIF

Files

ldif.cabal view
@@ -1,5 +1,5 @@ Name:            ldif-Version:         0.0.7+Version:         0.0.8 License:         BSD3 License-File:    LICENSE Synopsis:        The LDAP Data Interchange Format (LDIF) parser @@ -17,9 +17,12 @@  .  - diffLDIF command generates change LDIF between two     content LDIF files.+ .  - ldif2html command generates hypertext HTML browsable    LDIF file.   .+ - ldifmodify commmand apply change LDIF on contenct LDIF+ . Category:        Text Stability:       experimental Build-Type:      Simple@@ -52,11 +55,11 @@   Build-Depends:   ghc,                    base         < 5,                    filepath,-                   haskell98,                    containers,                    cmdargs,+                   directory,                    parsec       >= 2.1.0,-                   Cabal        >= 1.5 && < 1.9+                   Cabal        >= 1.4   Hs-Source-Dirs:  src   Extensions:      CPP, PatternGuards   Ghc-Options:      -Wall -fno-warn-orphans
src/Text/LDIF/Parser.hs view
@@ -68,7 +68,7 @@     pSEPs     ver <- optionMaybe pVersionSpec     pSEPs-    recs <- sepEndBy1 pChangeRec pSEPs+    recs <- sepEndBy pChangeRec pSEPs     eof     return $ LDIF ver recs @@ -77,7 +77,7 @@     pSEPs     ver <- optionMaybe pVersionSpec     pSEPs-    recs <- sepEndBy1 pRec pSEPs+    recs <- sepEndBy pRec pSEPs     eof     return $ LDIF ver recs @@ -86,7 +86,7 @@     pSEPs     ver <- optionMaybe pVersionSpec     pSEPs-    recs <- sepEndBy1 pAttrValRec pSEPs+    recs <- sepEndBy pAttrValRec pSEPs     eof     return $ LDIF ver recs 
src/Text/LDIF/Printer.hs view
@@ -19,7 +19,7 @@  -- | Serialize DN to LDIF Format dn2str :: DN -> String-dn2str (DN xs) = intercalate "," $ map (\((Attribute n),v) -> n++"="++v) xs+dn2str xs = intercalate "," $ map (\((Attribute n),v) -> n++"="++v) (dnAttrVals xs)  -- | Serialize Content Record in LDIF Format record2str :: LDIFRecord -> String
src/Text/LDIF/Types.hs view
@@ -53,4 +53,10 @@             | ModReplace { modAttr :: Attribute, modAttrVals :: [Value] } deriving (Show, Eq)  -- | Represents Distinguished Name (DN)-data DN = DN { dnAttrVals :: [AttrValue] } deriving (Show, Eq)+data DN = DN { dnAttrVals :: [AttrValue] } +        | DNi { dnAttrVals :: [AttrValue] } deriving (Show)++instance Eq DN where+    (DN xs)  == (DN ys)   = xs == ys+    (DNi xs) == (DNi ys)  = (map (\(n,v) -> (n,(map toUpper v)))  xs) == (map (\(n,v) -> (n,(map toUpper v))) ys)+    x        == y         = (DNi (dnAttrVals x)) == (DNi (dnAttrVals y))
src/Text/LDIF/Utils.hs view
@@ -13,7 +13,9 @@         ldif2tree,         getLDIFType,         isContentRecord,-        isChangeRecord+        isChangeRecord,+        dn2dnI,+        ldif2ldifI ) where import Text.LDIF.Types@@ -50,13 +52,14 @@ rootOfDN xs = getDNValue xs ((sizeOfDN xs)-1)  sizeOfDN :: DN -> Int-sizeOfDN (DN vals) = length vals+sizeOfDN xs = length (dnAttrVals xs)  getDNValue :: DN -> Int -> AttrValue-getDNValue (DN vals) idx = vals !! idx+getDNValue xs idx = (dnAttrVals xs) !! idx  takeDNPrefix :: DN -> Int -> DN-takeDNPrefix (DN vals) n = (DN (reverse $ take n (reverse vals)))+takeDNPrefix (DN vals) n  = (DN (reverse $ take n (reverse vals)))+takeDNPrefix (DNi vals) n = (DNi (reverse $ take n (reverse vals)))  -- | Check if the dn1 is prefix of dn2 isDNPrefixOf :: DN -> DN -> Bool@@ -100,3 +103,12 @@       getLDIFType' [] _  = LDIFChangesType       getLDIFType' _  [] = LDIFContentType       getLDIFType' _  _  = LDIFMixedType++dn2dnI :: DN -> DN+dn2dnI (DN xs) = (DNi xs)+dn2dnI xs = xs++ldif2ldifI :: LDIF -> LDIF+ldif2ldifI (LDIF v xs) = LDIF v ys+    where+      ys = map (\x -> x { reDN = dn2dnI (reDN x) } )  xs
tests/TestMain.hs view
@@ -2,7 +2,7 @@ import Test.HUnit import Data.Either import Data.List-import Directory+import System.Directory import System.FilePath import Control.Monad (liftM)