iCalendar 0.3.0.1 → 0.4
raw patch · 6 files changed
+43/−14 lines, 6 filesdep ~mime
Dependency ranges changed: mime
Files
- Text/ICalendar/Parser.hs +25/−7
- Text/ICalendar/Parser/Common.hs +1/−1
- Text/ICalendar/Parser/Parameters.hs +1/−1
- Text/ICalendar/Printer.hs +10/−3
- Text/ICalendar/Types.hs +4/−0
- iCalendar.cabal +2/−2
Text/ICalendar/Parser.hs view
@@ -3,7 +3,9 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeSynonymInstances #-} module Text.ICalendar.Parser- ( parseICal+ ( parseICalendar+ , parseICalendarFile+ , parseICal , parseICalFile , DecodingFunctions(..) ) where@@ -29,12 +31,13 @@ -- | Parse a ByteString containing iCalendar data.+-- -- Returns either an error, or a tuple of the result and a list of warnings.-parseICal :: DecodingFunctions- -> FilePath- -> ByteString- -> Either String ([VCalendar], [String])-parseICal s f bs = do+parseICalendar :: DecodingFunctions+ -> FilePath -- ^ Used in error messages.+ -> ByteString+ -> Either String ([VCalendar], [String])+parseICalendar s f bs = do a <- either (Left . show) Right $ runParser parseToContent s f bs when (null a) $ throwError "Missing content." let xs = map (runCP s . parseVCalendar) a@@ -44,11 +47,26 @@ Right y -> Right (y:x, w <> ws) return (x, w) +-- | Deprecated synonym for parseICalendar+parseICal :: DecodingFunctions+ -> FilePath+ -> ByteString+ -> Either String ([VCalendar], [String])+parseICal = parseICalendar+{-# DEPRECATED parseICal "Use parseICalendar instead" #-}+ -- | Parse an iCalendar file.+parseICalendarFile :: DecodingFunctions+ -> FilePath+ -> IO (Either String ([VCalendar], [String]))+parseICalendarFile s f = parseICal s f <$> B.readFile f++-- | Deprecated synonym for parseICalendarFile parseICalFile :: DecodingFunctions -> FilePath -> IO (Either String ([VCalendar], [String]))-parseICalFile s f = parseICal s f <$> B.readFile f+parseICalFile = parseICalendarFile+{-# DEPRECATED parseICalFile "Use parseICalendarFile instead" #-} runCP :: DecodingFunctions -> ContentParser a -> (Either String a, (SourcePos, [Content]), [String])
Text/ICalendar/Parser/Common.hs view
@@ -37,6 +37,7 @@ import Text.ICalendar.Types +-- | Content lines, separated into components. 3.1. data Content = ContentLine P.SourcePos (CI Text) [(CI Text, [Text])] ByteString | Component P.SourcePos (CI Text) [Content] deriving (Show, Eq, Ord)@@ -143,7 +144,6 @@ parseURI s = case URI.parseURI s of Just x -> return x Nothing -> throwError $ "Invalid URI: " ++ show s- -- | Convert a 'DateTime' to 'UTCTime', giving an appropriate error. mustBeUTC :: DateTime -> ContentParser UTCTime
Text/ICalendar/Parser/Parameters.hs view
@@ -87,7 +87,7 @@ parseCUType x = CUTypeX x parseMime :: Text -> ContentParser MIMEType-parseMime t = let m = mimeType .: parseMIMEType $ T.unpack t+parseMime t = let m = mimeType .: parseMIMEType $ T.toStrict t in maybe (throwError $ "parseMime: " ++ show t) return m -- | Parse Duration. 3.3.6
Text/ICalendar/Printer.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE TupleSections #-} module Text.ICalendar.Printer ( EncodingFunctions(..)+ , printICalendar , printICal ) where @@ -74,9 +75,15 @@ type ContentPrinter = RWS EncodingFunctions Builder Int +-- | Print a VCalendar object to a ByteString.+printICalendar :: EncodingFunctions -> VCalendar -> ByteString+printICalendar r v = (\(_, _, x) -> Bu.toLazyByteString x) $+ runRWS (printVCalendar v) r 0++-- | Deprecated synonym for printICalendar printICal :: EncodingFunctions -> VCalendar -> ByteString-printICal r v = (\(_, _, x) -> Bu.toLazyByteString x) $- runRWS (printVCalendar v) r 0+printICal = printICalendar+{-# DEPRECATED printICal "Use printICalendar instead" #-} -- {{{ Component printers @@ -625,7 +632,7 @@ toParam (FBTypeX x) = [("FBTYPE", [(Optional, CI.original x)])] instance ToParam MIMEType where- toParam m = [("FMTTYPE", [(NoQuotes, T.pack $ showMIMEType m)])]+ toParam m = [("FMTTYPE", [(NoQuotes, T.fromStrict $ showMIMEType m)])] instance ToParam Attachment where toParam UriAttachment {..} = toParam attachFmtType <>
Text/ICalendar/Types.hs view
@@ -546,6 +546,7 @@ deriving (Show, Eq, Ord, Typeable) -- | Free/Busy Time Type. 3.2.9.+-- -- Unrecognized FBTypeX MUST be treated as Busy. data FBType = Free@@ -611,6 +612,7 @@ } deriving (Show, Eq, Ord, Typeable) -- | Calendar User Type. 3.2.3.+-- -- Unrecognized CUTypeX MUST be treated as Unknown. data CUType = Individual@@ -659,6 +661,7 @@ } deriving (Show, Eq, Ord, Typeable) -- | Organizer. 3.8.4.3.+-- -- TODO: CAL-ADDRESS-related properties. data Organizer = Organizer { organizerValue :: CalAddress@@ -694,6 +697,7 @@ } deriving (Show, Eq, Ord, Typeable) -- | Relationship Type. 3.2.15.+-- -- Unrecognized RelationshipTypeX values MUST be treated as Parent. data RelationshipType = Parent | Child | Sibling | RelationshipTypeX (CI Text) deriving (Show, Eq, Ord, Typeable)
iCalendar.cabal view
@@ -1,5 +1,5 @@ name: iCalendar-version: 0.3.0.1+version: 0.4 synopsis: iCalendar data types, parser, and printer. description: Data definitions, parsing and printing of the iCalendar format (RFC5545).@@ -34,6 +34,6 @@ build-depends: base >=4.5 && <5, time ==1.4.*, data-default >=0.3 , case-insensitive >=0.4, network ==2.4.* , bytestring >=0.10 && < 0.11, parsec ==3.1.*- , text, containers >= 0.5 && < 0.6, mime ==0.3.*+ , text, containers >= 0.5 && < 0.6, mime ==0.4.* , mtl ==2.1.*, old-locale, base64-bytestring ==1.0.* ghc-options: -Wall