xdg 3.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/{LICENSE.md → LICENSE.adoc} +29 -30
- data/README.adoc +298 -0
- data/lib/xdg.rb +1 -1
- data/lib/xdg/cache.rb +1 -1
- data/lib/xdg/config.rb +1 -1
- data/lib/xdg/data.rb +1 -1
- data/lib/xdg/environment.rb +1 -1
- data/lib/xdg/identity.rb +4 -15
- data/lib/xdg/paths/directory.rb +3 -3
- data/lib/xdg/paths/{standard.rb → home.rb} +3 -3
- metadata +64 -49
- 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: c2f5c506da3a72de1866fffa3dd4b3f5668ff763af3094725c04db9623b34d64
|
|
4
|
+
data.tar.gz: d09ebc55bc4178203555eb6bb1780538d0de1800d7511862a27ff41fd0e4bc95
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60105cd15d211b8ed79e97df075cae9d8ab359e58b02b8cb31d35998f66e9045be7d4fa9de7e4fd6aa63ea3c33f4ef880c6be009c2c31030eb9fea76dafb0010
|
|
7
|
+
data.tar.gz: 974dc52e885ed0527b117ff044b687c1ea84014d7346beba0ca7089e78c82cc2473e068c3fc7562eb96f4ebf73a0940118740ee181532954ac4fadd054d6e9c8
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
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
|
|
153
|
+
Copyright link:https://www.alchemists.io[Alchemists].
|
|
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://circleci.com/gh/bkuhlmann/xdg]
|
|
10
|
+
image::https://circleci.com/gh/bkuhlmann/xdg.svg?style=svg[Circle CI Status]
|
|
11
|
+
|
|
12
|
+
Provides a Ruby implementation of the
|
|
13
|
+
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html[XDG Base Directory
|
|
14
|
+
Specification].
|
|
15
|
+
|
|
16
|
+
💡 If you write a lot of Command Line Interfaces and would like additional syntactic sugar that
|
|
17
|
+
includes what is found in this gem, make sure to check out the
|
|
18
|
+
link:https://www.alchemists.io/projects/runcom[Runcom] gem too.
|
|
19
|
+
|
|
20
|
+
toc::[]
|
|
21
|
+
|
|
22
|
+
== Features
|
|
23
|
+
|
|
24
|
+
* Provides a `XDG::Environment` object that adheres to the _XDG Base Directory Specification_ with
|
|
25
|
+
access to the following environment settings:
|
|
26
|
+
** `$XDG_CACHE_HOME`
|
|
27
|
+
** `$XDG_CONFIG_HOME`
|
|
28
|
+
** `$XDG_CONFIG_DIRS`
|
|
29
|
+
** `$XDG_DATA_HOME`
|
|
30
|
+
** `$XDG_DATA_DIRS`
|
|
31
|
+
|
|
32
|
+
== Requirements
|
|
33
|
+
|
|
34
|
+
. https://www.ruby-lang.org[Ruby]
|
|
35
|
+
|
|
36
|
+
== Setup
|
|
37
|
+
|
|
38
|
+
=== Production
|
|
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
|
+
=== Development
|
|
55
|
+
|
|
56
|
+
To contribute, run:
|
|
57
|
+
|
|
58
|
+
[source,bash]
|
|
59
|
+
----
|
|
60
|
+
git clone https://github.com/bkuhlmann/xdg.git
|
|
61
|
+
cd xdg
|
|
62
|
+
bin/setup
|
|
63
|
+
----
|
|
64
|
+
|
|
65
|
+
You can also use the IRB console for direct access to all objects:
|
|
66
|
+
|
|
67
|
+
[source,bash]
|
|
68
|
+
----
|
|
69
|
+
bin/console
|
|
70
|
+
----
|
|
71
|
+
|
|
72
|
+
== Usage
|
|
73
|
+
|
|
74
|
+
The following describes how to use this XDG implementation.
|
|
75
|
+
|
|
76
|
+
=== Overview
|
|
77
|
+
|
|
78
|
+
To get up and running quickly, use `+XDG::Environment+` as follows:
|
|
79
|
+
|
|
80
|
+
[source,ruby]
|
|
81
|
+
----
|
|
82
|
+
xdg = XDG::Environment.new
|
|
83
|
+
xdg.cache_home # <= Answers computed `$XDG_CACHE_HOME` value.
|
|
84
|
+
xdg.config_home # <= Answers computed `$XDG_CONFIG_HOME` value.
|
|
85
|
+
xdg.config_dirs # <= Answers computed `$XDG_CONFIG_DIRS` value.
|
|
86
|
+
xdg.data_home # <= Answers computed `$XDG_DATA_HOME` value.
|
|
87
|
+
xdg.data_dirs # <= Answers computed `$XDG_DATA_DIRS` value.
|
|
88
|
+
----
|
|
89
|
+
|
|
90
|
+
The _computed_ value, in this case, is either the user-defined value of the key or the default
|
|
91
|
+
value, per specification, when the key is not defined or empty. For more on this, scroll down to the
|
|
92
|
+
_Variable Defaults_ section to learn more.
|
|
93
|
+
|
|
94
|
+
The `XDG::Environment` wraps the following objects which can be used individually if you don’t
|
|
95
|
+
want to load the entire environment:
|
|
96
|
+
|
|
97
|
+
[source,ruby]
|
|
98
|
+
----
|
|
99
|
+
cache = XDG::Cache.new
|
|
100
|
+
config = XDG::Config.new
|
|
101
|
+
data = XDG::Data.new
|
|
102
|
+
----
|
|
103
|
+
|
|
104
|
+
The `cache`, `config`, and `data` objects share the same API which means you can ask each the
|
|
105
|
+
following messages:
|
|
106
|
+
|
|
107
|
+
* `#home` - Answers the home directory as computed via the `$XDG_*_HOME` key.
|
|
108
|
+
* `#directories` - Answers an array directories as computed via the `$XDG_*_DIRS` key.
|
|
109
|
+
* `#all` - Answers an array of _all_ directories as computed from the combined `$XDG_*_HOME` and
|
|
110
|
+
`$XDG_*_DIRS` values (with `$XDG_*_HOME` prefixed at the start of the array).
|
|
111
|
+
|
|
112
|
+
=== Examples
|
|
113
|
+
|
|
114
|
+
The following are examples of what you would see when playing around with the XDG objects within an
|
|
115
|
+
IRB console (taken from my own environment):
|
|
116
|
+
|
|
117
|
+
[source,ruby]
|
|
118
|
+
----
|
|
119
|
+
require "xdg"
|
|
120
|
+
|
|
121
|
+
# Initialization
|
|
122
|
+
environment = XDG::Environment.new
|
|
123
|
+
cache = XDG::Cache.new
|
|
124
|
+
config = XDG::Config.new
|
|
125
|
+
data = XDG::Data.new
|
|
126
|
+
|
|
127
|
+
# Inspection
|
|
128
|
+
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
|
|
129
|
+
cache.inspect # => "XDG_CACHE_HOME=/Users/bkuhlmann/.cache"
|
|
130
|
+
config.inspect # => "XDG_CONFIG_HOME=/Users/bkuhlmann/.config XDG_CONFIG_DIRS=/etc/xdg"
|
|
131
|
+
data.inspect # => "XDG_DATA_HOME=/Users/bkuhlmann/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
|
|
132
|
+
|
|
133
|
+
# Paths
|
|
134
|
+
environment.cache_home # => #<Pathname:/Users/bkuhlmann/.cache>
|
|
135
|
+
environment.config_home # => #<Pathname:/Users/bkuhlmann/.config>
|
|
136
|
+
environment.config_dirs # => [#<Pathname:/etc/xdg>]
|
|
137
|
+
environment.data_home # => #<Pathname:/Users/bkuhlmann/.local/share>
|
|
138
|
+
environment.data_dirs # => [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
|
139
|
+
|
|
140
|
+
cache.home # => #<Pathname:/Users/bkuhlmann/.cache>
|
|
141
|
+
cache.directories # => []
|
|
142
|
+
cache.all # => [#<Pathname:/Users/bkuhlmann/.cache>]
|
|
143
|
+
|
|
144
|
+
config.home # => #<Pathname:/Users/bkuhlmann/.config>
|
|
145
|
+
config.directories # => [#<Pathname:/etc/xdg>]
|
|
146
|
+
config.all # => [#<Pathname:/Users/bkuhlmann/.config>, #<Pathname:/etc/xdg>]
|
|
147
|
+
|
|
148
|
+
data.home # => #<Pathname:/Users/bkuhlmann/.local/share>
|
|
149
|
+
data.directories # => [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
|
150
|
+
data.all # => [#<Pathname:/Users/bkuhlmann/.local/share>, #<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
|
151
|
+
----
|
|
152
|
+
|
|
153
|
+
As you can see from above, each XDG object answers back a `Pathname` which means you have the full
|
|
154
|
+
`Pathname` API at your fingertips to build upon the output of these objects as needed.
|
|
155
|
+
|
|
156
|
+
=== Variable Defaults
|
|
157
|
+
|
|
158
|
+
The _XDG Base Directory Specification_ defines environment variables and associated default values
|
|
159
|
+
when not defined or empty. The following defaults, per specification, are implemented by the `XDG`
|
|
160
|
+
objects:
|
|
161
|
+
|
|
162
|
+
* `$XDG_CACHE_HOME="$HOME/.cache"`
|
|
163
|
+
* `$XDG_CONFIG_HOME="$HOME/.config"`
|
|
164
|
+
* `$XDG_CONFIG_DIRS="/etc/xdg"`
|
|
165
|
+
* `$XDG_DATA_HOME="$HOME/.local/share"`
|
|
166
|
+
* `$XDG_DATA_DIRS="/usr/local/share/:/usr/share/"`
|
|
167
|
+
* `$XDG_RUNTIME_DIR`
|
|
168
|
+
|
|
169
|
+
The `$XDG_RUNTIME_DIR` deserves special mention as it’s not, _currently_, implemented as part of
|
|
170
|
+
this gem because it is more user/environment specific. Here is how the `$XDG_RUNTIME_DIR` is meant
|
|
171
|
+
to be used should you choose to use it:
|
|
172
|
+
|
|
173
|
+
* _Must_ reference user-specific non-essential runtime files and other file objects (such as
|
|
174
|
+
sockets, named pipes, etc.)
|
|
175
|
+
* _Must_ be owned by the user with _only_ the user having read and write access to it.
|
|
176
|
+
* _Must_ have a Unix access mode of `0700`.
|
|
177
|
+
* _Must_ be bound to the user when logging in.
|
|
178
|
+
* _Must_ be removed when the user logs out.
|
|
179
|
+
* _Must_ be pointed to the same directory when the user logs in more than once.
|
|
180
|
+
* _Must_ exist from first login to last logout on the system and not removed in between.
|
|
181
|
+
* _Must_ not allow files in the directory to survive reboot or a full logout/login cycle.
|
|
182
|
+
* _Must_ keep the directory on the local file system and not shared with any other file systems.
|
|
183
|
+
* _Must_ keep the directory fully-featured by the standards of the operating system. Specifically,
|
|
184
|
+
on Unix-like operating systems AF_UNIX sockets, symbolic links, hard links, proper permissions, file
|
|
185
|
+
locking, sparse files, memory mapping, file change notifications, a reliable hard link count must be
|
|
186
|
+
supported, and no restrictions on the file name character set should be imposed. Files in this
|
|
187
|
+
directory _may_ be subjected to periodic clean-up. To ensure files are not removed, they should have
|
|
188
|
+
their access time timestamp modified at least once every 6 hours of monotonic time or the '`sticky`'
|
|
189
|
+
bit should be set on the file.
|
|
190
|
+
* When not set, applications should fall back to a replacement directory with similar capabilities
|
|
191
|
+
and print a warning message. Applications should use this directory for communication and
|
|
192
|
+
synchronization purposes and should not place larger files in it, since it might reside in runtime
|
|
193
|
+
memory and cannot necessarily be swapped out to disk.
|
|
194
|
+
|
|
195
|
+
=== Variable Behavior
|
|
196
|
+
|
|
197
|
+
The behavior of most XDG environment variables can be lumped into two categories:
|
|
198
|
+
|
|
199
|
+
* `$XDG_*_HOME`
|
|
200
|
+
* `$XDG_*_DIRS`
|
|
201
|
+
|
|
202
|
+
Each is described in detail below.
|
|
203
|
+
|
|
204
|
+
==== `$XDG_*_DIRS`
|
|
205
|
+
|
|
206
|
+
These variables are used to define a colon (`:`) delimited list of directories. Order is important
|
|
207
|
+
as the first directory defined will take precedent over the following directory and so forth. For
|
|
208
|
+
example, here is a situation where the `XDG_CONFIG_DIRS` key has a custom value:
|
|
209
|
+
|
|
210
|
+
[source,bash]
|
|
211
|
+
----
|
|
212
|
+
XDG_CONFIG_DIRS="/example/one/.config:/example/two/.settings:/example/three/.configuration"
|
|
213
|
+
----
|
|
214
|
+
|
|
215
|
+
Yields the following, colon delimited, array:
|
|
216
|
+
|
|
217
|
+
[source,ruby]
|
|
218
|
+
----
|
|
219
|
+
[
|
|
220
|
+
"/example/one/.config",
|
|
221
|
+
"/example/two/.settings",
|
|
222
|
+
"/example/three/.configuration"
|
|
223
|
+
]
|
|
224
|
+
----
|
|
225
|
+
|
|
226
|
+
In the above example, the `"/example/one/.config"` path takes _highest_ priority since it was
|
|
227
|
+
defined first.
|
|
228
|
+
|
|
229
|
+
==== `$XDG_*_HOME`
|
|
230
|
+
|
|
231
|
+
These variables take precidence over the corresponding `$XDG_*_DIRS` environment variables. Using
|
|
232
|
+
a modified version of the `$XDG_*_DIRS` example, shown above, we could have the following setup:
|
|
233
|
+
|
|
234
|
+
[source,bash]
|
|
235
|
+
----
|
|
236
|
+
XDG_CONFIG_HOME="/example/priority"
|
|
237
|
+
XDG_CONFIG_DIRS="/example/one/.config:/example/two/.settings"
|
|
238
|
+
----
|
|
239
|
+
|
|
240
|
+
Yields the following, colon delimited, array:
|
|
241
|
+
|
|
242
|
+
[source,ruby]
|
|
243
|
+
----
|
|
244
|
+
[
|
|
245
|
+
"/example/priority",
|
|
246
|
+
"/example/one/.config",
|
|
247
|
+
"/example/two/.settings"
|
|
248
|
+
]
|
|
249
|
+
----
|
|
250
|
+
|
|
251
|
+
Due to `XDG_CONFIG_HOME` taking precidence over the `XDG_CONFIG_DIRS`, the path with the
|
|
252
|
+
_highest_ priority in this example is: `"/example/priority"`.
|
|
253
|
+
|
|
254
|
+
=== Variable Priority
|
|
255
|
+
|
|
256
|
+
Path precedence is determined in the following order (with the first taking highest priority):
|
|
257
|
+
|
|
258
|
+
. `$XDG_*_HOME` - Will be used if defined. Otherwise, falls back to specification default.
|
|
259
|
+
. `$XDG_*_DIRS` - Iterates through directories in order defined (with first taking highest
|
|
260
|
+
priority). Otherwise, falls back to specification default.
|
|
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.rb
CHANGED
data/lib/xdg/cache.rb
CHANGED
|
@@ -10,7 +10,7 @@ module XDG
|
|
|
10
10
|
|
|
11
11
|
delegate %i[home directories all inspect] => :combined
|
|
12
12
|
|
|
13
|
-
def initialize home: Paths::
|
|
13
|
+
def initialize home: Paths::Home, directories: Paths::Directory, environment: ENV
|
|
14
14
|
@combined = Paths::Combined.new home.new(HOME_PAIR, environment),
|
|
15
15
|
directories.new(Pair.new, environment)
|
|
16
16
|
end
|
data/lib/xdg/config.rb
CHANGED
|
@@ -11,7 +11,7 @@ module XDG
|
|
|
11
11
|
|
|
12
12
|
delegate %i[home directories all inspect] => :combined
|
|
13
13
|
|
|
14
|
-
def initialize home: Paths::
|
|
14
|
+
def initialize home: Paths::Home, directories: Paths::Directory, environment: ENV
|
|
15
15
|
@combined = Paths::Combined.new home.new(HOME_PAIR, environment),
|
|
16
16
|
directories.new(DIRS_PAIR, environment)
|
|
17
17
|
end
|
data/lib/xdg/data.rb
CHANGED
|
@@ -11,7 +11,7 @@ module XDG
|
|
|
11
11
|
|
|
12
12
|
delegate %i[home directories all inspect] => :combined
|
|
13
13
|
|
|
14
|
-
def initialize home: Paths::
|
|
14
|
+
def initialize home: Paths::Home, directories: Paths::Directory, environment: ENV
|
|
15
15
|
@combined = Paths::Combined.new home.new(HOME_PAIR, environment),
|
|
16
16
|
directories.new(DIRS_PAIR, environment)
|
|
17
17
|
end
|
data/lib/xdg/environment.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module XDG
|
|
4
4
|
class Environment
|
|
5
|
-
def initialize home: Paths::
|
|
5
|
+
def initialize home: Paths::Home, directories: Paths::Directory, environment: ENV
|
|
6
6
|
@cache = Cache.new home: home, directories: directories, environment: environment
|
|
7
7
|
@config = Config.new home: home, directories: directories, environment: environment
|
|
8
8
|
@data = Data.new home: home, directories: directories, environment: environment
|
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
|
-
"3.1.0"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.version_label
|
|
19
|
-
"#{label} #{version}"
|
|
20
|
-
end
|
|
6
|
+
NAME = "xdg"
|
|
7
|
+
LABEL = "XDG"
|
|
8
|
+
VERSION = "4.2.0"
|
|
9
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
|
21
10
|
end
|
|
22
11
|
end
|
data/lib/xdg/paths/directory.rb
CHANGED
|
@@ -14,11 +14,11 @@ module XDG
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def default
|
|
17
|
-
|
|
17
|
+
value.split(DELIMITER).map(&method(:expand))
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def dynamic
|
|
21
|
-
String(environment[key]).then { |
|
|
21
|
+
String(environment[key]).then { |env_value| env_value.empty? ? value : env_value }
|
|
22
22
|
.split(DELIMITER)
|
|
23
23
|
.uniq
|
|
24
24
|
.map(&method(:expand))
|
|
@@ -36,7 +36,7 @@ module XDG
|
|
|
36
36
|
String pair.key
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def
|
|
39
|
+
def value
|
|
40
40
|
String pair.value
|
|
41
41
|
end
|
|
42
42
|
|
|
@@ -6,10 +6,10 @@ require "pathname"
|
|
|
6
6
|
module XDG
|
|
7
7
|
module Paths
|
|
8
8
|
# A XDG home path.
|
|
9
|
-
class
|
|
9
|
+
class Home
|
|
10
10
|
extend Forwardable
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
KEY = "HOME"
|
|
13
13
|
|
|
14
14
|
delegate %i[key value] => :pair
|
|
15
15
|
|
|
@@ -39,7 +39,7 @@ module XDG
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def home
|
|
42
|
-
Pathname environment.fetch(
|
|
42
|
+
Pathname environment.fetch(KEY)
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
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
|
+
version: 4.2.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,15 +20,15 @@ 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:
|
|
31
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
|
32
32
|
dependencies:
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: bundler-audit
|
|
@@ -50,28 +50,28 @@ dependencies:
|
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
53
|
+
version: '14.2'
|
|
54
54
|
type: :development
|
|
55
55
|
prerelease: false
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
60
|
+
version: '14.2'
|
|
61
61
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
name: git-
|
|
62
|
+
name: git-lint
|
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
67
|
+
version: '1.0'
|
|
68
68
|
type: :development
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
74
|
+
version: '1.0'
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
76
|
name: guard-rspec
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -92,137 +92,151 @@ dependencies:
|
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '0.
|
|
95
|
+
version: '0.13'
|
|
96
96
|
type: :development
|
|
97
97
|
prerelease: false
|
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
|
100
100
|
- - "~>"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '0.
|
|
102
|
+
version: '0.13'
|
|
103
103
|
- !ruby/object:Gem::Dependency
|
|
104
104
|
name: pry-byebug
|
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
|
107
107
|
- - "~>"
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '3.
|
|
109
|
+
version: '3.9'
|
|
110
110
|
type: :development
|
|
111
111
|
prerelease: false
|
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
113
|
requirements:
|
|
114
114
|
- - "~>"
|
|
115
115
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '3.
|
|
116
|
+
version: '3.9'
|
|
117
117
|
- !ruby/object:Gem::Dependency
|
|
118
118
|
name: rake
|
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
|
120
120
|
requirements:
|
|
121
121
|
- - "~>"
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: '
|
|
123
|
+
version: '13.0'
|
|
124
124
|
type: :development
|
|
125
125
|
prerelease: false
|
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
127
|
requirements:
|
|
128
128
|
- - "~>"
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: '
|
|
130
|
+
version: '13.0'
|
|
131
131
|
- !ruby/object:Gem::Dependency
|
|
132
132
|
name: reek
|
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
|
134
134
|
requirements:
|
|
135
135
|
- - "~>"
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '
|
|
137
|
+
version: '6.0'
|
|
138
138
|
type: :development
|
|
139
139
|
prerelease: false
|
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
141
|
requirements:
|
|
142
142
|
- - "~>"
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '
|
|
144
|
+
version: '6.0'
|
|
145
145
|
- !ruby/object:Gem::Dependency
|
|
146
146
|
name: rspec
|
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements:
|
|
149
149
|
- - "~>"
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: '3.
|
|
151
|
+
version: '3.9'
|
|
152
152
|
type: :development
|
|
153
153
|
prerelease: false
|
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
|
155
155
|
requirements:
|
|
156
156
|
- - "~>"
|
|
157
157
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: '3.
|
|
158
|
+
version: '3.9'
|
|
159
159
|
- !ruby/object:Gem::Dependency
|
|
160
160
|
name: rubocop
|
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
|
162
162
|
requirements:
|
|
163
163
|
- - "~>"
|
|
164
164
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: '0.
|
|
165
|
+
version: '0.83'
|
|
166
166
|
type: :development
|
|
167
167
|
prerelease: false
|
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
|
169
169
|
requirements:
|
|
170
170
|
- - "~>"
|
|
171
171
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: '0.
|
|
172
|
+
version: '0.83'
|
|
173
173
|
- !ruby/object:Gem::Dependency
|
|
174
174
|
name: rubocop-performance
|
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
|
176
176
|
requirements:
|
|
177
177
|
- - "~>"
|
|
178
178
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: '1.
|
|
179
|
+
version: '1.5'
|
|
180
180
|
type: :development
|
|
181
181
|
prerelease: false
|
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
|
183
183
|
requirements:
|
|
184
184
|
- - "~>"
|
|
185
185
|
- !ruby/object:Gem::Version
|
|
186
|
-
version: '1.
|
|
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'
|
|
187
201
|
- !ruby/object:Gem::Dependency
|
|
188
202
|
name: rubocop-rspec
|
|
189
203
|
requirement: !ruby/object:Gem::Requirement
|
|
190
204
|
requirements:
|
|
191
205
|
- - "~>"
|
|
192
206
|
- !ruby/object:Gem::Version
|
|
193
|
-
version: '1.
|
|
207
|
+
version: '1.39'
|
|
194
208
|
type: :development
|
|
195
209
|
prerelease: false
|
|
196
210
|
version_requirements: !ruby/object:Gem::Requirement
|
|
197
211
|
requirements:
|
|
198
212
|
- - "~>"
|
|
199
213
|
- !ruby/object:Gem::Version
|
|
200
|
-
version: '1.
|
|
214
|
+
version: '1.39'
|
|
201
215
|
- !ruby/object:Gem::Dependency
|
|
202
216
|
name: simplecov
|
|
203
217
|
requirement: !ruby/object:Gem::Requirement
|
|
204
218
|
requirements:
|
|
205
219
|
- - "~>"
|
|
206
220
|
- !ruby/object:Gem::Version
|
|
207
|
-
version: '0.
|
|
221
|
+
version: '0.18'
|
|
208
222
|
type: :development
|
|
209
223
|
prerelease: false
|
|
210
224
|
version_requirements: !ruby/object:Gem::Requirement
|
|
211
225
|
requirements:
|
|
212
226
|
- - "~>"
|
|
213
227
|
- !ruby/object:Gem::Version
|
|
214
|
-
version: '0.
|
|
215
|
-
description:
|
|
228
|
+
version: '0.18'
|
|
229
|
+
description:
|
|
216
230
|
email:
|
|
217
231
|
- brooke@alchemists.io
|
|
218
232
|
executables: []
|
|
219
233
|
extensions: []
|
|
220
234
|
extra_rdoc_files:
|
|
221
|
-
- README.
|
|
222
|
-
- LICENSE.
|
|
235
|
+
- README.adoc
|
|
236
|
+
- LICENSE.adoc
|
|
223
237
|
files:
|
|
224
|
-
- LICENSE.
|
|
225
|
-
- README.
|
|
238
|
+
- LICENSE.adoc
|
|
239
|
+
- README.adoc
|
|
226
240
|
- lib/xdg.rb
|
|
227
241
|
- lib/xdg/cache.rb
|
|
228
242
|
- lib/xdg/config.rb
|
|
@@ -232,15 +246,16 @@ files:
|
|
|
232
246
|
- lib/xdg/pair.rb
|
|
233
247
|
- lib/xdg/paths/combined.rb
|
|
234
248
|
- lib/xdg/paths/directory.rb
|
|
235
|
-
- lib/xdg/paths/
|
|
236
|
-
homepage: https://
|
|
249
|
+
- lib/xdg/paths/home.rb
|
|
250
|
+
homepage: https://www.alchemists.io/projects/xdg
|
|
237
251
|
licenses:
|
|
238
252
|
- Apache-2.0
|
|
239
253
|
metadata:
|
|
240
|
-
source_code_uri: https://github.com/bkuhlmann/xdg
|
|
241
|
-
changelog_uri: https://github.com/bkuhlmann/xdg/blob/master/CHANGES.md
|
|
242
254
|
bug_tracker_uri: https://github.com/bkuhlmann/xdg/issues
|
|
243
|
-
|
|
255
|
+
changelog_uri: https://www.alchemists.io/projects/xdg/changes.html
|
|
256
|
+
documentation_uri: https://www.alchemists.io/projects/xdg
|
|
257
|
+
source_code_uri: https://github.com/bkuhlmann/xdg
|
|
258
|
+
post_install_message:
|
|
244
259
|
rdoc_options: []
|
|
245
260
|
require_paths:
|
|
246
261
|
- lib
|
|
@@ -248,15 +263,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
248
263
|
requirements:
|
|
249
264
|
- - "~>"
|
|
250
265
|
- !ruby/object:Gem::Version
|
|
251
|
-
version: '2.
|
|
266
|
+
version: '2.7'
|
|
252
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
268
|
requirements:
|
|
254
269
|
- - ">="
|
|
255
270
|
- !ruby/object:Gem::Version
|
|
256
271
|
version: '0'
|
|
257
272
|
requirements: []
|
|
258
|
-
rubygems_version: 3.
|
|
259
|
-
signing_key:
|
|
273
|
+
rubygems_version: 3.1.4
|
|
274
|
+
signing_key:
|
|
260
275
|
specification_version: 4
|
|
261
276
|
summary: Provides an implementation of the XDG Base Directory Specification.
|
|
262
277
|
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
|
-
[](http://badge.fury.io/rb/xdg)
|
|
8
|
-
[](https://codeclimate.com/github/bkuhlmann/xdg/maintainability)
|
|
9
|
-
[](https://codeclimate.com/github/bkuhlmann/xdg/test_coverage)
|
|
10
|
-
[](https://circleci.com/gh/bkuhlmann/xdg)
|
|
11
|
-
|
|
12
|
-
Provides a Ruby implementation of the [XDG Base Directory
|
|
13
|
-
Specification](https://standards.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.6.4](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).
|