summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Resource/Provider/Dummy.hs
blob: 548f845b2d3d11c340d3e1586a0f5f7dc78e40ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- | Dummy resource provider for testing purposes
--
module Hakyll.Core.Resource.Provider.Dummy
    ( dummyResourceProvider
    ) where

import Data.Map (Map)
import qualified Data.Map as M

import Data.Time (getCurrentTime)
import Data.ByteString.Lazy (ByteString)
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Encoding as TL

import Hakyll.Core.Resource
import Hakyll.Core.Resource.Provider

-- | Create a dummy 'ResourceProvider'
--
dummyResourceProvider :: Map String ByteString -> IO ResourceProvider
dummyResourceProvider vfs = makeResourceProvider
    (map resource (M.keys vfs))
    (return . TL.unpack . TL.decodeUtf8 . (vfs M.!) . unResource)
    (return . (vfs M.!) . unResource)
    (const getCurrentTime)