path 0.1.0 → 0.2.0
raw patch · 3 files changed
+30/−18 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Path: parentAbs :: Path Abs t -> Path Abs Dir
+ Path: dirname :: Path b Dir -> Path Rel Dir
+ Path: parent :: Path Abs t -> Path Abs Dir
Files
- path.cabal +1/−1
- src/Path.hs +19/−7
- test/Main.hs +10/−10
path.cabal view
@@ -1,5 +1,5 @@ name: path-version: 0.1.0+version: 0.2.0 synopsis: Path description: Path license: BSD3
src/Path.hs view
@@ -27,8 +27,9 @@ ,(</>) ,stripDir ,isParentOf- ,parentAbs+ ,parent ,filename+ ,dirname -- * Conversion ,toFilePath )@@ -234,24 +235,35 @@ -- -- The following properties hold: ----- @parentAbs (parent \<\/> child) == parent@+-- @parent (parent \<\/> child) == parent@ -- -- On the root, getting the parent is idempotent: ----- @parentAbs (parentAbs \"\/\") = \"\/\"@+-- @parent (parent \"\/\") = \"\/\"@ ---parentAbs :: Path Abs t -> Path Abs Dir-parentAbs (Path fp) =+parent :: Path Abs t -> Path Abs Dir+parent (Path fp) = Path (normalizeDir (FilePath.takeDirectory (FilePath.dropTrailingPathSeparator fp))) --- | Extract the relative filename from a given location.+-- | Extract the file part of a path. -- -- The following properties hold: -- -- @filename (parent \<\/> filename a) == a@ -- filename :: Path b File -> Path Rel File-filename (Path l) = Path (normalizeFile (FilePath.takeFileName l))+filename (Path l) =+ Path (normalizeFile (FilePath.takeFileName l))++-- | Extract the last directory name of a path.+--+-- The following properties hold:+--+-- @dirname (parent \<\/> dirname a) == a@+--+dirname :: Path b Dir -> Path Rel Dir+dirname (Path l) =+ Path (last (FilePath.splitPath l)) -------------------------------------------------------------------------------- -- Internal functions
test/Main.hs view
@@ -23,7 +23,7 @@ describe "Operations: (</>)" operationAppend describe "Operations: stripDir" operationStripDir describe "Operations: isParentOf" operationIsParentOf- describe "Operations: parentAbs" operationParentAbs+ describe "Operations: parent" operationParent describe "Operations: filename" operationFilename -- | The 'filename' operation.@@ -38,18 +38,18 @@ filename $(mkRelFile "bar.txt")) == $(mkRelFile "bar.txt")) --- | The 'parentAbs' operation.-operationParentAbs :: Spec-operationParentAbs =- do it "parentAbs (parent </> child) == parent"- (parentAbs ($(mkAbsDir "/foo") </>+-- | The 'parent' operation.+operationParent :: Spec+operationParent =+ do it "parent (parent </> child) == parent"+ (parent ($(mkAbsDir "/foo") </> $(mkRelDir "bar")) == $(mkAbsDir "/foo"))- it "parentAbs \"\" == \"\""- (parentAbs $(mkAbsDir "/") ==+ it "parent \"\" == \"\""+ (parent $(mkAbsDir "/") == $(mkAbsDir "/"))- it "parentAbs (parentAbs \"\") == \"\""- (parentAbs (parentAbs $(mkAbsDir "/")) ==+ it "parent (parent \"\") == \"\""+ (parent (parent $(mkAbsDir "/")) == $(mkAbsDir "/")) -- | The 'isParentOf' operation.