pdfinfo 0.1.1 → 0.1.2
raw patch · 2 files changed
+14/−10 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Text.PDF.Info: pdfInfoSubject :: PDFInfo -> Maybe String
+ Text.PDF.Info: pdfInfoTitle :: PDFInfo -> Maybe String
- Text.PDF.Info: PDFInfo :: Maybe String -> Maybe String -> Maybe String -> Maybe UTCTime -> Maybe UTCTime -> Maybe Bool -> Maybe Integer -> Maybe Bool -> Maybe PDFSize -> Maybe Integer -> Maybe Bool -> Maybe Double -> PDFInfo
+ Text.PDF.Info: PDFInfo :: Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe UTCTime -> Maybe UTCTime -> Maybe Bool -> Maybe Integer -> Maybe Bool -> Maybe PDFSize -> Maybe Integer -> Maybe Bool -> Maybe Double -> PDFInfo
Files
- pdfinfo.cabal +1/−1
- src/Text/PDF/Info.hs +13/−9
pdfinfo.cabal view
@@ -1,5 +1,5 @@ Name: pdfinfo-Version: 0.1.1+Version: 0.1.2 Synopsis: Wrapper around the pdfinfo command. Description: Just a wrapper around the pdfinfo command. See man pdfinfo. License: BSD3
src/Text/PDF/Info.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving, MultiParamTypeClasses, ViewPatterns #-} {-# LANGUAGE FlexibleContexts #-} {-# OPTIONS -Wall #-}-module Text.PDF.Info +module Text.PDF.Info (-- * Reading PDF info pdfInfo ,PDFInfo(..)@@ -28,7 +28,9 @@ -- | A type representing the output from the pdfinfo command. data PDFInfo = PDFInfo {- pdfInfoAuthor :: Maybe String -- ^ Author: E.g. Chris Done+ pdfInfoTitle :: Maybe String -- ^ Title+ , pdfInfoSubject :: Maybe String -- ^ Subject+ , pdfInfoAuthor :: Maybe String -- ^ Author: E.g. Chris Done , pdfInfoCreator :: Maybe String -- ^ Creator: E.g. Microsoft® Office Word 2007 , pdfInfoProducer :: Maybe String -- ^ Producer: E.g. Microsoft® Office Word 2007 , pdfInfoCreationDate :: Maybe UTCTime -- ^ Creation Date@@ -43,7 +45,7 @@ } deriving Show -- | Possible things that can go wrong while reading the info.-data PDFInfoError = +data PDFInfoError = ParseError String -- ^ Couldn't parse a property value. | ProcessError IOException -- ^ Error to do with the pdfinfo process. | NoMessage -- ^ No message given.@@ -69,7 +71,9 @@ -- | Parse PDFInfo's output. parse :: String -> Either PDFInfoError PDFInfo parse out = runParse $- PDFInfo <$> string "Author"+ PDFInfo <$> string "Title"+ <*> string "Subject"+ <*> string "Author" <*> string "Creator" <*> string "Producer" <*> date "CreationDate"@@ -103,23 +107,23 @@ -- | Parse a page size. This is loosely defined. parseSize :: String -> ParsePDFInfo PDFSize-parseSize s = +parseSize s = case words s of- ((readRight -> Right x):"x":(readRight -> Right y):_) -> + ((readRight -> Right x):"x":(readRight -> Right y):_) -> return $ PDFSize x y _ -> throwError $ ParseError $ "Unable to read size: " ++ show s -- | Parse a date according to pdfinfo's format. parseDate :: String -> ParsePDFInfo UTCTime-parseDate s = +parseDate s = case parseTime defaultTimeLocale "%a %b %e %H:%M:%S %Y" s of Just ok -> return ok Nothing -> throwError $ ParseError $ "Unable to parse date: " ++ show s -- | Read a value, maybe, allow misc trailing data. readRight :: (MonadError PDFInfoError m,Read a) => String -> m a-readRight s = - case reads s of +readRight s =+ case reads s of [(v,_)] -> return v _ -> throwError $ ParseError $ "Couldn't read value: " ++ show s