packages feed

hslua-module-path 0.0.1 → 0.1.0

raw patch · 4 files changed

+85/−8 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -3,9 +3,19 @@ `hslua-module-paths` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +## 0.1.0++Released 2021-02-02.++- Fixed `directory`. This was the same as normalize.+- Improved documentation.+- Added more tests.+ ## 0.0.1 -* Initially created.+Released 2021-02-01.++- Initially created.  [1]: https://pvp.haskell.org [2]: https://github.com/hslua/hslua-module-path/releases
hslua-module-path.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                hslua-module-path-version:             0.0.1+version:             0.1.0 synopsis:            Lua module to work with file paths. description:         Lua module to work with file paths in a platform                      independent way.
src/Foreign/Lua/Module/Path.hs view
@@ -137,10 +137,11 @@  -- | See @Path.takeDirectory@ directory :: HaskellFunction-directory = toHsFnPrecursor Path.normalise+directory = toHsFnPrecursor Path.takeDirectory   <#> filepathParam   =#> [filepathResult "The filepath up to the last directory separator."]-  #? "Get the directory name; move up one level."+  #? ("Gets the directory name, i.e., removes the last directory " <>+      "separator and everything after from the given path.")  -- | See @Path.takeFilename@ filename :: HaskellFunction@@ -215,10 +216,12 @@   #? T.unlines      [ "Normalizes a path."      , ""-     , "- `//` outside of the drive can be made blank"-     , "- `/` becomes the `path.separator`"-     , "- `./` -> \'\'"-     , "- an empty path becomes `.`"+     , " - `//` makes sense only as part of a (Windows) network drive;"+     , "   elsewhere, multiple slashes are reduced to a single"+     , "   `path.separator` (platform dependent)."+     , " - `/` becomes `path.separator` (platform dependent)."+     , " - `./` is removed."+     , " - an empty path becomes `.`"      ]  -- | See @Path.splitDirectories@.
test/test-path.lua view
@@ -19,6 +19,70 @@     end),   }, +  group 'directory' {+    test('directory from file path', function ()+      print(path.join{'/', '2020', 'img', 'mask.jpg'})+      assert.are_equal(+        path.directory(path.join{'/', '2020', 'img', 'mask.jpg'}),+        path.join{'/', '2020', 'img'}+      )+    end),+    test('drops trailing path sep', function ()+      assert.are_equal(+        path.directory(path.join{'this', 'that'} .. path.separator),+        path.join{'this', 'that'}+      )+    end),+    test('returns dot if given just a filename', function ()+      assert.are_equal(+        path.directory('index.html'),+        '.'+      )+    end)+  },++  group 'filename' {+    test('removes directories', function ()+      assert.are_equal(+        path.filename(path.join{'paper', 'refs.bib'}),+        'refs.bib'+      )+      assert.are_equal(+        path.filename(path.join{'www', '.htaccess'}),+        '.htaccess'+      )+    end),+    test('empty if no filename present', function ()+      assert.are_equal(+        path.filename(path.join{'usr', 'bin'} .. path.separator),+        ''+      )+    end)+  },++  group 'is_absolute' {+    test('network path is absolute', function ()+      local paths = {'c:', 'Applications'}+      assert.is_truthy(path.is_absolute '//foo/bar')+    end),+    test('pure filename is not absolute', function ()+      assert.is_falsy(path.is_absolute '1337.txt')+    end),+  },++  group 'is_relative' {+    test('joined paths are relative', function ()+      local paths = {'one', 'two', 'test'}+      assert.is_truthy(path.is_relative(path.join(paths)))+    end),+    test('pure filename is relative', function ()+      assert.is_truthy(path.is_relative '1337.txt')+    end),+    test('network path is not relative', function ()+      assert.is_falsy(path.is_relative '//foo/bar')+    end),+  },+   group 'splitting/joining' {     test('split_path is inverse of join', function ()       local paths = {'one', 'two', 'test'}