packages feed

file-embed 0.0.4.6 → 0.0.4.7

raw patch · 5 files changed

+26/−13 lines, 5 filesdep +HUnitdep +filepathPVP ok

version bump matches the API change (PVP)

Dependencies added: HUnit, filepath

API changes (from Hackage documentation)

Files

Data/FileEmbed.hs view
@@ -14,7 +14,7 @@     ) where  import Language.Haskell.TH.Syntax-    ( Exp (AppE, ListE, LitE, TupE)+    ( Exp (AppE, ListE, LitE, TupE, SigE) #if MIN_VERSION_template_haskell(2,5,0)     , Lit (StringL, StringPrimL, IntegerL) #else@@ -31,11 +31,11 @@ import Control.Monad (filterM) import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8-import Control.Arrow ((&&&), second, first)+import Control.Arrow ((&&&), second) import Control.Applicative ((<$>))-import Data.Monoid (mappend) import Data.ByteString.Unsafe (unsafePackAddressLen) import System.IO.Unsafe (unsafePerformIO)+import System.FilePath ((</>))  -- | Embed a single file in your source code. --@@ -57,7 +57,10 @@ -- > myDir :: [(FilePath, Data.ByteString.ByteString)] -- > myDir = $(embedDir "dirName") embedDir :: FilePath -> Q Exp-embedDir fp = ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))+embedDir fp = do+    typ <- [t| [(FilePath, B.ByteString)] |]+    e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))+    return $ SigE e typ  -- | Get a directory tree in the IO monad. --@@ -87,14 +90,12 @@ notHidden _ = True  fileList :: FilePath -> IO [(FilePath, B.ByteString)]-fileList top = map (first tail) <$> fileList' top ""+fileList top = fileList' top ""  fileList' :: FilePath -> FilePath -> IO [(FilePath, B.ByteString)] fileList' realTop top = do-    let prefix1 = top ++ "/"-        prefix2 = realTop ++ prefix1-    allContents <- filter notHidden <$> getDirectoryContents prefix2-    let all' = map (mappend prefix1 &&& mappend prefix2) allContents+    allContents <- filter notHidden <$> getDirectoryContents (realTop </> top)+    let all' = map ((top </>) &&& (\x -> realTop </> top </> x)) allContents     files <- filterM (doesFileExist . snd) all' >>=              mapM (liftPair2 . second B.readFile)     dirs <- filterM (doesDirectoryExist . snd) all' >>=
file-embed.cabal view
@@ -1,5 +1,5 @@ name:            file-embed-version:         0.0.4.6+version:         0.0.4.7 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -13,13 +13,14 @@ cabal-version:   >= 1.8 build-type:      Simple homepage:        https://github.com/snoyberg/file-embed-extra-source-files: test/main.hs, test/sample/foo+extra-source-files: test/main.hs, test/sample/foo, test/sample/bar/baz  library     build-depends:   base               >= 4       && < 5                    , bytestring         >= 0.9.1.4                    , directory          >= 1.0.0.3                    , template-haskell+                   , filepath     exposed-modules: Data.FileEmbed     ghc-options:     -Wall @@ -29,6 +30,8 @@     hs-source-dirs: test     build-depends: base                  , file-embed+                 , HUnit+                 , filepath  source-repository head   type:     git
test/main.hs view
@@ -1,6 +1,14 @@ {-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE OverloadedStrings #-}  import Data.FileEmbed+import Test.HUnit ((@?=))+import System.FilePath ((</>))  main :: IO ()-main = print $(embedDir "test/sample")+main = do+    let received = $(embedDir "test/sample")+    received @?=+        [ ("foo", "foo\r\n")+        , ("bar" </> "baz", "baz\r\n")+        ]
+ test/sample/bar/baz view
@@ -0,0 +1,1 @@+baz
test/sample/foo view
@@ -1,1 +1,1 @@-foo+foo