conduit-extra 1.1.14 → 1.1.15
raw patch · 5 files changed
+54/−3 lines, 5 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Data.Conduit.Binary: sinkSystemTempFile :: MonadResource m => String -> ConduitM ByteString o m FilePath
+ Data.Conduit.Binary: sinkTempFile :: MonadResource m => FilePath -> String -> ConduitM ByteString o m FilePath
Files
- ChangeLog.md +4/−0
- Data/Conduit/Binary.hs +36/−1
- conduit-extra.cabal +2/−1
- test/Data/Conduit/BinarySpec.hs +11/−0
- test/Data/Conduit/ProcessSpec.hs +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.1.15++* `sinkTempFile` and `sinkSystemTempFile`+ ## 1.1.14 * `sinkFileCautious`
Data/Conduit/Binary.hs view
@@ -23,6 +23,8 @@ -- ** Sinks , sinkFile , sinkFileCautious+ , sinkTempFile+ , sinkSystemTempFile , sinkHandle , sinkIOHandle -- ** Conduits@@ -273,7 +275,7 @@ acquire = openBinaryTempFile (takeDirectory fp) (takeFileName fp <.> "tmp") cleanup (tmpFP, h) = do hClose h- removeFile tmpFP `catch` \e ->+ removeFile tmpFP `Control.Exception.catch` \e -> if isDoesNotExistError e then return () else throwIO e@@ -282,6 +284,39 @@ liftIO $ do hClose h renameFile tmpFP fp++-- | Stream data into a temporary file in the given directory with the+-- given filename pattern, and return the temporary filename. The+-- temporary file will be automatically deleted when exiting the+-- active 'ResourceT' block, if it still exists.+--+-- @since 1.1.15+sinkTempFile :: MonadResource m+ => FilePath -- ^ temp directory+ -> String -- ^ filename pattern+ -> ConduitM ByteString o m FilePath+sinkTempFile tmpdir pattern = do+ (_releaseKey, (fp, h)) <- allocate+ (IO.openBinaryTempFile tmpdir pattern)+ (\(fp, h) -> IO.hClose h `finally` (removeFile fp `Control.Exception.catch` \e ->+ if isDoesNotExistError e+ then return ()+ else throwIO e))+ sinkHandle h+ liftIO $ IO.hClose h+ return fp++-- | Same as 'sinkTempFile', but will use the default temp file+-- directory for the system as the first argument.+--+-- @since 1.1.15+sinkSystemTempFile+ :: MonadResource m+ => String -- ^ filename pattern+ -> ConduitM ByteString o m FilePath+sinkSystemTempFile pattern = do+ dir <- liftIO getTemporaryDirectory+ sinkTempFile dir pattern -- | Stream the contents of the input to a file, and also send it along the -- pipeline. Similar in concept to the Unix command @tee@.
conduit-extra.cabal view
@@ -1,5 +1,5 @@ Name: conduit-extra-Version: 1.1.14+Version: 1.1.15 Synopsis: Batteries included conduit: adapters for common libraries. Description: The conduit package itself maintains relative small dependencies. The purpose of this package is to collect commonly used utility functions wrapping other library dependencies, without depending on heavier-weight dependencies. The basic idea is that this package should only depend on haskell-platform packages and conduit.@@ -88,6 +88,7 @@ , text , transformers , transformers-base+ , directory ghc-options: -Wall if os(windows) cpp-options: -DWINDOWS
test/Data/Conduit/BinarySpec.hs view
@@ -24,6 +24,7 @@ import Data.Typeable (Typeable) import Data.ByteString.Internal (createAndTrim') import Foreign.Ptr (alignPtr, minusPtr)+import System.Directory (doesFileExist) import System.IO.Unsafe (unsafePerformIO) import Control.Applicative ((<$>), (<*>)) @@ -172,6 +173,16 @@ `shouldThrow` anyException bs2 <- S.readFile "tmp" bs2 `shouldBe` bs1++ it "sinkSystemTempFile" $ do+ let bs = "Hello World!"+ fp <- runResourceT $ do+ fp <- C.yield bs C.$$ CB.sinkSystemTempFile "temp-file-test"+ actual <- liftIO $ S.readFile fp+ liftIO $ actual `shouldBe` bs+ return fp+ exists <- doesFileExist fp+ exists `shouldBe` False describe "Data.Conduit.Binary.mapM_" $ do prop "telling works" $ \bytes ->
test/Data/Conduit/ProcessSpec.hs view
@@ -73,7 +73,7 @@ it "feeds stdin" $ do let mystr = "this is a test string" :: S.ByteString sourceCmdWithStreams "cat"- (mapM_ yield . L.toChunks $ L.fromStrict mystr)+ (yield mystr) CL.consume -- stdout CL.consume -- stderr `shouldReturn` (ExitSuccess, [mystr], [])