aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-04-25 11:13:25 +0200
committerPatrick Spek <p.spek@tyil.nl>2020-04-25 11:13:25 +0200
commitd7ab7f7c2497d58c8c29f98494eb450b426ec2e6 (patch)
treec5bc165932aca67b9b34267f837f607f4f547e49
parent116b9f283fc1e5efab2a9aef350a2dcbf137875f (diff)
downloadIO::Path::XDG-d7ab7f7c2497d58c8c29f98494eb450b426ec2e6.tar.gz
IO::Path::XDG-d7ab7f7c2497d58c8c29f98494eb450b426ec2e6.tar.bz2
Add subs to handle -dirs variantsHEADv0.2.0master
-rw-r--r--CHANGELOG.md15
-rw-r--r--META6.json4
-rw-r--r--lib/IO/Path/XDG.rakumod41
3 files changed, 57 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d74a60..15056c9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,5 +5,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).
+## [0.2.0] - 2020-04-25
+
+### Added
+
+- `xdg-config-dirs` has been added, which will return a sequence of IO::Path
+ objects to refer to all configuration dirs an application *should* check for
+ user defined configuration.
+
+- `xdg-data-dirs` has been added, which will return a sequence of IO::Path
+ objects to refer to all user specific data files.
+
+### Changed
+
+- References to Perl 6 have been updated to refer to Raku instead.
+
## [0.1.0] - 2019-09-12
- Initial release
diff --git a/META6.json b/META6.json
index f9aff61..8ef9e37 100644
--- a/META6.json
+++ b/META6.json
@@ -18,5 +18,5 @@
"source-url": "https://home.tyil.nl/git/raku/IO::Path::XDG/",
"tags": [
],
- "version": "0.1.1"
-}
+ "version": "0.2.0"
+} \ No newline at end of file
diff --git a/lib/IO/Path/XDG.rakumod b/lib/IO/Path/XDG.rakumod
index 2b93d35..54c1941 100644
--- a/lib/IO/Path/XDG.rakumod
+++ b/lib/IO/Path/XDG.rakumod
@@ -4,6 +4,25 @@ use v6.d;
unit module IO::Path::XDG;
+#| Retrieve the value of XDG_CONFIG_DIRS as a sequence of IO::Path objects. If
+#| this variable is not set, it will use the default value of /etc/xdg. These
+#| directories should be read in order to retrieve configuration files.
+sub xdg-config-dirs (
+ #| When set to true, this sequence will start with the XDG_CONFIG_HOME
+ #| value (or its default).
+ Bool:D :$home = True,
+
+ --> Iterable
+) is export {
+ (
+ (xdg-config-home if $home),
+ (%*ENV<XDG_CONFIG_DIRS> // '/etc/xdg')
+ .split(':')
+ .map(*.IO)
+ .Slip,
+ )
+}
+
#| Returns an IO::Path for $XDG_CONFIG_HOME, if it exists as environment
#| variable. Otherwise, return the default value, $HOME/.config. This directory
#| should contain user-specific configuration files.
@@ -26,6 +45,26 @@ sub xdg-cache-home (
$*HOME.IO.add(".cache");
}
+#| Retrieve the value of XDG_DATA_DIRS as a sequence of IO::Path objects. If
+#| this variable is not set, it will use the default values of /usr/local/share
+#| and /usr/share. These directories should be read in order to retrieve user
+#| specific data files.
+sub xdg-data-dirs (
+ #| When set to true, this sequence will start with the XDG_DATA_HOME
+ #| value (or its default).
+ Bool:D :$home = True,
+
+ --> Iterable
+) is export {
+ (
+ (xdg-data-home if $home),
+ (%*ENV<XDG_DATA_DIRS> // '/usr/local/share:/usr/share')
+ .split(':')
+ .map(*.IO)
+ .Slip
+ )
+}
+
#| Returns an IO::Path for $XDG_DATA_HOME, if it exists as environment
#| variable. Otherwise, return the default value, $HOME/.local/share. This
#| directory should contain user-specific data files.
@@ -65,7 +104,7 @@ sub xdg-runtime-dir (
=NAME IO::Path::XDG
=AUTHOR Patrick Spek <p.spek@tyil.work>
-=VERSION 0.1.0
+=VERSION 0.2.0
=head1 Synopsis