hslua-module-path 1.0.0 → 1.0.1
raw patch · 6 files changed
+68/−111 lines, 6 filesdep +hslua-coredep −hsluadep ~hslua-marshallingdep ~hslua-packagingdep ~textPVP ok
version bump matches the API change (PVP)
Dependencies added: hslua-core
Dependencies removed: hslua
Dependency ranges changed: hslua-marshalling, hslua-packaging, text
API changes (from Hackage documentation)
Files
- CHANGELOG.md +19/−12
- LICENSE +1/−1
- README.md +1/−1
- hslua-module-path.cabal +12/−10
- src/HsLua/Module/Path.hs +26/−81
- test/test-hslua-module-path.hs +9/−6
CHANGELOG.md view
@@ -1,27 +1,34 @@ # Changelog -`hslua-module-paths` uses [PVP Versioning][1].-The changelog is available [on GitHub][2].+`hslua-module-paths` uses [PVP Versioning][]. -## 0.1.0.1+## hslua-module-path-1.0.1 +- Bumped upper bound of hslua-core and hslua-marshalling to+ allow their respective version 2.1.++## hslua-module-path-1.0.0++- Updated to hslua 2.0.++## hslua-module-path-0.1.0.1+ Released 2021-02-06. -- Changed minimal cabal version to 2.2.+- Changed minimal cabal version to 2.2. -## 0.1.0+## hslua-module-path-0.1.0 Released 2021-02-02. -- Fixed `directory`. This was the same as normalize.-- Improved documentation.-- Added more tests.+- Fixed `directory`. This was the same as normalize.+- Improved documentation.+- Added more tests. -## 0.0.1+## hslua-module-path-0.0.1 Released 2021-02-01. -- Initially created.+- Initially created. -[1]: https://pvp.haskell.org-[2]: https://github.com/hslua/hslua-module-path/releases+ [PVP Versioning]: https://pvp.haskell.org
LICENSE view
@@ -1,6 +1,6 @@ MIT License -Copyright © 2020-2021 Albert Krewinkel+Copyright © 2020-2022 Albert Krewinkel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
README.md view
@@ -6,7 +6,7 @@ [![Stackage Nightly][Stackage Nightly badge]](http://stackage.org/nightly/package/hslua-module-path) [![MIT license][License badge]](LICENSE) -[CI badge]: https://github.com/hslua/hslua-module-path/workflows/CI/badge.svg+[CI badge]: https://img.shields.io/github/workflow/status/hslua/hslua/CI.svg?logo=github [Hackage badge]: https://img.shields.io/hackage/v/hslua-module-path.svg?logo=haskell [Stackage Lts badge]: http://stackage.org/package/hslua-module-path/badge/lts [Stackage Nightly badge]: http://stackage.org/package/hslua-module-path/badge/nightly
hslua-module-path.cabal view
@@ -1,16 +1,16 @@ cabal-version: 2.2 name: hslua-module-path-version: 1.0.0+version: 1.0.1 synopsis: Lua module to work with file paths. description: Lua module to work with file paths in a platform independent way.-homepage: https://github.com/hslua/hslua-module-path-bug-reports: https://github.com/hslua/hslua-module-path/issues+homepage: https://hslua.org/+bug-reports: https://github.com/hslua/hslua/issues license: MIT license-file: LICENSE author: Albert Krewinkel maintainer: Albert Krewinkel <albert@zeitkraut.de>-copyright: © 2020-2021 Albert Krewinkel+copyright: © 2020-2022 Albert Krewinkel category: Foreign build-type: Simple extra-doc-files: README.md@@ -21,20 +21,22 @@ , GHC == 8.4.4 , GHC == 8.6.5 , GHC == 8.8.4- , GHC == 8.10.4+ , GHC == 8.10.7 , GHC == 9.0.1+ , GHC == 9.2.1 source-repository head type: git- location: https://github.com/hslua/hslua-module-path.git+ location: https://github.com/hslua/hslua+ subdir: hslua-module-path common common-options build-depends: base >= 4.9.1 && < 5 , filepath >= 1.4 && < 1.5- , hslua >= 2.0 && < 2.1- , hslua-marshalling >= 2.0 && < 2.1- , hslua-packaging >= 2.0 && < 2.1- , text >= 1.0 && < 1.3+ , hslua-core >= 2.1 && < 2.2+ , hslua-marshalling >= 2.0 && < 2.2+ , hslua-packaging >= 2.0 && < 2.2+ , text >= 1.2 && < 2.1 ghc-options: -Wall -Wcompat
src/HsLua/Module/Path.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-| Module : HsLua.Module.Path-Copyright : © 2021 Albert Krewinkel+Copyright : © 2021-2022 Albert Krewinkel License : MIT Maintainer : Albert Krewinkel <albert+hslua@zeitkraut.de> @@ -43,8 +43,7 @@ import HsLua.Core ( LuaError, getglobal, getmetatable, nth, pop, rawset, remove, top ) import HsLua.Marshalling- ( Peeker, peekBool, peekList, peekString- , pushBool, pushList, pushName, pushString )+ ( Peeker, peekList, peekString, pushList, pushName, pushString ) import HsLua.Packaging import qualified Data.Text as T@@ -112,7 +111,7 @@ directory = defun "directory" ### liftPure Path.takeDirectory <#> filepathParam- =#> [filepathResult "The filepath up to the last directory separator."]+ =#> filepathResult "The filepath up to the last directory separator." #? ("Gets the directory name, i.e., removes the last directory " <> "separator and everything after from the given path.") `since` initialVersion@@ -122,7 +121,7 @@ filename = defun "filename" ### liftPure Path.takeFileName <#> filepathParam- =#> [filepathResult "File name part of the input path."]+ =#> filepathResult "File name part of the input path." #? "Get the file name." `since` initialVersion @@ -131,8 +130,8 @@ is_absolute = defun "is_absolute" ### liftPure Path.isAbsolute <#> filepathParam- =#> [booleanResult ("`true` iff `filepath` is an absolute path, " <>- "`false` otherwise.")]+ =#> boolResult ("`true` iff `filepath` is an absolute path, " <>+ "`false` otherwise.") #? "Checks whether a path is absolute, i.e. not fixed to a root." `since` initialVersion @@ -141,8 +140,8 @@ is_relative = defun "is_relative" ### liftPure Path.isRelative <#> filepathParam- =#> [booleanResult ("`true` iff `filepath` is a relative path, " <>- "`false` otherwise.")]+ =#> boolResult ("`true` iff `filepath` is a relative path, " <>+ "`false` otherwise.") #? "Checks whether a path is relative or fixed to a root." `since` initialVersion @@ -150,16 +149,9 @@ join :: LuaError e => DocumentedFunction e join = defun "join" ### liftPure Path.joinPath- <#> Parameter- { parameterPeeker = peekList peekFilePath- , parameterDoc = ParameterDoc- { parameterName = "filepaths"- , parameterType = "list of strings"- , parameterDescription = "path components"- , parameterIsOptional = False- }- }- =#> [filepathResult "The joined path."]+ <#> parameter (peekList peekFilePath) "{string,...}"+ "filepaths" "path components"+ =#> filepathResult "The joined path." #? "Join path elements back together by the directory separator." `since` initialVersion @@ -176,12 +168,8 @@ "string" "root" "root path"- <#> optionalParameter- peekBool- "boolean"- "unsafe"- "whether to allow `..` in the result."- =#> [filepathResult "contracted filename"]+ <#> opt (boolParam "unsafe" "whether to allow `..` in the result.")+ =#> filepathResult "contracted filename" #? mconcat [ "Contract a filename, based on a relative path. Note that the " , "resulting path will never introduce `..` paths, as the "@@ -197,7 +185,7 @@ normalize = defun "normalize" ### liftPure Path.normalise <#> filepathParam- =#> [filepathResult "The normalized path."]+ =#> filepathResult "The normalized path." #? T.unlines [ "Normalizes a path." , ""@@ -218,7 +206,7 @@ split = defun "split" ### liftPure Path.splitDirectories <#> filepathParam- =#> [filepathListResult "List of all path components."]+ =#> filepathListResult "List of all path components." #? "Splits a path by the directory separator." `since` initialVersion @@ -227,21 +215,9 @@ split_extension = defun "split_extension" ### liftPure Path.splitExtension <#> filepathParam- =#> [ FunctionResult- { fnResultPusher = pushString . fst- , fnResultDoc = ResultValueDoc- { resultValueType = "string"- , resultValueDescription = "filepath without extension"- }- },- FunctionResult- { fnResultPusher = pushString . snd- , fnResultDoc = ResultValueDoc- { resultValueType = "string"- , resultValueDescription = "extension or empty string"- }- }- ]+ =#> (functionResult (pushString . fst) "string" "filepath without extension"+ +++ functionResult (pushString . snd) "string" "extension or empty string") #? ("Splits the last extension from a file path and returns the parts. " <> "The extension, if present, includes the leading separator; " <> "if the path has no extension, then the empty string is returned "@@ -261,7 +237,7 @@ , parameterIsOptional = False } }- =#> [filepathListResult "list of directories in search path"]+ =#> filepathListResult "list of directories in search path" #? ("Takes a string and splits it on the `search_path_separator` " <> "character. Blank items are ignored on Windows, " <> "and converted to `.` on Posix. "@@ -274,7 +250,7 @@ ### liftPure2 Path.combine <#> filepathParam <#> filepathParam- =#> [filepathResult "combined paths"]+ =#> filepathResult "combined paths" #? "Combine two paths with a path separator." -- | Adds an extension to a file path. Wraps @'Path.addExtension'@.@@ -291,7 +267,7 @@ , parameterIsOptional = False } }- =#> [filepathResult "filepath with extension"]+ =#> filepathResult "filepath with extension" #? "Adds an extension, even if there is already one." `since` initialVersion @@ -339,49 +315,18 @@ -- | Filepath function parameter. filepathParam :: Parameter e FilePath-filepathParam = Parameter- { parameterPeeker = peekFilePath- , parameterDoc = ParameterDoc- { parameterName = "filepath"- , parameterType = "string"- , parameterDescription = "path"- , parameterIsOptional = False- }- }+filepathParam = parameter peekFilePath "string" "filepath" "path" -- | Result of a function returning a file path. filepathResult :: Text -- ^ Description- -> FunctionResult e FilePath-filepathResult desc = FunctionResult- { fnResultPusher = pushString- , fnResultDoc = ResultValueDoc- { resultValueType = "string"- , resultValueDescription = desc- }- }+ -> FunctionResults e FilePath+filepathResult = stringResult -- | List of filepaths function result. filepathListResult :: LuaError e => Text -- ^ Description- -> FunctionResult e [FilePath]-filepathListResult desc = FunctionResult- { fnResultPusher = pushList pushString- , fnResultDoc = ResultValueDoc- { resultValueType = "list of strings"- , resultValueDescription = desc- }- }---- | Boolean function result.-booleanResult :: Text -- ^ Description- -> FunctionResult e Bool-booleanResult desc = FunctionResult- { fnResultPusher = pushBool- , fnResultDoc = ResultValueDoc- { resultValueType = "boolean"- , resultValueDescription = desc- }- }+ -> FunctionResults e [FilePath]+filepathListResult = functionResult (pushList pushString) "{string,...}" -- -- Helpers
test/test-hslua-module-path.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE TypeApplications #-} {-| Module : Main-Copyright : © 2021 Albert Krewinkel+Copyright : © 2021-2022 Albert Krewinkel License : MIT Maintainer : Albert Krewinkel <albert+hslua@zeitkraut.de> Stability : stable@@ -14,20 +14,21 @@ module Main (main) where import Control.Monad (void)-import HsLua (Lua)-import HsLua.Packaging.Module (preloadModule, preloadModuleWithName, pushModule)+import HsLua.Core (Lua, top)+import HsLua.Packaging ( preloadModule, preloadModuleWithName, pushModule+ , registerModule) import HsLua.Module.Path (documentedModule) import Test.Tasty (TestTree, defaultMain, testGroup) import Test.Tasty.HUnit (assertEqual, testCase) import Test.Tasty.Lua (translateResultsFromFile) -import qualified HsLua as Lua+import qualified HsLua.Core as Lua main :: IO () main = do luaTestResults <- Lua.run @Lua.Exception $ do Lua.openlibs- Lua.registerModule documentedModule+ registerModule documentedModule Lua.pop 1 translateResultsFromFile "test/test-path.lua" defaultMain $ testGroup "hslua-module-path" [tests, luaTestResults]@@ -42,7 +43,9 @@ Lua.openlibs preloadModule documentedModule assertEqual' "function not added to preloader" Lua.TypeFunction =<< do- Lua.getglobal' "package.preload.path"+ void $ Lua.getglobal "package"+ *> Lua.getfield top "preload"+ *> Lua.getfield top "path" Lua.ltype (-1) , testCase "path module can be loaded as hspath" . Lua.run $ do