From 4f1530055cafb849de542f6f4a2434e7f7ede358 Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Thu, 12 Sep 2019 09:00:04 +0200
Subject: Initial commit
---
.editorconfig | 16 +++++++++++
.gitignore | 14 ++++++++++
.gitlab-ci.yml | 23 +++++++++++++++
.travis.yml | 13 +++++++++
CHANGELOG.md | 9 ++++++
META6.json | 25 +++++++++++++++++
README.pod6 | 23 +++++++++++++++
lib/IO/Path/XDG.pm6 | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 203 insertions(+)
create mode 100644 .editorconfig
create mode 100644 .gitignore
create mode 100644 .gitlab-ci.yml
create mode 100644 .travis.yml
create mode 100644 CHANGELOG.md
create mode 100644 META6.json
create mode 100644 README.pod6
create mode 100644 lib/IO/Path/XDG.pm6
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 "
+ ],
+ "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
+=VERSION 0.0.0
+
+=head1 Description
+
+Convenience functions for working with the XDG Base Directory Specification
+
+=head1 Installation
+
+Install this module through L:
+
+=begin code :lang
+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.IO if %*ENV: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.IO if %*ENV: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.IO if %*ENV: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.IO if %*ENV: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
+=VERSION 0.0.0
+
+=head1 Synopsis
+
+=head1 Description
+
+=head1 Examples
+
+=head1 See also
+
+=end pod
+
+# vim: ft=perl6 noet
--
cgit v1.1