xdg 4.0.1 → 4.1.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 +0 -0
- data/{LICENSE.md → LICENSE.adoc} +29 -30
- data/README.adoc +298 -0
- data/lib/xdg/identity.rb +4 -15
- metadata +22 -21
- 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: d60ccee2cde7053f46ceec9c294a175e6834cf35075a88a58fc6a8ab1e44d971
|
4
|
+
data.tar.gz: a5a103d0c9d7f9316e6fc879aed226f6495e5075bb35e41d89d19d141cf4d9ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 872d932d6a12e319fc87cd684328167404849d1f799c6dcec9af9f8d163a268dd8a3a01f64399ac7dd16e091adcdeadca5df9ed6b158b5485e2ce4e50de559fb
|
7
|
+
data.tar.gz: fe7881085ec69c44e87e73b2ab1989707576e662453020745b7a9b3fd8043d34381d360c443e143d9a616863d1ea265229a741474f597fe48b1b273e6606737e
|
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 2.7.x]
|
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.html[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.1.0"
|
9
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
21
10
|
end
|
22
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xdg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -10,9 +10,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: 2020-
|
31
|
+
date: 2020-04-01 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler-audit
|
@@ -134,14 +134,14 @@ dependencies:
|
|
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
|
@@ -232,11 +232,11 @@ email:
|
|
232
232
|
executables: []
|
233
233
|
extensions: []
|
234
234
|
extra_rdoc_files:
|
235
|
-
- README.
|
236
|
-
- LICENSE.
|
235
|
+
- README.adoc
|
236
|
+
- LICENSE.adoc
|
237
237
|
files:
|
238
|
-
- LICENSE.
|
239
|
-
- README.
|
238
|
+
- LICENSE.adoc
|
239
|
+
- README.adoc
|
240
240
|
- lib/xdg.rb
|
241
241
|
- lib/xdg/cache.rb
|
242
242
|
- lib/xdg/config.rb
|
@@ -247,13 +247,14 @@ files:
|
|
247
247
|
- lib/xdg/paths/combined.rb
|
248
248
|
- lib/xdg/paths/directory.rb
|
249
249
|
- lib/xdg/paths/home.rb
|
250
|
-
homepage: https://
|
250
|
+
homepage: https://www.alchemists.io/projects/xdg
|
251
251
|
licenses:
|
252
252
|
- Apache-2.0
|
253
253
|
metadata:
|
254
|
-
source_code_uri: https://github.com/bkuhlmann/xdg
|
255
|
-
changelog_uri: https://github.com/bkuhlmann/xdg/blob/master/CHANGES.md
|
256
254
|
bug_tracker_uri: https://github.com/bkuhlmann/xdg/issues
|
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
|
257
258
|
post_install_message:
|
258
259
|
rdoc_options: []
|
259
260
|
require_paths:
|
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).
|