packages feed

follow-file 0.0.1 → 0.0.1.1

raw patch · 3 files changed

+35/−21 lines, 3 filesdep +attoparsecdep +attoparsec-pathdep +textnew-component:exe:follow-filePVP ok

version bump matches the API change (PVP)

Dependencies added: attoparsec, attoparsec-path, text

API changes (from Hackage documentation)

Files

+ app/Main.hs view
@@ -0,0 +1,28 @@+import Path+import qualified Data.ByteString.Lazy as BS+import qualified Data.Text as T+import Data.Attoparsec.Text (parseOnly, endOfInput, eitherP)+import Data.Attoparsec.Path (absFilePath, relFilePath, absDirPath)+import System.INotify (initINotify, removeWatch, killINotify)+import System.File.Follow (follow)+import System.Directory (getCurrentDirectory)+import System.Environment (getArgs)+import Control.Monad (forever)+import Control.Exception (bracket)+import Control.Concurrent (threadDelay)+++main = do+  [f] <- getArgs+  f <- case parseOnly (eitherP absFilePath relFilePath <* endOfInput) (T.pack f) of+          Left e -> error e+          Right eAR -> case eAR of+            Left a -> pure a+            Right r -> do+              d <- getCurrentDirectory+              case parseOnly (absDirPath <* endOfInput) (T.pack (d ++ "/")) of+                Left e -> error e+                Right d' ->+                  pure (d' </> r)+  i <- initINotify+  bracket (follow i f BS.putStr) (\watch -> removeWatch watch >> killINotify i) $ \_ -> forever $ threadDelay 50000
follow-file.cabal view
@@ -1,5 +1,5 @@ Name:                   follow-file-Version:                0.0.1+Version:                0.0.1.1 Author:                 Athan Clark <athan.clark@gmail.com> Maintainer:             Athan Clark <athan.clark@gmail.com> License:                BSD3@@ -26,14 +26,17 @@                       , utf8-string                       , vector -Test-suite filefollow-tests-  Type:                exitcode-stdio-1.0+Executable follow-file   Default-Language:    Haskell2010-  Hs-Source-Dirs:      test+  Hs-Source-Dirs:      app   Main-is:             Main.hs   Build-Depends:       base+                     , bytestring                      , follow-file                      , path+                     , text+                     , attoparsec+                     , attoparsec-path                      , hinotify                      , directory 
− test/Main.hs
@@ -1,17 +0,0 @@-import Path-import System.INotify (initINotify, removeWatch, killINotify)-import System.File.Follow (follow)-import System.Directory (getCurrentDirectory)-import Control.Monad (forever)-import Control.Exception (bracket)-import Control.Concurrent (threadDelay)---main = do-  i <- initINotify-  d <- getCurrentDirectory-  f <- parseAbsFile $ d ++ "/foo"-  bracket (follow i f print) (\watch -> do-                                removeWatch watch-                                killINotify i-                              ) $ \_ -> forever $ threadDelay 50000