xdg 4.0.1 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -1
- data/{LICENSE.md → LICENSE.adoc} +29 -30
- data/README.adoc +298 -0
- data/lib/xdg/identity.rb +4 -15
- data/lib/xdg/paths/directory.rb +2 -2
- metadata +26 -221
- metadata.gz.sig +0 -0
- data/README.md +0 -271
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 452257d923b23e0f08696df96d63819a9dfd0b520b0dd797fbad701b29899a0c
|
4
|
+
data.tar.gz: db53acdb13a606cec5438c8a91568ed09a1da9c956ac1fe0ede87fe8d604f121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 074e7b686c7ee5965351df7a337108c7e8f44479ecffec6f688fc9b23d7600fdc55118362504d1088e4b079c74b3110ec773edb0dc56ff495c3670dc2a84d8e7
|
7
|
+
data.tar.gz: d0608b4b984dd1afa045661d8a09e53b3c530ae13b497c811ca4708ce063d872446928bc5a1382d404796b900c0d7ab1baafcee70bd487272490529c186c36e0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
�K��Ʀ)�"Y|�I)��b+_��6�
|
data/{LICENSE.md → LICENSE.adoc}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
= Apache License
|
2
2
|
|
3
3
|
Version 2.0, January 2004
|
4
4
|
|
@@ -6,7 +6,7 @@ http://www.apache.org/licenses
|
|
6
6
|
|
7
7
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8
8
|
|
9
|
-
|
9
|
+
== 1. Definitions
|
10
10
|
|
11
11
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
|
12
12
|
Sections 1 through 9 of this document.
|
@@ -54,14 +54,14 @@ Contribution."
|
|
54
54
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
|
55
55
|
Contribution has been received by Licensor and subsequently incorporated within the Work.
|
56
56
|
|
57
|
-
|
57
|
+
== 2. Grant of Copyright License
|
58
58
|
|
59
59
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
60
60
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
61
61
|
reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
|
62
62
|
distribute the Work and such Derivative Works in Source or Object form.
|
63
63
|
|
64
|
-
|
64
|
+
== 3. Grant of Patent License
|
65
65
|
|
66
66
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
67
67
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
@@ -74,39 +74,38 @@ a Contribution incorporated within the Work constitutes direct or contributory p
|
|
74
74
|
then any patent licenses granted to You under this License for that Work shall terminate as of the
|
75
75
|
date such litigation is filed.
|
76
76
|
|
77
|
-
|
77
|
+
== 4. Redistribution
|
78
78
|
|
79
79
|
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
|
80
80
|
or without modifications, and in Source or Object form, provided that You meet the following
|
81
81
|
conditions:
|
82
82
|
|
83
|
-
|
83
|
+
. You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
84
84
|
|
85
|
-
|
86
|
-
|
85
|
+
. You must cause any modified files to carry prominent notices stating that You changed the files;
|
86
|
+
and
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
. You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
|
89
|
+
patent, trademark, and attribution notices from the Source form of the Work, excluding those
|
90
|
+
notices that do not pertain to any part of the Derivative Works; and
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
construed as modifying the License.
|
92
|
+
. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works
|
93
|
+
that You distribute must include a readable copy of the attribution notices contained within such
|
94
|
+
NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in
|
95
|
+
at least one of the following places: within a NOTICE text file distributed as part of the
|
96
|
+
Derivative Works; within the Source form or documentation, if provided along with the Derivative
|
97
|
+
Works; or, within a display generated by the Derivative Works, if and wherever such third-party
|
98
|
+
notices normally appear. The contents of the NOTICE file are for informational purposes only and
|
99
|
+
do not modify the License. You may add Your own attribution notices within Derivative Works that
|
100
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such
|
101
|
+
additional attribution notices cannot be construed as modifying the License.
|
103
102
|
|
104
103
|
You may add Your own copyright statement to Your modifications and may provide additional or
|
105
104
|
different license terms and conditions for use, reproduction, or distribution of Your modifications,
|
106
105
|
or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
|
107
106
|
the Work otherwise complies with the conditions stated in this License.
|
108
107
|
|
109
|
-
|
108
|
+
== 5. Submission of Contributions
|
110
109
|
|
111
110
|
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
|
112
111
|
Work by You to the Licensor shall be under the terms and conditions of this License, without any
|
@@ -114,13 +113,13 @@ additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
114
113
|
the terms of any separate license agreement you may have executed with Licensor regarding such
|
115
114
|
Contributions.
|
116
115
|
|
117
|
-
|
116
|
+
== 6. Trademarks
|
118
117
|
|
119
118
|
This License does not grant permission to use the trade names, trademarks, service marks, or product
|
120
119
|
names of the Licensor, except as required for reasonable and customary use in describing the origin
|
121
120
|
of the Work and reproducing the content of the NOTICE file.
|
122
121
|
|
123
|
-
|
122
|
+
== 7. Disclaimer of Warranty
|
124
123
|
|
125
124
|
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
|
126
125
|
Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
@@ -129,7 +128,7 @@ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Y
|
|
129
128
|
responsible for determining the appropriateness of using or redistributing the Work and assume any
|
130
129
|
risks associated with Your exercise of permissions under this License.
|
131
130
|
|
132
|
-
|
131
|
+
== 8. Limitation of Liability
|
133
132
|
|
134
133
|
In no event and under no legal theory, whether in tort (including negligence), contract, or
|
135
134
|
otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
|
@@ -139,7 +138,7 @@ License or out of the use or inability to use the Work (including but not limite
|
|
139
138
|
loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
|
140
139
|
damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
141
140
|
|
142
|
-
|
141
|
+
== 9. Accepting Warranty or Additional Liability
|
143
142
|
|
144
143
|
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
|
145
144
|
for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
|
@@ -151,11 +150,11 @@ additional liability.
|
|
151
150
|
|
152
151
|
END OF TERMS AND CONDITIONS
|
153
152
|
|
154
|
-
Copyright 2019
|
153
|
+
Copyright 2019 link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
155
154
|
|
156
155
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
157
|
-
compliance with the License. You may obtain a
|
158
|
-
the License.
|
156
|
+
compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
|
157
|
+
of the License.
|
159
158
|
|
160
159
|
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
161
160
|
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
data/README.adoc
ADDED
@@ -0,0 +1,298 @@
|
|
1
|
+
:toc: macro
|
2
|
+
:toclevels: 5
|
3
|
+
:figure-caption!:
|
4
|
+
|
5
|
+
= XDG
|
6
|
+
|
7
|
+
[link=http://badge.fury.io/rb/xdg]
|
8
|
+
image::https://badge.fury.io/rb/xdg.svg[Gem Version]
|
9
|
+
[link=https://www.alchemists.io/projects/code_quality]
|
10
|
+
image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
|
11
|
+
[link=https://circleci.com/gh/bkuhlmann/xdg]
|
12
|
+
image::https://circleci.com/gh/bkuhlmann/xdg.svg?style=svg[Circle CI Status]
|
13
|
+
|
14
|
+
Provides a Ruby implementation of the
|
15
|
+
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html[XDG Base Directory
|
16
|
+
Specification].
|
17
|
+
|
18
|
+
💡 If you write a lot of Command Line Interfaces and would like additional syntactic sugar that
|
19
|
+
includes what is found in this gem, make sure to check out the
|
20
|
+
link:https://www.alchemists.io/projects/runcom[Runcom] gem too.
|
21
|
+
|
22
|
+
toc::[]
|
23
|
+
|
24
|
+
== Features
|
25
|
+
|
26
|
+
* Provides a `XDG::Environment` object that adheres to the _XDG Base Directory Specification_ with
|
27
|
+
access to the following environment settings:
|
28
|
+
** `$XDG_CACHE_HOME`
|
29
|
+
** `$XDG_CONFIG_HOME`
|
30
|
+
** `$XDG_CONFIG_DIRS`
|
31
|
+
** `$XDG_DATA_HOME`
|
32
|
+
** `$XDG_DATA_DIRS`
|
33
|
+
|
34
|
+
== Requirements
|
35
|
+
|
36
|
+
. https://www.ruby-lang.org[Ruby]
|
37
|
+
|
38
|
+
== Setup
|
39
|
+
|
40
|
+
To install, run:
|
41
|
+
|
42
|
+
[source,bash]
|
43
|
+
----
|
44
|
+
gem install xdg
|
45
|
+
----
|
46
|
+
|
47
|
+
Add the following to your Gemfile:
|
48
|
+
|
49
|
+
[source,ruby]
|
50
|
+
----
|
51
|
+
gem "xdg"
|
52
|
+
----
|
53
|
+
|
54
|
+
== Usage
|
55
|
+
|
56
|
+
The following describes how to use this XDG implementation.
|
57
|
+
|
58
|
+
=== Overview
|
59
|
+
|
60
|
+
To get up and running quickly, use `+XDG::Environment+` as follows:
|
61
|
+
|
62
|
+
[source,ruby]
|
63
|
+
----
|
64
|
+
xdg = XDG::Environment.new
|
65
|
+
xdg.cache_home # <= Answers computed `$XDG_CACHE_HOME` value.
|
66
|
+
xdg.config_home # <= Answers computed `$XDG_CONFIG_HOME` value.
|
67
|
+
xdg.config_dirs # <= Answers computed `$XDG_CONFIG_DIRS` value.
|
68
|
+
xdg.data_home # <= Answers computed `$XDG_DATA_HOME` value.
|
69
|
+
xdg.data_dirs # <= Answers computed `$XDG_DATA_DIRS` value.
|
70
|
+
----
|
71
|
+
|
72
|
+
The _computed_ value, in this case, is either the user-defined value of the key or the default
|
73
|
+
value, per specification, when the key is not defined or empty. For more on this, scroll down to the
|
74
|
+
_Variable Defaults_ section to learn more.
|
75
|
+
|
76
|
+
The `XDG::Environment` wraps the following objects which can be used individually if you don’t
|
77
|
+
want to load the entire environment:
|
78
|
+
|
79
|
+
[source,ruby]
|
80
|
+
----
|
81
|
+
cache = XDG::Cache.new
|
82
|
+
config = XDG::Config.new
|
83
|
+
data = XDG::Data.new
|
84
|
+
----
|
85
|
+
|
86
|
+
The `cache`, `config`, and `data` objects share the same API which means you can ask each the
|
87
|
+
following messages:
|
88
|
+
|
89
|
+
* `#home` - Answers the home directory as computed via the `$XDG_*_HOME` key.
|
90
|
+
* `#directories` - Answers an array directories as computed via the `$XDG_*_DIRS` key.
|
91
|
+
* `#all` - Answers an array of _all_ directories as computed from the combined `$XDG_*_HOME` and
|
92
|
+
`$XDG_*_DIRS` values (with `$XDG_*_HOME` prefixed at the start of the array).
|
93
|
+
|
94
|
+
=== Examples
|
95
|
+
|
96
|
+
The following are examples of what you would see when playing around with the XDG objects within an
|
97
|
+
IRB console (taken from my own environment):
|
98
|
+
|
99
|
+
[source,ruby]
|
100
|
+
----
|
101
|
+
require "xdg"
|
102
|
+
|
103
|
+
# Initialization
|
104
|
+
environment = XDG::Environment.new
|
105
|
+
cache = XDG::Cache.new
|
106
|
+
config = XDG::Config.new
|
107
|
+
data = XDG::Data.new
|
108
|
+
|
109
|
+
# Inspection
|
110
|
+
environment.inspect # => XDG_CACHE_HOME=/Users/bkuhlmann/.cache XDG_CONFIG_HOME=/Users/bkuhlmann/.config XDG_CONFIG_DIRS=/etc/xdg XDG_DATA_HOME=/Users/bkuhlmann/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share
|
111
|
+
cache.inspect # => "XDG_CACHE_HOME=/Users/bkuhlmann/.cache"
|
112
|
+
config.inspect # => "XDG_CONFIG_HOME=/Users/bkuhlmann/.config XDG_CONFIG_DIRS=/etc/xdg"
|
113
|
+
data.inspect # => "XDG_DATA_HOME=/Users/bkuhlmann/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
|
114
|
+
|
115
|
+
# Paths
|
116
|
+
environment.cache_home # => #<Pathname:/Users/bkuhlmann/.cache>
|
117
|
+
environment.config_home # => #<Pathname:/Users/bkuhlmann/.config>
|
118
|
+
environment.config_dirs # => [#<Pathname:/etc/xdg>]
|
119
|
+
environment.data_home # => #<Pathname:/Users/bkuhlmann/.local/share>
|
120
|
+
environment.data_dirs # => [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
121
|
+
|
122
|
+
cache.home # => #<Pathname:/Users/bkuhlmann/.cache>
|
123
|
+
cache.directories # => []
|
124
|
+
cache.all # => [#<Pathname:/Users/bkuhlmann/.cache>]
|
125
|
+
|
126
|
+
config.home # => #<Pathname:/Users/bkuhlmann/.config>
|
127
|
+
config.directories # => [#<Pathname:/etc/xdg>]
|
128
|
+
config.all # => [#<Pathname:/Users/bkuhlmann/.config>, #<Pathname:/etc/xdg>]
|
129
|
+
|
130
|
+
data.home # => #<Pathname:/Users/bkuhlmann/.local/share>
|
131
|
+
data.directories # => [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
132
|
+
data.all # => [#<Pathname:/Users/bkuhlmann/.local/share>, #<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
133
|
+
----
|
134
|
+
|
135
|
+
As you can see from above, each XDG object answers back a `Pathname` which means you have the full
|
136
|
+
`Pathname` API at your fingertips to build upon the output of these objects as needed.
|
137
|
+
|
138
|
+
=== Variable Defaults
|
139
|
+
|
140
|
+
The _XDG Base Directory Specification_ defines environment variables and associated default values
|
141
|
+
when not defined or empty. The following defaults, per specification, are implemented by the `XDG`
|
142
|
+
objects:
|
143
|
+
|
144
|
+
* `$XDG_CACHE_HOME="$HOME/.cache"`
|
145
|
+
* `$XDG_CONFIG_HOME="$HOME/.config"`
|
146
|
+
* `$XDG_CONFIG_DIRS="/etc/xdg"`
|
147
|
+
* `$XDG_DATA_HOME="$HOME/.local/share"`
|
148
|
+
* `$XDG_DATA_DIRS="/usr/local/share/:/usr/share/"`
|
149
|
+
* `$XDG_RUNTIME_DIR`
|
150
|
+
|
151
|
+
The `$XDG_RUNTIME_DIR` deserves special mention as it’s not, _currently_, implemented as part of
|
152
|
+
this gem because it is more user/environment specific. Here is how the `$XDG_RUNTIME_DIR` is meant
|
153
|
+
to be used should you choose to use it:
|
154
|
+
|
155
|
+
* _Must_ reference user-specific non-essential runtime files and other file objects (such as
|
156
|
+
sockets, named pipes, etc.)
|
157
|
+
* _Must_ be owned by the user with _only_ the user having read and write access to it.
|
158
|
+
* _Must_ have a Unix access mode of `0700`.
|
159
|
+
* _Must_ be bound to the user when logging in.
|
160
|
+
* _Must_ be removed when the user logs out.
|
161
|
+
* _Must_ be pointed to the same directory when the user logs in more than once.
|
162
|
+
* _Must_ exist from first login to last logout on the system and not removed in between.
|
163
|
+
* _Must_ not allow files in the directory to survive reboot or a full logout/login cycle.
|
164
|
+
* _Must_ keep the directory on the local file system and not shared with any other file systems.
|
165
|
+
* _Must_ keep the directory fully-featured by the standards of the operating system. Specifically,
|
166
|
+
on Unix-like operating systems AF_UNIX sockets, symbolic links, hard links, proper permissions, file
|
167
|
+
locking, sparse files, memory mapping, file change notifications, a reliable hard link count must be
|
168
|
+
supported, and no restrictions on the file name character set should be imposed. Files in this
|
169
|
+
directory _may_ be subjected to periodic clean-up. To ensure files are not removed, they should have
|
170
|
+
their access time timestamp modified at least once every 6 hours of monotonic time or the '`sticky`'
|
171
|
+
bit should be set on the file.
|
172
|
+
* When not set, applications should fall back to a replacement directory with similar capabilities
|
173
|
+
and print a warning message. Applications should use this directory for communication and
|
174
|
+
synchronization purposes and should not place larger files in it, since it might reside in runtime
|
175
|
+
memory and cannot necessarily be swapped out to disk.
|
176
|
+
|
177
|
+
=== Variable Behavior
|
178
|
+
|
179
|
+
The behavior of most XDG environment variables can be lumped into two categories:
|
180
|
+
|
181
|
+
* `$XDG_*_HOME`
|
182
|
+
* `$XDG_*_DIRS`
|
183
|
+
|
184
|
+
Each is described in detail below.
|
185
|
+
|
186
|
+
==== `$XDG_*_DIRS`
|
187
|
+
|
188
|
+
These variables are used to define a colon (`:`) delimited list of directories. Order is important
|
189
|
+
as the first directory defined will take precedent over the following directory and so forth. For
|
190
|
+
example, here is a situation where the `XDG_CONFIG_DIRS` key has a custom value:
|
191
|
+
|
192
|
+
[source,bash]
|
193
|
+
----
|
194
|
+
XDG_CONFIG_DIRS="/example/one/.config:/example/two/.settings:/example/three/.configuration"
|
195
|
+
----
|
196
|
+
|
197
|
+
Yields the following, colon delimited, array:
|
198
|
+
|
199
|
+
[source,ruby]
|
200
|
+
----
|
201
|
+
[
|
202
|
+
"/example/one/.config",
|
203
|
+
"/example/two/.settings",
|
204
|
+
"/example/three/.configuration"
|
205
|
+
]
|
206
|
+
----
|
207
|
+
|
208
|
+
In the above example, the `"/example/one/.config"` path takes _highest_ priority since it was
|
209
|
+
defined first.
|
210
|
+
|
211
|
+
==== `$XDG_*_HOME`
|
212
|
+
|
213
|
+
These variables take precidence over the corresponding `$XDG_*_DIRS` environment variables. Using
|
214
|
+
a modified version of the `$XDG_*_DIRS` example, shown above, we could have the following setup:
|
215
|
+
|
216
|
+
[source,bash]
|
217
|
+
----
|
218
|
+
XDG_CONFIG_HOME="/example/priority"
|
219
|
+
XDG_CONFIG_DIRS="/example/one/.config:/example/two/.settings"
|
220
|
+
----
|
221
|
+
|
222
|
+
Yields the following, colon delimited, array:
|
223
|
+
|
224
|
+
[source,ruby]
|
225
|
+
----
|
226
|
+
[
|
227
|
+
"/example/priority",
|
228
|
+
"/example/one/.config",
|
229
|
+
"/example/two/.settings"
|
230
|
+
]
|
231
|
+
----
|
232
|
+
|
233
|
+
Due to `XDG_CONFIG_HOME` taking precidence over the `XDG_CONFIG_DIRS`, the path with the
|
234
|
+
_highest_ priority in this example is: `"/example/priority"`.
|
235
|
+
|
236
|
+
=== Variable Priority
|
237
|
+
|
238
|
+
Path precedence is determined in the following order (with the first taking highest priority):
|
239
|
+
|
240
|
+
. `$XDG_*_HOME` - Will be used if defined. Otherwise, falls back to specification default.
|
241
|
+
. `$XDG_*_DIRS` - Iterates through directories in order defined (with first taking highest
|
242
|
+
priority). Otherwise, falls back to specification default.
|
243
|
+
|
244
|
+
== Development
|
245
|
+
|
246
|
+
To contribute, run:
|
247
|
+
|
248
|
+
[source,bash]
|
249
|
+
----
|
250
|
+
git clone https://github.com/bkuhlmann/xdg.git
|
251
|
+
cd xdg
|
252
|
+
bin/setup
|
253
|
+
----
|
254
|
+
|
255
|
+
You can also use the IRB console for direct access to all objects:
|
256
|
+
|
257
|
+
[source,bash]
|
258
|
+
----
|
259
|
+
bin/console
|
260
|
+
----
|
261
|
+
|
262
|
+
== Tests
|
263
|
+
|
264
|
+
To test, run:
|
265
|
+
|
266
|
+
[source,bash]
|
267
|
+
----
|
268
|
+
bundle exec rake
|
269
|
+
----
|
270
|
+
|
271
|
+
== Versioning
|
272
|
+
|
273
|
+
Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
|
274
|
+
|
275
|
+
* Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
276
|
+
* Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
277
|
+
* Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
278
|
+
|
279
|
+
== Code of Conduct
|
280
|
+
|
281
|
+
Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
|
282
|
+
participating in this project you agree to abide by its terms.
|
283
|
+
|
284
|
+
== Contributions
|
285
|
+
|
286
|
+
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
287
|
+
|
288
|
+
== License
|
289
|
+
|
290
|
+
Read link:LICENSE.adoc[LICENSE] for details.
|
291
|
+
|
292
|
+
== History
|
293
|
+
|
294
|
+
Read link:CHANGES.adoc[CHANGES] for details.
|
295
|
+
|
296
|
+
== Credits
|
297
|
+
|
298
|
+
Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
data/lib/xdg/identity.rb
CHANGED
@@ -3,20 +3,9 @@
|
|
3
3
|
module XDG
|
4
4
|
# Gem identity information.
|
5
5
|
module Identity
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.label
|
11
|
-
"XDG"
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.version
|
15
|
-
"4.0.1"
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.version_label
|
19
|
-
"#{label} #{version}"
|
20
|
-
end
|
6
|
+
NAME = "xdg"
|
7
|
+
LABEL = "XDG"
|
8
|
+
VERSION = "4.5.0"
|
9
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
21
10
|
end
|
22
11
|
end
|
data/lib/xdg/paths/directory.rb
CHANGED
@@ -14,14 +14,14 @@ module XDG
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def default
|
17
|
-
value.split(DELIMITER).map
|
17
|
+
value.split(DELIMITER).map { |path| expand path }
|
18
18
|
end
|
19
19
|
|
20
20
|
def dynamic
|
21
21
|
String(environment[key]).then { |env_value| env_value.empty? ? value : env_value }
|
22
22
|
.split(DELIMITER)
|
23
23
|
.uniq
|
24
|
-
.map
|
24
|
+
.map { |path| expand path }
|
25
25
|
end
|
26
26
|
|
27
27
|
def inspect
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xdg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIC/
|
14
|
-
|
15
|
-
|
13
|
+
MIIC/jCCAeagAwIBAgIBAzANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
|
14
|
+
a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMDAzMTUxNDQ1MzJaFw0yMTAzMTUx
|
15
|
+
NDQ1MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
|
16
16
|
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
|
17
17
|
xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
|
18
18
|
brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
|
@@ -20,223 +20,27 @@ cert_chain:
|
|
20
20
|
D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
|
21
21
|
3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
|
22
22
|
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
|
23
|
-
2CdikiiE3fJhP/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAIHhAlD3po4sTYqacXaQ
|
24
|
+
XI9jIhrfMy//2PgbHWcETtlJPBeNUbbSNBABcllUHKqYsVDlSvSmss034KSWNR8F
|
25
|
+
bF1GcloicyvcCC4y6IoW4it0COAcdeaaxkxiBSgKdQFpff9REnDlIKK4uQ9lLxIo
|
26
|
+
Y2G5xubiziKZkyfWFuSr67PIjW3Bu673D1JVBArhA1qbgQmYQcy1CkGOjo+iO8Nf
|
27
|
+
7u/QSfBHb+r/bXhKscDgPpnKwbUmvgO2+94zJG9KsrmIydlzYfsD09aXKx0t6Xy4
|
28
|
+
2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
|
29
|
+
QWc=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2020-
|
32
|
-
dependencies:
|
33
|
-
|
34
|
-
name: bundler-audit
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0.6'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0.6'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: gemsmith
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '14.0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '14.0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: git-cop
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '4.0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '4.0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: guard-rspec
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '4.7'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '4.7'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: pry
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0.12'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0.12'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: pry-byebug
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '3.7'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '3.7'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: rake
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '13.0'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '13.0'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: reek
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '5.6'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - "~>"
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '5.6'
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: rspec
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '3.9'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "~>"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '3.9'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: rubocop
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
162
|
-
requirements:
|
163
|
-
- - "~>"
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0.79'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - "~>"
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: '0.79'
|
173
|
-
- !ruby/object:Gem::Dependency
|
174
|
-
name: rubocop-performance
|
175
|
-
requirement: !ruby/object:Gem::Requirement
|
176
|
-
requirements:
|
177
|
-
- - "~>"
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '1.5'
|
180
|
-
type: :development
|
181
|
-
prerelease: false
|
182
|
-
version_requirements: !ruby/object:Gem::Requirement
|
183
|
-
requirements:
|
184
|
-
- - "~>"
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: '1.5'
|
187
|
-
- !ruby/object:Gem::Dependency
|
188
|
-
name: rubocop-rake
|
189
|
-
requirement: !ruby/object:Gem::Requirement
|
190
|
-
requirements:
|
191
|
-
- - "~>"
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: '0.5'
|
194
|
-
type: :development
|
195
|
-
prerelease: false
|
196
|
-
version_requirements: !ruby/object:Gem::Requirement
|
197
|
-
requirements:
|
198
|
-
- - "~>"
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
version: '0.5'
|
201
|
-
- !ruby/object:Gem::Dependency
|
202
|
-
name: rubocop-rspec
|
203
|
-
requirement: !ruby/object:Gem::Requirement
|
204
|
-
requirements:
|
205
|
-
- - "~>"
|
206
|
-
- !ruby/object:Gem::Version
|
207
|
-
version: '1.37'
|
208
|
-
type: :development
|
209
|
-
prerelease: false
|
210
|
-
version_requirements: !ruby/object:Gem::Requirement
|
211
|
-
requirements:
|
212
|
-
- - "~>"
|
213
|
-
- !ruby/object:Gem::Version
|
214
|
-
version: '1.37'
|
215
|
-
- !ruby/object:Gem::Dependency
|
216
|
-
name: simplecov
|
217
|
-
requirement: !ruby/object:Gem::Requirement
|
218
|
-
requirements:
|
219
|
-
- - "~>"
|
220
|
-
- !ruby/object:Gem::Version
|
221
|
-
version: '0.18'
|
222
|
-
type: :development
|
223
|
-
prerelease: false
|
224
|
-
version_requirements: !ruby/object:Gem::Requirement
|
225
|
-
requirements:
|
226
|
-
- - "~>"
|
227
|
-
- !ruby/object:Gem::Version
|
228
|
-
version: '0.18'
|
229
|
-
description:
|
31
|
+
date: 2020-12-13 00:00:00.000000000 Z
|
32
|
+
dependencies: []
|
33
|
+
description:
|
230
34
|
email:
|
231
35
|
- brooke@alchemists.io
|
232
36
|
executables: []
|
233
37
|
extensions: []
|
234
38
|
extra_rdoc_files:
|
235
|
-
- README.
|
236
|
-
- LICENSE.
|
39
|
+
- README.adoc
|
40
|
+
- LICENSE.adoc
|
237
41
|
files:
|
238
|
-
- LICENSE.
|
239
|
-
- README.
|
42
|
+
- LICENSE.adoc
|
43
|
+
- README.adoc
|
240
44
|
- lib/xdg.rb
|
241
45
|
- lib/xdg/cache.rb
|
242
46
|
- lib/xdg/config.rb
|
@@ -247,14 +51,15 @@ files:
|
|
247
51
|
- lib/xdg/paths/combined.rb
|
248
52
|
- lib/xdg/paths/directory.rb
|
249
53
|
- lib/xdg/paths/home.rb
|
250
|
-
homepage: https://
|
54
|
+
homepage: https://www.alchemists.io/projects/xdg
|
251
55
|
licenses:
|
252
56
|
- Apache-2.0
|
253
57
|
metadata:
|
254
|
-
source_code_uri: https://github.com/bkuhlmann/xdg
|
255
|
-
changelog_uri: https://github.com/bkuhlmann/xdg/blob/master/CHANGES.md
|
256
58
|
bug_tracker_uri: https://github.com/bkuhlmann/xdg/issues
|
257
|
-
|
59
|
+
changelog_uri: https://www.alchemists.io/projects/xdg/changes.html
|
60
|
+
documentation_uri: https://www.alchemists.io/projects/xdg
|
61
|
+
source_code_uri: https://github.com/bkuhlmann/xdg
|
62
|
+
post_install_message:
|
258
63
|
rdoc_options: []
|
259
64
|
require_paths:
|
260
65
|
- lib
|
@@ -269,8 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
74
|
- !ruby/object:Gem::Version
|
270
75
|
version: '0'
|
271
76
|
requirements: []
|
272
|
-
rubygems_version: 3.
|
273
|
-
signing_key:
|
77
|
+
rubygems_version: 3.2.0
|
78
|
+
signing_key:
|
274
79
|
specification_version: 4
|
275
80
|
summary: Provides an implementation of the XDG Base Directory Specification.
|
276
81
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/README.md
DELETED
@@ -1,271 +0,0 @@
|
|
1
|
-
<p align="center">
|
2
|
-
<img src="xdg.png" alt="XDG Icon"/>
|
3
|
-
</p>
|
4
|
-
|
5
|
-
# XDG
|
6
|
-
|
7
|
-
[![Gem Version](https://badge.fury.io/rb/xdg.svg)](http://badge.fury.io/rb/xdg)
|
8
|
-
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/73c8f06ae65cbe663e1c/maintainability)](https://codeclimate.com/github/bkuhlmann/xdg/maintainability)
|
9
|
-
[![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/73c8f06ae65cbe663e1c/test_coverage)](https://codeclimate.com/github/bkuhlmann/xdg/test_coverage)
|
10
|
-
[![Circle CI Status](https://circleci.com/gh/bkuhlmann/xdg.svg?style=svg)](https://circleci.com/gh/bkuhlmann/xdg)
|
11
|
-
|
12
|
-
Provides a Ruby implementation of the [XDG Base Directory
|
13
|
-
Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html).
|
14
|
-
|
15
|
-
:bulb: If you write a lot of Command Line Interfaces and would like additional syntactic
|
16
|
-
sugar that includes what is found in this gem, make sure to check out the
|
17
|
-
[Runcom](https://github.com/bkuhlmann/runcom) gem too.
|
18
|
-
|
19
|
-
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
20
|
-
|
21
|
-
## Table of Contents
|
22
|
-
|
23
|
-
- [Features](#features)
|
24
|
-
- [Requirements](#requirements)
|
25
|
-
- [Setup](#setup)
|
26
|
-
- [Usage](#usage)
|
27
|
-
- [Overview](#overview)
|
28
|
-
- [Examples](#examples)
|
29
|
-
- [Variable Defaults](#variable-defaults)
|
30
|
-
- [Variable Behavior](#variable-behavior)
|
31
|
-
- [`$XDG_*_DIRS`](#xdg__dirs)
|
32
|
-
- [`$XDG_*_HOME`](#xdg__home)
|
33
|
-
- [Variable Priority](#variable-priority)
|
34
|
-
- [Tests](#tests)
|
35
|
-
- [Versioning](#versioning)
|
36
|
-
- [Code of Conduct](#code-of-conduct)
|
37
|
-
- [Contributions](#contributions)
|
38
|
-
- [License](#license)
|
39
|
-
- [History](#history)
|
40
|
-
- [Credits](#credits)
|
41
|
-
|
42
|
-
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
43
|
-
|
44
|
-
## Features
|
45
|
-
|
46
|
-
- Provides a `XDG::Environment` object that adheres to the *XDG Base Directory Specification* with
|
47
|
-
access to the following environment settings:
|
48
|
-
- `$XDG_CACHE_HOME`
|
49
|
-
- `$XDG_CONFIG_HOME`
|
50
|
-
- `$XDG_CONFIG_DIRS`
|
51
|
-
- `$XDG_DATA_HOME`
|
52
|
-
- `$XDG_DATA_DIRS`
|
53
|
-
|
54
|
-
## Requirements
|
55
|
-
|
56
|
-
1. [Ruby 2.7.x](https://www.ruby-lang.org)
|
57
|
-
|
58
|
-
## Setup
|
59
|
-
|
60
|
-
To install, run:
|
61
|
-
|
62
|
-
gem install xdg
|
63
|
-
|
64
|
-
Add the following to your Gemfile:
|
65
|
-
|
66
|
-
gem "xdg"
|
67
|
-
|
68
|
-
## Usage
|
69
|
-
|
70
|
-
The following describes how to use this XDG implementation.
|
71
|
-
|
72
|
-
#### Overview
|
73
|
-
|
74
|
-
To get up and running quickly, use `XDG::Environment` as follows:
|
75
|
-
|
76
|
-
xdg = XDG::Environment.new
|
77
|
-
xdg.cache_home # <= Answers computed `$XDG_CACHE_HOME` value.
|
78
|
-
xdg.config_home # <= Answers computed `$XDG_CONFIG_HOME` value.
|
79
|
-
xdg.config_dirs # <= Answers computed `$XDG_CONFIG_DIRS` value.
|
80
|
-
xdg.data_home # <= Answers computed `$XDG_DATA_HOME` value.
|
81
|
-
xdg.data_dirs # <= Answers computed `$XDG_DATA_DIRS` value.
|
82
|
-
|
83
|
-
The *computed* value, in this case, is either the user-defined value of the key or the default
|
84
|
-
value, per specification, when the key is not defined or empty. For more on this, scroll down to the
|
85
|
-
*Variable Defaults* section to learn more.
|
86
|
-
|
87
|
-
The `XDG::Environment` wraps the following objects which can be used individually if you
|
88
|
-
don't want to load the entire environment:
|
89
|
-
|
90
|
-
cache = XDG::Cache.new
|
91
|
-
config = XDG::Config.new
|
92
|
-
data = XDG::Data.new
|
93
|
-
|
94
|
-
The `cache`, `config`, and `data` objects share the same API which means you can ask each the
|
95
|
-
following messages:
|
96
|
-
|
97
|
-
- `#home` - Answers the home directory as computed via the `$XDG_*_HOME` key.
|
98
|
-
- `#directories` - Answers an array directories as computed via the `$XDG_*_DIRS` key.
|
99
|
-
- `#all` - Answers an array of *all* directories as computed from the combined `$XDG_*_HOME` and
|
100
|
-
`$XDG_*_DIRS` values (with `$XDG_*_HOME` prefixed at the start of the array).
|
101
|
-
|
102
|
-
#### Examples
|
103
|
-
|
104
|
-
The following are examples of what you would see when playing around with the XDG objects within an
|
105
|
-
IRB console (taken from my own environment):
|
106
|
-
|
107
|
-
require "xdg"
|
108
|
-
|
109
|
-
# Initialization
|
110
|
-
environment = XDG::Environment.new
|
111
|
-
cache = XDG::Cache.new
|
112
|
-
config = XDG::Config.new
|
113
|
-
data = XDG::Data.new
|
114
|
-
|
115
|
-
# Inspection
|
116
|
-
environment.inspect # => XDG_CACHE_HOME=/Users/bkuhlmann/.cache XDG_CONFIG_HOME=/Users/bkuhlmann/.config XDG_CONFIG_DIRS=/etc/xdg XDG_DATA_HOME=/Users/bkuhlmann/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share
|
117
|
-
cache.inspect # => "XDG_CACHE_HOME=/Users/bkuhlmann/.cache"
|
118
|
-
config.inspect # => "XDG_CONFIG_HOME=/Users/bkuhlmann/.config XDG_CONFIG_DIRS=/etc/xdg"
|
119
|
-
data.inspect # => "XDG_DATA_HOME=/Users/bkuhlmann/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
|
120
|
-
|
121
|
-
# Paths
|
122
|
-
environment.cache_home # => #<Pathname:/Users/bkuhlmann/.cache>
|
123
|
-
environment.config_home # => #<Pathname:/Users/bkuhlmann/.config>
|
124
|
-
environment.config_dirs # => [#<Pathname:/etc/xdg>]
|
125
|
-
environment.data_home # => #<Pathname:/Users/bkuhlmann/.local/share>
|
126
|
-
environment.data_dirs # => [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
127
|
-
|
128
|
-
cache.home # => #<Pathname:/Users/bkuhlmann/.cache>
|
129
|
-
cache.directories # => []
|
130
|
-
cache.all # => [#<Pathname:/Users/bkuhlmann/.cache>]
|
131
|
-
|
132
|
-
config.home # => #<Pathname:/Users/bkuhlmann/.config>
|
133
|
-
config.directories # => [#<Pathname:/etc/xdg>]
|
134
|
-
config.all # => [#<Pathname:/Users/bkuhlmann/.config>, #<Pathname:/etc/xdg>]
|
135
|
-
|
136
|
-
data.home # => #<Pathname:/Users/bkuhlmann/.local/share>
|
137
|
-
data.directories # => [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
138
|
-
data.all # => [#<Pathname:/Users/bkuhlmann/.local/share>, #<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
139
|
-
|
140
|
-
As you can see from above, each XDG object answers back a `Pathname` which means you have the
|
141
|
-
full `Pathname` API at your fingertips to build upon the output of these objects as needed.
|
142
|
-
|
143
|
-
#### Variable Defaults
|
144
|
-
|
145
|
-
The *XDG Base Directory Specification* defines environment variables and associated default values
|
146
|
-
when not defined or empty. The following defaults, per specification, are implemented by the
|
147
|
-
`XDG` objects:
|
148
|
-
|
149
|
-
- `$XDG_CACHE_HOME="$HOME/.cache"`
|
150
|
-
- `$XDG_CONFIG_HOME="$HOME/.config"`
|
151
|
-
- `$XDG_CONFIG_DIRS="/etc/xdg"`
|
152
|
-
- `$XDG_DATA_HOME="$HOME/.local/share"`
|
153
|
-
- `$XDG_DATA_DIRS="/usr/local/share/:/usr/share/"`
|
154
|
-
- `$XDG_RUNTIME_DIR`
|
155
|
-
|
156
|
-
The `$XDG_RUNTIME_DIR` deserves special mention as it's not, *currently*, implemented as part of
|
157
|
-
this gem because it is more user/environment specific. Here is how the `$XDG_RUNTIME_DIR` is meant
|
158
|
-
to be used should you choose to use it:
|
159
|
-
|
160
|
-
- *Must* reference user-specific non-essential runtime files and other file objects (such as
|
161
|
-
sockets, named pipes, etc.)
|
162
|
-
- *Must* be owned by the user with *only* the user having read and write access to it.
|
163
|
-
- *Must* have a Unix access mode of `0700`.
|
164
|
-
- *Must* be bound to the user when logging in.
|
165
|
-
- *Must* be removed when the user logs out.
|
166
|
-
- *Must* be pointed to the same directory when the user logs in more than once.
|
167
|
-
- *Must* exist from first login to last logout on the system and not removed in between.
|
168
|
-
- *Must* not allow files in the directory to survive reboot or a full logout/login cycle.
|
169
|
-
- *Must* keep the directory on the local file system and not shared with any other file systems.
|
170
|
-
- *Must* keep the directory fully-featured by the standards of the operating system. Specifically,
|
171
|
-
on Unix-like operating systems AF_UNIX sockets, symbolic links, hard links, proper permissions,
|
172
|
-
file locking, sparse files, memory mapping, file change notifications, a reliable hard link count
|
173
|
-
must be supported, and no restrictions on the file name character set should be imposed. Files in
|
174
|
-
this directory *may* be subjected to periodic clean-up. To ensure files are not removed,
|
175
|
-
they should have their access time timestamp modified at least once every 6 hours of monotonic
|
176
|
-
time or the 'sticky' bit should be set on the file.
|
177
|
-
- When not set, applications should fall back to a replacement directory with similar capabilities
|
178
|
-
and print a warning message. Applications should use this directory for communication and
|
179
|
-
synchronization purposes and should not place larger files in it, since it might reside in runtime
|
180
|
-
memory and cannot necessarily be swapped out to disk.
|
181
|
-
|
182
|
-
#### Variable Behavior
|
183
|
-
|
184
|
-
The behavior of most XDG environment variables can be lumped into two categories:
|
185
|
-
|
186
|
-
- `$XDG_*_HOME`
|
187
|
-
- `$XDG_*_DIRS`
|
188
|
-
|
189
|
-
Each is described in detail below.
|
190
|
-
|
191
|
-
##### `$XDG_*_DIRS`
|
192
|
-
|
193
|
-
These variables are used to define a colon (`:`) delimited list of directories. Order is important
|
194
|
-
as the first directory defined will take precedent over the following directory and so forth. For
|
195
|
-
example, here is a situation where the `XDG_CONFIG_DIRS` key has a custom value:
|
196
|
-
|
197
|
-
XDG_CONFIG_DIRS="/example/one/.config:/example/two/.settings:/example/three/.configuration"
|
198
|
-
|
199
|
-
# Yields the following, colon delimited, array:
|
200
|
-
[
|
201
|
-
"/example/one/.config",
|
202
|
-
"/example/two/.settings",
|
203
|
-
"/example/three/.configuration"
|
204
|
-
]
|
205
|
-
|
206
|
-
In the above example, the `"/example/one/.config"` path takes *highest* priority since it was
|
207
|
-
defined first.
|
208
|
-
|
209
|
-
##### `$XDG_*_HOME`
|
210
|
-
|
211
|
-
These variables take precidence over the corresponding `$XDG_*_DIRS` environment variables. Using a
|
212
|
-
modified version of the `$XDG_*_DIRS` example, shown above, we could have the following setup:
|
213
|
-
|
214
|
-
XDG_CONFIG_HOME="/example/priority"
|
215
|
-
XDG_CONFIG_DIRS="/example/one/.config:/example/two/.settings"
|
216
|
-
|
217
|
-
# Yields the following, colon delimited, array:
|
218
|
-
[
|
219
|
-
"/example/priority",
|
220
|
-
"/example/one/.config",
|
221
|
-
"/example/two/.settings"
|
222
|
-
]
|
223
|
-
|
224
|
-
Due to `XDG_CONFIG_HOME` taking precidence over the `XDG_CONFIG_DIRS`, the path with the *highest*
|
225
|
-
priority in this example is: `"/example/priority"`.
|
226
|
-
|
227
|
-
#### Variable Priority
|
228
|
-
|
229
|
-
Path precedence is determined in the following order (with the first taking highest priority):
|
230
|
-
|
231
|
-
1. `$XDG_*_HOME` - Will be used if defined. Otherwise, falls back to specification default.
|
232
|
-
1. `$XDG_*_DIRS` - Iterates through directories in order defined (with first taking highest
|
233
|
-
priority). Otherwise, falls back to specification default.
|
234
|
-
|
235
|
-
## Tests
|
236
|
-
|
237
|
-
To test, run:
|
238
|
-
|
239
|
-
bundle exec rake
|
240
|
-
|
241
|
-
## Versioning
|
242
|
-
|
243
|
-
Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
|
244
|
-
|
245
|
-
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
246
|
-
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
247
|
-
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
248
|
-
|
249
|
-
## Code of Conduct
|
250
|
-
|
251
|
-
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
|
252
|
-
participating in this project you agree to abide by its terms.
|
253
|
-
|
254
|
-
## Contributions
|
255
|
-
|
256
|
-
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
257
|
-
|
258
|
-
## License
|
259
|
-
|
260
|
-
Copyright 2019 [Alchemists](https://www.alchemists.io).
|
261
|
-
Read [LICENSE](LICENSE.md) for details.
|
262
|
-
|
263
|
-
## History
|
264
|
-
|
265
|
-
Read [CHANGES](CHANGES.md) for details.
|
266
|
-
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
267
|
-
|
268
|
-
## Credits
|
269
|
-
|
270
|
-
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
|
271
|
-
[Alchemists](https://www.alchemists.io).
|