shikensu 0.3.7 → 0.3.8
raw patch · 3 files changed
+82/−23 lines, 3 filesdep ~bytestringdep ~tastydep ~tasty-hunitPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: bytestring, tasty, tasty-hunit, unordered-containers
API changes (from Hackage documentation)
+ Shikensu.Contrib: setContent :: ByteString -> Dictionary -> Dictionary
+ Shikensu.Contrib: setContentDef :: ByteString -> Definition -> Definition
+ Shikensu.Contrib: transformContent :: (Definition -> Maybe ByteString) -> Dictionary -> Dictionary
+ Shikensu.Contrib: transformContentDef :: (Definition -> Maybe ByteString) -> Definition -> Definition
Files
- shikensu.cabal +27/−22
- src/Shikensu/Contrib.hs +31/−0
- tests/Test/Contrib.hs +24/−1
shikensu.cabal view
@@ -1,9 +1,11 @@--- This file has been generated from package.yaml by hpack version 0.17.0.+-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack+--+-- hash: fb09818f3cf65658cd8ba3ba520e9ba2d557fe1cb4ab855df52cecec43b78aa8 name: shikensu-version: 0.3.7+version: 0.3.8 synopsis: Run a sequence of functions on in-memory representations of files description: See README at <https://github.com/icidasset/shikensu#readme> category: Filesystem@@ -24,15 +26,15 @@ src default-extensions: DisambiguateRecordFields DuplicateRecordFields OverloadedStrings build-depends:- aeson == 1.*- , base >= 4.9 && < 5- , bytestring == 0.*- , directory == 1.*- , filepath == 1.*- , flow == 1.*- , Glob >= 0.7 && < 1- , unordered-containers == 0.*- , text == 1.*+ Glob >=0.7 && <1+ , aeson ==1.*+ , base >=4.9 && <5+ , bytestring ==0.10.*+ , directory ==1.*+ , filepath ==1.*+ , flow ==1.*+ , text ==1.*+ , unordered-containers ==0.2.* exposed-modules: Shikensu Shikensu.Contrib@@ -42,6 +44,8 @@ Shikensu.Metadata Shikensu.Sorting Shikensu.Utilities+ other-modules:+ Paths_shikensu default-language: Haskell2010 test-suite spec@@ -52,17 +56,17 @@ src default-extensions: DisambiguateRecordFields DuplicateRecordFields OverloadedStrings build-depends:- aeson == 1.*- , base >= 4.9 && < 5- , bytestring == 0.*- , directory == 1.*- , filepath == 1.*- , flow == 1.*- , Glob >= 0.7 && < 1- , unordered-containers == 0.*- , text == 1.*- , tasty == 0.*- , tasty-hunit == 0.*+ Glob >=0.7 && <1+ , aeson ==1.*+ , base >=4.9 && <5+ , bytestring ==0.10.*+ , directory ==1.*+ , filepath ==1.*+ , flow ==1.*+ , tasty >=0.11 && <1.1+ , tasty-hunit >=0.9 && <1+ , text ==1.*+ , unordered-containers ==0.2.* other-modules: Test.Contrib Test.Example@@ -77,4 +81,5 @@ Shikensu.Metadata Shikensu.Sorting Shikensu.Utilities+ Paths_shikensu default-language: Haskell2010
src/Shikensu/Contrib.hs view
@@ -22,6 +22,10 @@ , renderContentDef , replaceMetadata , replaceMetadataDef+ , setContent+ , setContentDef+ , transformContent+ , transformContentDef ) where import Data.ByteString (ByteString)@@ -235,3 +239,30 @@ replaceMetadataDef :: Metadata -> Definition -> Definition replaceMetadataDef given def = def { metadata = given }+++{-| Set content.++Set content directly.+-}+setContent :: ByteString -> Dictionary -> Dictionary+setContent content =+ fmap (setContentDef content)+++setContentDef :: ByteString -> Definition -> Definition+setContentDef content def =+ def { content = Just content }+++{-| Transform content.++Alias for `renderContent`.+-}+transformContent :: (Definition -> Maybe ByteString) -> Dictionary -> Dictionary+transformContent = renderContent+++transformContentDef :: (Definition -> Maybe ByteString) -> Definition -> Definition+transformContentDef =+ renderContentDef
tests/Test/Contrib.hs view
@@ -16,7 +16,7 @@ import qualified Data.HashMap.Strict as HashMap (fromList, lookup) import qualified Data.List as List (head, reverse) import qualified Data.Text as Text (pack, unpack)-import qualified Data.Text.Encoding as Text (decodeUtf8)+import qualified Data.Text.Encoding as Text (decodeUtf8, encodeUtf8) import qualified Data.Text.IO as Text (readFile) import qualified Shikensu import qualified Shikensu.Contrib as Contrib@@ -35,6 +35,8 @@ , testRename , testRenameExt , testRenderContent+ , testSetContent+ , testTransformContent , testWrite ] @@ -232,6 +234,27 @@ testCase "Should `renderContent`" $ assertDef definition (Shikensu.content .> fmap Text.decodeUtf8) theResult ++testSetContent :: TestTree+testSetContent =+ let+ content = Text.encodeUtf8 "<html># Example\n</html>"+ dictionary = fmap (Contrib.setContent content) (example_md >>= Contrib.IO.read)+ definition = fmap List.head dictionary+ in+ testCase "Should `setContent`"+ $ assertDef definition Shikensu.content (Just content)+++testTransformContent :: TestTree+testTransformContent =+ let+ theResult = Just (Text.pack "<html># Example\n</html>")+ dictionary = fmap (Contrib.transformContent renderer) (example_md >>= Contrib.IO.read)+ definition = fmap List.head dictionary+ in+ testCase "Should `transformContent`"+ $ assertDef definition (Shikensu.content .> fmap Text.decodeUtf8) theResult testWrite :: TestTree