aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2019-09-12 09:00:04 +0200
committerPatrick Spek <p.spek@tyil.nl>2019-09-12 09:00:04 +0200
commit4f1530055cafb849de542f6f4a2434e7f7ede358 (patch)
tree511e975b099f164feb15dd17213089de1ada432f
Initial commit
-rw-r--r--.editorconfig16
-rw-r--r--.gitignore14
-rw-r--r--.gitlab-ci.yml23
-rw-r--r--.travis.yml13
-rw-r--r--CHANGELOG.md9
-rw-r--r--META6.json25
-rw-r--r--README.pod623
-rw-r--r--lib/IO/Path/XDG.pm680
8 files changed, 203 insertions, 0 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..74dde7f
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+indent_style = tab
+indent_size = 4
+
+[*.json]
+indent_style = space
+indent_size = 2
+
+[*.yml]
+indent_style = space
+indent_size = 2
+
+# vim: ft=dosini
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..93356c2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,14 @@
+## Perl 6 precompilation files ##
+.precomp
+
+## Editor files ##
+
+# emacs
+*~
+
+# vim
+.*.sw?
+
+# comma
+.idea
+*.iml
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..b09cfa5
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,23 @@
+IO::Path::XDG:
+ only:
+ - master
+ image: rakudo-star
+ before_script:
+ - zef install . --deps-only --test-depends --/test
+ script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t
+ artifacts:
+ name: "perl6-IO-Path-XDG"
+ paths:
+ - META6.json
+ - bin
+ - lib
+ - resources
+ - t
+
+test:
+ except:
+ - master
+ image: rakudo-star
+ before_script:
+ - zef install . --deps-only --test-depends --/test
+ script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..077ddb0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,13 @@
+language: perl6
+
+perl6:
+ - latest
+
+os:
+ - linux
+
+install:
+ - rakudobrew build zef
+ - zef install --deps-only .
+
+script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t/
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..1003abb
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,9 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+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).
+
+## [UNRELEASED]
+- Initial release
diff --git a/META6.json b/META6.json
new file mode 100644
index 0000000..387e5e6
--- /dev/null
+++ b/META6.json
@@ -0,0 +1,25 @@
+{
+ "api": "0",
+ "authors": [
+ "Patrick Spek <p.spek@tyil.work>"
+ ],
+ "depends": [
+
+ ],
+ "description": "Convenience functions for working with the XDG Base Directory Specification",
+ "license": "AGPL-3.0",
+ "meta-version": 0,
+ "name": "IO::Path::XDG",
+ "perl": "6.d",
+ "provides": {
+ "IO::Path::XDG": "lib/IO/Path/XDG.pm6"
+ },
+ "resources": [
+
+ ],
+ "source-url": "",
+ "tags": [
+
+ ],
+ "version": "0.0.0"
+} \ No newline at end of file
diff --git a/README.pod6 b/README.pod6
new file mode 100644
index 0000000..99f4dbe
--- /dev/null
+++ b/README.pod6
@@ -0,0 +1,23 @@
+=begin pod
+
+=NAME IO::Path::XDG
+=AUTHOR Patrick Spek <p.spek@tyil.work>
+=VERSION 0.0.0
+
+=head1 Description
+
+Convenience functions for working with the XDG Base Directory Specification
+
+=head1 Installation
+
+Install this module through L<zef|https://github.com/ugexe/zef>:
+
+=begin code :lang<sh>
+zef install IO::Path::XDG
+=end code
+
+=head1 License
+
+This module is distributed under the terms of the AGPL-3.0.
+
+=end pod
diff --git a/lib/IO/Path/XDG.pm6 b/lib/IO/Path/XDG.pm6
new file mode 100644
index 0000000..f0ab832
--- /dev/null
+++ b/lib/IO/Path/XDG.pm6
@@ -0,0 +1,80 @@
+#! /usr/bin/env false
+
+use v6.d;
+
+unit module IO::Path::XDG;
+
+#| 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.
+sub xdg-config-home (
+ --> IO::Path
+) is export {
+ return %*ENV<XDG_CONFIG_HOME>.IO if %*ENV<XDG_CONFIG_HOME>:exists;
+
+ $*HOME.add(".config");
+}
+
+#| Returns an IO::Path for $XDG_CACHE_HOME, if it exists as environment
+#| variable. Otherwise, return the default value, $HOME/.cache. This directory
+#| should contain user-specific, non-essential (cached) data.
+sub xdg-cache-home (
+ --> IO::Path
+) is export {
+ return %*ENV<XDG_CACHE_HOME>.IO if %*ENV<XDG_CACHE_HOME>:exists;
+
+ $*HOME.IO.add(".cache");
+}
+
+#| 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.
+sub xdg-data-home (
+ --> IO::Path
+) is export {
+ return %*ENV<XDG_DATA_HOME>.IO if %*ENV<XDG_DATA_HOME>:exists;
+
+ $*HOME.add(".local/share");
+}
+
+#| Returns an IO::Path for $XDG_RUNTIME_DIR, if it exists as environment
+#| variable. Otherwise, return an IO::Path to a temporary directory. This
+#| directory should contain user-specific runtime files and other file objects.
+sub xdg-runtime-dir (
+ --> IO::Path
+) is export {
+ return %*ENV<XDG_RUNTIME_DIR>.IO if %*ENV<XDG_RUNTIME_DIR>:exists;
+
+ # XDG_RUNTIME_DIR is the only XDG basedir variant that does not come with
+ # defaults. However, there are a number of de facto standard locations to
+ # make use of. Try them, and return whichever hits first that also seems to
+ # exist on the user's system.
+ [
+ "/var/run".IO.add(+$*USER),
+ "/var/run".IO.add(~$*USER),
+ $*HOME.add(".local/run"),
+ $*TMPDIR,
+ $*CWD,
+ ]
+ .grep(*.d)
+ .first
+ .add($*PID)
+}
+
+=begin pod
+
+=NAME IO::Path::XDG
+=AUTHOR Patrick Spek <p.spek@tyil.work>
+=VERSION 0.0.0
+
+=head1 Synopsis
+
+=head1 Description
+
+=head1 Examples
+
+=head1 See also
+
+=end pod
+
+# vim: ft=perl6 noet