From 380c1b0fd6c25dec3c924b82f1d721aa91a001da Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Mar 2014 23:37:54 -0400 Subject: prepare for hackage --- Property/File.hs | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 Property/File.hs (limited to 'Property/File.hs') diff --git a/Property/File.hs b/Property/File.hs deleted file mode 100644 index 55ca4fec..00000000 --- a/Property/File.hs +++ /dev/null @@ -1,40 +0,0 @@ -module Property.File where - -import Common - -type Line = String - -{- Replaces all the content of a file. -} -hasContent :: FilePath -> [Line] -> Property -f `hasContent` newcontent = fileProperty ("replace " ++ f) - (\_oldcontent -> newcontent) f - -{- Ensures that a line is present in a file, adding it to the end if not. -} -containsLine :: FilePath -> Line -> Property -f `containsLine` l = fileProperty (f ++ " contains:" ++ l) go f - where - go ls - | l `elem` ls = ls - | otherwise = ls++[l] - -{- Ensures that a line is not present in a file. - - Note that the file is ensured to exist, so if it doesn't, an empty - - file will be written. -} -lacksLine :: FilePath -> Line -> Property -f `lacksLine` l = fileProperty (f ++ " remove: " ++ l) (filter (/= l)) f - -{- Note: Does not remove symlinks or non-plain-files. -} -notPresent :: FilePath -> Property -notPresent f = check (doesFileExist f) $ Property (f ++ " not present") $ - makeChange $ nukeFile f - -fileProperty :: Desc -> ([Line] -> [Line]) -> FilePath -> Property -fileProperty desc a f = Property desc $ go =<< doesFileExist f - where - go True = do - ls <- lines <$> catchDefaultIO [] (readFile f) - let ls' = a ls - if ls' == ls - then noChange - else makeChange $ viaTmp writeFile f (unlines ls') - go False = makeChange $ writeFile f (unlines $ a []) -- cgit v1.2.3