process-conduit 1.0.0.0 → 1.0.0.1
raw patch · 6 files changed
+232/−232 lines, 6 filesdep ~template-haskellsetup-changedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: template-haskell
API changes (from Hackage documentation)
Files
- LICENSE +30/−30
- README.md +76/−76
- Setup.hs +2/−2
- System/Process/QQ.hs +40/−40
- process-conduit.cabal +49/−49
- test.hs +35/−35
LICENSE view
@@ -1,30 +1,30 @@-Copyright (c)2011-2012, Hideyuki Tanaka--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:-- * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.-- * Redistributions in binary form must reproduce the above- copyright notice, this list of conditions and the following- disclaimer in the documentation and/or other materials provided- with the distribution.-- * Neither the name of Hideyuki Tanaka nor the names of other- contributors may be used to endorse or promote products derived- from this software without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+Copyright (c)2011-2012, Hideyuki Tanaka + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Hideyuki Tanaka nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
README.md view
@@ -1,76 +1,76 @@-process-conduit: Conduit for processes-======================================--# About--This package provides [conduit](http://hackage.haskell.org/package/conduit)-for processes.-Also this provides quasi-quoters for process using it.--# Install--~~~ {.bash}-$ cabal update-$ cabal install process-conduit-~~~--# Document--Haddock documents are here:--<http://hackage.haskell.org/package/process-conduit>--# Quasi Quoters--process-conduit has three quasi-quoters, `cmd`, `scmd` and `ccmd`.--The result type of `cmd` is Lazy `ByteString`,-but execution will perform strictly.--The result type of `scmd` and `ccmd` are-`GSource m ByteString` and-`GConduit ByteString m ByteString` respectively.--If a command is failed, an exception is thrown.--Commands are executed in ***run-time***, not compile-time.--# Examples--* Create a Source and a Conduit of process--~~~ {.haskell}-import Data.Conduit-import qualified Data.Conduit.Binary as CB-import Data.Conduit.Process-import System.IO--main :: IO ()-main = runResourceT $ do- sourceCmd "ls" $= conduitCmd "sort" $$ CB.sinkHandle stdout-~~~--* Invoke a process simply--~~~ {.haskell}-{-# LANGUAGE QuasiQuotes #-}-import System.Process.QQ--main = print =<< [cmd|ls|]-~~~--* Conduit Quasi-Quoters--~~~ {.haskell}-main :: IO ()-main = runResourceT $ do- [scmd|ls|] $= [ccmd|sort|] $$ CB.sinkHandle stdout-~~~--* Unquoting (syntax is same as [shakespeare-text](http://hackage.haskell.org/package/shakespeare-text))--~~~ {.haskell}-main = do- [url] <- getArgs- print =<< [cmd|curl #{url}|]-~~~+process-conduit: Conduit for processes +====================================== + +# About + +This package provides [conduit](http://hackage.haskell.org/package/conduit) +for processes. +Also this provides quasi-quoters for process using it. + +# Install + +~~~ {.bash} +$ cabal update +$ cabal install process-conduit +~~~ + +# Document + +Haddock documents are here: + +<http://hackage.haskell.org/package/process-conduit> + +# Quasi Quoters + +process-conduit has three quasi-quoters, `cmd`, `scmd` and `ccmd`. + +The result type of `cmd` is Lazy `ByteString`, +but execution will perform strictly. + +The result type of `scmd` and `ccmd` are +`GSource m ByteString` and +`GConduit ByteString m ByteString` respectively. + +If a command is failed, an exception is thrown. + +Commands are executed in ***run-time***, not compile-time. + +# Examples + +* Create a Source and a Conduit of process + +~~~ {.haskell} +import Data.Conduit +import qualified Data.Conduit.Binary as CB +import Data.Conduit.Process +import System.IO + +main :: IO () +main = runResourceT $ do + sourceCmd "ls" $= conduitCmd "sort" $$ CB.sinkHandle stdout +~~~ + +* Invoke a process simply + +~~~ {.haskell} +{-# LANGUAGE QuasiQuotes #-} +import System.Process.QQ + +main = print =<< [cmd|ls|] +~~~ + +* Conduit Quasi-Quoters + +~~~ {.haskell} +main :: IO () +main = runResourceT $ do + [scmd|ls|] $= [ccmd|sort|] $$ CB.sinkHandle stdout +~~~ + +* Unquoting (syntax is same as [shakespeare-text](http://hackage.haskell.org/package/shakespeare-text)) + +~~~ {.haskell} +main = do + [url] <- getArgs + print =<< [cmd|curl #{url}|] +~~~
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple-main = defaultMain+import Distribution.Simple +main = defaultMain
System/Process/QQ.hs view
@@ -1,40 +1,40 @@-{-# LANGUAGE TemplateHaskell #-}--module System.Process.QQ (- -- * Quasi Quoters- cmd,- scmd,- ccmd,- ) where--import Control.Applicative-import qualified Data.ByteString.Lazy as BL-import qualified Data.Conduit as C-import qualified Data.Conduit.List as CL-import qualified Data.Text.Lazy as LT-import Language.Haskell.TH.Quote-import Text.Shakespeare.Text--import Data.Conduit.Process--def :: QuasiQuoter-def = QuasiQuoter- { quoteExp = undefined- , quotePat = undefined- , quoteType = undefined- , quoteDec = undefined- }---- | Command result of (Lazy) ByteString.-cmd :: QuasiQuoter-cmd = def { quoteExp = \str -> [|- BL.fromChunks <$> C.runResourceT (sourceCmd (LT.unpack $(quoteExp lt str)) C.$$ CL.consume)-|] }---- | Source of shell command-scmd :: QuasiQuoter-scmd = def { quoteExp = \str -> [| sourceCmd (LT.unpack $(quoteExp lt str)) |] }---- | Conduit of shell command-ccmd :: QuasiQuoter-ccmd = def { quoteExp = \str -> [| conduitCmd (LT.unpack $(quoteExp lt str)) |] }+{-# LANGUAGE TemplateHaskell #-} + +module System.Process.QQ ( + -- * Quasi Quoters + cmd, + scmd, + ccmd, + ) where + +import Control.Applicative +import qualified Data.ByteString.Lazy as BL +import qualified Data.Conduit as C +import qualified Data.Conduit.List as CL +import qualified Data.Text.Lazy as LT +import Language.Haskell.TH.Quote +import Text.Shakespeare.Text + +import Data.Conduit.Process + +def :: QuasiQuoter +def = QuasiQuoter + { quoteExp = undefined + , quotePat = undefined + , quoteType = undefined + , quoteDec = undefined + } + +-- | Command result of (Lazy) ByteString. +cmd :: QuasiQuoter +cmd = def { quoteExp = \str -> [| + BL.fromChunks <$> C.runResourceT (sourceCmd (LT.unpack $(quoteExp lt str)) C.$$ CL.consume) +|] } + +-- | Source of shell command +scmd :: QuasiQuoter +scmd = def { quoteExp = \str -> [| sourceCmd (LT.unpack $(quoteExp lt str)) |] } + +-- | Conduit of shell command +ccmd :: QuasiQuoter +ccmd = def { quoteExp = \str -> [| conduitCmd (LT.unpack $(quoteExp lt str)) |] }
process-conduit.cabal view
@@ -1,49 +1,49 @@-name: process-conduit-version: 1.0.0.0-synopsis: Conduits for processes--description:- Conduits for processes.- For more details: <https://github.com/tanakh/process-conduit/blob/master/README.md>--homepage: http://github.com/tanakh/process-conduit-license: BSD3-license-file: LICENSE-author: Hideyuki Tanaka-maintainer: Hideyuki Tanaka <tanaka.hideyuki@gmail.com>-copyright: (c) 2011-2012, Hideyuki Tanaka-category: System, Conduit-build-type: Simple-cabal-version: >=1.8--extra-source-files: README.md--source-repository head- type: git- location: git://github.com/tanakh/process-conduit.git--library- exposed-modules: Data.Conduit.Process- System.Process.QQ- - build-depends: base == 4.*- , template-haskell >= 2.4 && < 2.9- , mtl >= 2.0- , control-monad-loop == 0.1.*- , bytestring >= 0.9- , text >= 0.11- , process >= 1.0- , conduit == 1.0.*- , shakespeare-text >= 1.0-- ghc-options: -Wall--test-suite process-conduit-test- type: exitcode-stdio-1.0- hs-source-dirs: dist- main-is: ../test.hs- build-depends: base == 4.*- , bytestring- , hspec >= 1.3- , conduit- , process-conduit+name: process-conduit +version: 1.0.0.1 +synopsis: Conduits for processes + +description: + Conduits for processes. + For more details: <https://github.com/tanakh/process-conduit/blob/master/README.md> + +homepage: http://github.com/tanakh/process-conduit +license: BSD3 +license-file: LICENSE +author: Hideyuki Tanaka +maintainer: Hideyuki Tanaka <tanaka.hideyuki@gmail.com> +copyright: (c) 2011-2013, Hideyuki Tanaka +category: System, Conduit +build-type: Simple +cabal-version: >=1.8 + +extra-source-files: README.md + +source-repository head + type: git + location: git://github.com/tanakh/process-conduit.git + +library + exposed-modules: Data.Conduit.Process + System.Process.QQ + + build-depends: base == 4.* + , template-haskell >= 2.4 + , mtl >= 2.0 + , control-monad-loop == 0.1.* + , bytestring >= 0.9 + , text >= 0.11 + , process >= 1.0 + , conduit == 1.0.* + , shakespeare-text >= 1.0 + + ghc-options: -Wall + +test-suite process-conduit-test + type: exitcode-stdio-1.0 + hs-source-dirs: dist + main-is: ../test.hs + build-depends: base == 4.* + , bytestring + , hspec >= 1.3 + , conduit + , process-conduit
test.hs view
@@ -1,35 +1,35 @@-{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}--import Data.Conduit.Process-import System.Process.QQ--import qualified Data.ByteString.Lazy.Char8 as L-import Data.Conduit-import qualified Data.Conduit.Binary as CB-import Test.Hspec--main :: IO ()-main = hspec $ do- describe "process conduit" $ do- it "get process's output" $ do- r <- runResourceT $ sourceCmd "echo abc def" $$ CB.take (10^9)- L.words r `shouldBe` ["abc", "def"]-- it "act as conduit" $ do- r <- runResourceT $- sourceProcess (proc "echo" ["zxc\nasd\nqwe"])- $$ conduitCmd "sort"- =$ CB.take (10^9)- L.words r `shouldBe` ["asd", "qwe", "zxc"]-- describe "quasiquoter" $ do- it "get process's output" $ do- r <- [cmd|echo abc def|]- L.words r `shouldBe` ["abc", "def"]-- it "act as conduit" $ do- r <- runResourceT $- sourceProcess (proc "echo" ["zxc\nasd\nqwe"])- $$ [ccmd|sort|]- =$ CB.take (10^9)- L.words r `shouldBe` ["asd", "qwe", "zxc"]+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-} + +import Data.Conduit.Process +import System.Process.QQ + +import qualified Data.ByteString.Lazy.Char8 as L +import Data.Conduit +import qualified Data.Conduit.Binary as CB +import Test.Hspec + +main :: IO () +main = hspec $ do + describe "process conduit" $ do + it "get process's output" $ do + r <- runResourceT $ sourceCmd "echo abc def" $$ CB.take (10^9) + L.words r `shouldBe` ["abc", "def"] + + it "act as conduit" $ do + r <- runResourceT $ + sourceProcess (proc "echo" ["zxc\nasd\nqwe"]) + $$ conduitCmd "sort" + =$ CB.take (10^9) + L.words r `shouldBe` ["asd", "qwe", "zxc"] + + describe "quasiquoter" $ do + it "get process's output" $ do + r <- [cmd|echo abc def|] + L.words r `shouldBe` ["abc", "def"] + + it "act as conduit" $ do + r <- runResourceT $ + sourceProcess (proc "echo" ["zxc\nasd\nqwe"]) + $$ [ccmd|sort|] + =$ CB.take (10^9) + L.words r `shouldBe` ["asd", "qwe", "zxc"]