diff --git a/README.md b/README.md index 476b280..2722b1d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ is a simple file path library for Carp. ## Installation ```clojure -(load "https://veitheller.de/git/carpentry/path@0.0.3") +(load "git@git.veitheller.de:carpentry/path.git@0.0.4") ``` ### Usage @@ -16,7 +16,7 @@ has some functions to work with the `PATH` environment variable. It assumes either Windows or POSIX-style separators. -Look at [the documentation](https://veitheller.de/path) for more information. +Look at [the documentation](https://carpentry.dev/path) for more information.
diff --git a/docs/Path.html b/docs/Path.html index 5bb0cee..f407466 100644 --- a/docs/Path.html +++ b/docs/Path.html @@ -25,477 +25,488 @@ -

- Path -

-
- -
-
- -

- </> -

-
-
- defn -
-

- (Fn [a, b] String) -

-
-                    (</> before after)
-                
-

-

joins before and after using the default path separator.

+
+

+ Path +

+
+

is a simple file path library for Carp.

+

Installation

+
(load "git@git.veitheller.de:carpentry/path.git@0.0.4")
+
+

Usage

+

The Path module mostly operates on String arguments. It allows you to +split, join, and merge paths and extensions in a lot of different ways. It also +has some functions to work with the PATH environment variable.

+

It assumes either Windows or POSIX-style separators.

-

-
-
- -

- absolute -

-
-
- defn
-

- (Fn [(Ref String a)] (Maybe String)) -

-
-                    (absolute p)
-                
-

- -

-
-
- -

- absolute? -

-
-
- defn +
+ +

+ </> +

+
+
+ defn +
+

+ (Fn [a, b] String) +

+
+                        (</> before after)
+                    
+

+

joins before and after using the default path separator.

+ +

-

- (Fn [(Ref String a)] Bool) -

-
-                    (absolute? p)
-                
-

-

checks whether a path is absolute.

+
+ +

+ absolute +

+
+
+ defn +
+

+ (Fn [(Ref String a)] (Maybe String)) +

+
+                        (absolute p)
+                    
+

+

makes an absolute path from p.

+ +

+
+
+ +

+ absolute? +

+
+
+ defn +
+

+ (Fn [(Ref String a)] Bool) +

+
+                        (absolute? p)
+                    
+

+

checks whether a path is absolute.

As such, it is the inverse to relative?.

-

-
-
- -

- add-extension -

-
-
- defn +

-

- (Fn [(Ref String a), (Ref String b)] String) -

-
-                    (add-extension p ext)
-                
-

-

adds an extension ext to a path p.

+
+ +

+ add-extension +

+
+
+ defn +
+

+ (Fn [(Ref String a), (Ref String b)] String) +

+
+                        (add-extension p ext)
+                    
+

+

adds an extension ext to a path p.

-

-
-
- -

- basename -

-
-
- defn +

-

- (Fn [(Ref String a)] String) -

-
-                    (basename p)
-                
-

-

gets the basename of the path p.

+
+ +

+ basename +

+
+
+ defn +
+

+ (Fn [(Ref String a)] String) +

+
+                        (basename p)
+                    
+

+

gets the basename of the path p.

-

-
-
- -

- cwd -

-
-
- defn +

-

- (Fn [] (Maybe String)) -

-
-                    (cwd)
-                
-

-

returns the current working directory as a Maybe. The ways in +

+ +

+ cwd +

+
+
+ defn +
+

+ (Fn [] (Maybe String)) +

+
+                        (cwd)
+                    
+

+

returns the current working directory as a Maybe. The ways in which it can fail are OS-dependent, but it should happen relatively rare.

-

-
-
- -

- drop-extension -

-
-
- defn +

-

- (Fn [(Ref String a)] String) -

-
-                    (drop-extension p)
-                
-

-

drops the extension of a path p. Does nothing if there +

+ +

+ drop-extension +

+
+
+ defn +
+

+ (Fn [(Ref String a)] String) +

+
+                        (drop-extension p)
+                    
+

+

drops the extension of a path p. Does nothing if there is none.

-

-
-
- -

- extension -

-
-
- defn +

-

- (Fn [(Ref String a)] (Maybe String)) -

-
-                    (extension p)
-                
-

-

gets the extension of a file as a Maybe.

+
+ +

+ extension +

+
+
+ defn +
+

+ (Fn [(Ref String a)] (Maybe String)) +

+
+                        (extension p)
+                    
+

+

gets the extension of a file as a Maybe.

-

-
-
- -

- filename -

-
-
- defn +

-

- (Fn [(Ref String a)] (Maybe String)) -

-
-                    (filename p)
-                
-

-

gets the filename of the path p as a (Maybe String).

+
+ +

+ filename +

+
+
+ defn +
+

+ (Fn [(Ref String a)] (Maybe String)) +

+
+                        (filename p)
+                    
+

+

gets the filename of the path p as a (Maybe String).

It will return Nothing if an empty string is passed.

-

-
-
- -

- get-search-path -

-
-
- defn +

-

- (Fn [] (Maybe (Array String))) -

-
-                    (get-search-path)
-                
-

-

gets the PATH environment variable and splits it.

+
+ +

+ get-search-path +

+
+
+ defn +
+

+ (Fn [] (Maybe (Array String))) +

+
+                        (get-search-path)
+                    
+

+

gets the PATH environment variable and splits it.

-

-
-
- -

- has-extension? -

-
-
- defn +

-

- (Fn [(Ref String a)] Bool) -

-
-                    (has-extension? p)
-                
-

-

cheks whether the path p has an extension.

+
+ +

+ has-extension? +

+
+
+ defn +
+

+ (Fn [(Ref String a)] Bool) +

+
+                        (has-extension? p)
+                    
+

+

cheks whether the path p has an extension.

-

-
-
- -

- is-extension? -

-
-
- defn +

-

- (Fn [(Ref String a), (Ref String b)] Bool) -

-
-                    (is-extension? p ext)
-                
-

-

checks whether the path p has the extension ext.

+
+ +

+ is-extension? +

+
+
+ defn +
+

+ (Fn [(Ref String a), (Ref String b)] Bool) +

+
+                        (is-extension? p ext)
+                    
+

+

checks whether the path p has the extension ext.

-

-
-
- -

- join -

-
-
- defn +

-

- (Fn [(Ref (Array String) a)] String) -

-
-                    (join ps)
-                
-

-

joins the path components ps into a path.

+
+ +

+ join +

+
+
+ defn +
+

+ (Fn [(Ref (Array String) a)] String) +

+
+                        (join ps)
+                    
+

+

joins the path components ps into a path.

As such, it is the inverse to split.

-

-
-
- -

- path-max -

-
-
- external +

-

- Int -

- - - -

-

defines the maximum path length on this OS.

+
+ +

+ path-max +

+
+
+ external +
+

+ Int +

+ + + +

+

defines the maximum path length on this OS.

-

-
-
- -

- relative? -

-
-
- defn +

-

- (Fn [(Ref String a)] Bool) -

-
-                    (relative? p)
-                
-

-

checks whether a path is relative.

+
+ +

+ relative? +

+
+
+ defn +
+

+ (Fn [(Ref String a)] Bool) +

+
+                        (relative? p)
+                    
+

+

checks whether a path is relative.

As such, it is the inverse to absolute?.

-

-
-
- -

- replace-extension -

-
-
- defn +

-

- (Fn [(Ref String a), (Ref String b)] String) -

-
-                    (replace-extension p ext)
-                
-

-

replaces the extension of a path p with ext. Adds +

+ +

+ replace-extension +

+
+
+ defn +
+

+ (Fn [(Ref String a), (Ref String b)] String) +

+
+                        (replace-extension p ext)
+                    
+

+

replaces the extension of a path p with ext. Adds an extension if there previously was none.

-

-
-
- -

- search-path-separator -

-
-
- def +

-

- Char -

- - - -

-

is the separator for the PATH environment +

+ +

+ search-path-separator +

+
+
+ def +
+

+ Char +

+ + + +

+

is the separator for the PATH environment variable we use on this OS.

-

-
-
- -

- search-path-separator? -

-
-
- defn +

-

- (Fn [Char] Bool) -

-
-                    (search-path-separator? c)
-                
-

- -

-
-
- -

- separator -

-
-
- def +
+ +

+ search-path-separator? +

+
+
+ defn +
+

+ (Fn [Char] Bool) +

+
+                        (search-path-separator? c)
+                    
+

+ +

-

- Char -

- - - -

-

is the default separator we use on this OS.

+
+ +

+ separator +

+
+
+ def +
+

+ Char +

+ + + +

+

is the default separator we use on this OS.

-

-
-
- -

- separator? -

-
-
- defn +

-

- (Fn [(Ref Char StaticLifetime)] Bool) -

-
-                    (separator? c)
-                
-

-

checks whether the character c is a separator for the +

+ +

+ separator? +

+
+
+ defn +
+

+ (Fn [(Ref Char StaticLifetime)] Bool) +

+
+                        (separator? c)
+                    
+

+

checks whether the character c is a separator for the PATH environment variable on this OS.

-

-
-
- -

- separators -

-
-
- def +

-

- (Array Char) -

- - - -

-

is the possible separators we could use on this OS.

+
+ +

+ separators +

+
+
+ def +
+

+ (Array Char) +

+ + + +

+

is the possible separators we could use on this OS.

-

-
-
- -

- split -

-
-
- defn +

-

- (Fn [(Ref String a)] (Array String)) -

-
-                    (split p)
-                
-

-

splits the path p into its components.

+
+ +

+ split +

+
+
+ defn +
+

+ (Fn [(Ref String a)] (Array String)) +

+
+                        (split p)
+                    
+

+

splits the path p into its components.

As such, it is the inverse to join.

-

-
-
- -

- split-extension -

-
-
- defn +

-

- (Fn [(Ref String a)] (Maybe (Pair String String))) -

-
-                    (split-extension p)
-                
-

-

splits the path p on its extension.

+
+ +

+ split-extension +

+
+
+ defn +
+

+ (Fn [(Ref String a)] (Maybe (Pair String String))) +

+
+                        (split-extension p)
+                    
+

+

splits the path p on its extension.

It will return a (Maybe (Pair String String)). Maybe because there might not be an extension, and Pair because it will return the part before and after the extension.

@@ -514,27 +525,28 @@ the extension.

; => (Maybe.Just (Pair "file/path.txt.bob" "fred")) -

-
-
- -

- split-search-path -

-
-
- defn +

-

- (Fn [(Ref String a)] (Array String)) -

-
-                    (split-search-path p)
-                
-

-

splits a PATH environment variable p.

+
+ +

+ split-search-path +

+
+
+ defn +
+

+ (Fn [(Ref String a)] (Array String)) +

+
+                        (split-search-path p)
+                    
+

+

splits a PATH environment variable p.

-

+

+
diff --git a/path.carp b/path.carp index 2bf5f14..90ede1b 100644 --- a/path.carp +++ b/path.carp @@ -3,7 +3,7 @@ ## Installation ```clojure -(load \"https://veitheller.de/git/carpentry/path@0.0.3\") +(load \"git@git.veitheller.de:carpentry/path.git@0.0.4\") ``` ### Usage @@ -148,5 +148,5 @@ an extension if there previously was none.") (defn split-search-path [p] (String.split-by p &[search-path-separator])) (doc get-search-path "gets the `PATH` environment variable and splits it.") (defn get-search-path [] - (Maybe.apply (IO.getenv @"PATH") &(fn [p] (split-search-path &p)))) + (Maybe.apply (IO.getenv "PATH") &(fn [p] (split-search-path &p)))) )