packages feed

snipcheck 0.1.0.1 → 0.1.0.2

raw patch · 3 files changed

+27/−4 lines, 3 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Snipcheck: trim :: String -> String

Files

README.md view
@@ -1,5 +1,7 @@ # Snipcheck +https://travis-ci.org/nmattia/snipcheck.svg?branch=master+ Snipcheck makes sure that the code snippets in markdown files are up-to-date.  This is very much a work in progress. The only function currently available is@@ -26,3 +28,18 @@      some more content ++## Release check-list++1. Make sure you're on master++1. Bump the version in `snipcheck.cabal`:++> Given a version number MAJOR.MINOR.PATCH, increment the:+>+> MAJOR version when you make incompatible API changes,+> MINOR version when you add functionality in a backwards-compatible manner, and+> PATCH version when you make backwards-compatible bug fixes.++1. Run `stack update --pvp-bounds both .` to upload `snipcheck` to `hackage`+1. Commit the updated `snipcheck.cabal` file.
snipcheck.cabal view
@@ -1,5 +1,5 @@ name: snipcheck-version: 0.1.0.1+version: 0.1.0.2 cabal-version: >=1.10 build-type: Simple license: MIT
src/Snipcheck.hs view
@@ -4,11 +4,13 @@ module Snipcheck where  import Control.Monad+import Data.Char (isSpace)+import Data.List (dropWhileEnd) import Data.Maybe-import qualified Data.Map as Map import Data.Monoid import System.Process(readCreateProcess, shell) import Text.Pandoc (Block(..))+import qualified Data.Map as Map  import qualified Text.Pandoc as Pandoc @@ -81,19 +83,23 @@     unMetaStr (Pandoc.Str s) = Just s     unMetaStr _ = Nothing +trim :: String -> String+trim = dropWhile isSpace . dropWhileEnd isSpace+ check :: Pandoc.Block -> IO () check (CodeBlock (typ, classes, kvs) content)   | "shell" `elem` classes = do       let Right cmds = extractCommands content       forM_ cmds $ \(cmd, expected) -> do-        actual <- lines <$> readCreateProcess (shell cmd) ""-        let expected' = sloppyString <$> expected+        actual <- (fmap trim . lines) <$> readCreateProcess (shell cmd) ""+        let expected' = (sloppyString . trim) <$> expected         unless (checkSloppy actual expected') $ error $ mconcat           [ "Couldnt match expected ", show expected'           , " with " <> show actual           ]   | otherwise = print (typ, classes, kvs) check _ = return ()+  extractCommands :: String -> Either String [(String, [String])] extractCommands str = go (lines str)