xdg 6.5.0 → 6.6.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/README.adoc +43 -32
- data/lib/xdg/cache.rb +1 -0
- data/lib/xdg/config.rb +1 -0
- data/lib/xdg/data.rb +1 -0
- data/lib/xdg/environment.rb +7 -3
- data/lib/xdg/state.rb +23 -0
- data/lib/xdg.rb +1 -0
- data/xdg.gemspec +1 -1
- data.tar.gz.sig +4 -2
- metadata +4 -3
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1a337c5649d81e8d7421794ff85c904aef168e84dc713ddb146a5959f8f7e7e
|
4
|
+
data.tar.gz: 8e5d15918077dff3d4bb0b1edd70ae413a9f975a559fb72dd6d10b2126ac4bad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84800060d723b7e06449223341be67a8d67832ceec513076873835c9d00c2f92c3f3f0938d9ffe4edad8818896526f62c179718d2ad0db86898ac7ca3821926
|
7
|
+
data.tar.gz: b12a448e2950a982a7d9254401de2231a7537354f3f587221baea25c2e988c46c49ec08f025ecc1b4c5be5b186984a9f79fcd9cb9c49295ac43f8f069b6ed09f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -25,6 +25,7 @@ access to the following environment settings:
|
|
25
25
|
** `$XDG_CONFIG_DIRS`
|
26
26
|
** `$XDG_DATA_HOME`
|
27
27
|
** `$XDG_DATA_DIRS`
|
28
|
+
** `$XDG_STATE_HOME`
|
28
29
|
|
29
30
|
== Requirements
|
30
31
|
|
@@ -48,20 +49,21 @@ gem "xdg"
|
|
48
49
|
|
49
50
|
== Usage
|
50
51
|
|
51
|
-
The following describes how to use this
|
52
|
+
The following describes how to use this implementation.
|
52
53
|
|
53
|
-
===
|
54
|
+
=== Objects
|
54
55
|
|
55
56
|
To get up and running quickly, use `+XDG::Environment+` as follows:
|
56
57
|
|
57
58
|
[source,ruby]
|
58
59
|
----
|
59
60
|
xdg = XDG::Environment.new
|
60
|
-
xdg.cache_home
|
61
|
-
xdg.config_home
|
62
|
-
xdg.config_dirs
|
63
|
-
xdg.data_home
|
64
|
-
xdg.data_dirs
|
61
|
+
xdg.cache_home # Answers computed `$XDG_CACHE_HOME` value.
|
62
|
+
xdg.config_home # Answers computed `$XDG_CONFIG_HOME` value.
|
63
|
+
xdg.config_dirs # Answers computed `$XDG_CONFIG_DIRS` value.
|
64
|
+
xdg.data_home # Answers computed `$XDG_DATA_HOME` value.
|
65
|
+
xdg.data_dirs # Answers computed `$XDG_DATA_DIRS` value.
|
66
|
+
xdg.state_home # Answers computed `$XDG_STATE_HOME` value.
|
65
67
|
----
|
66
68
|
|
67
69
|
The _computed_ value, in this case, is either the user-defined value of the key or the default
|
@@ -76,9 +78,10 @@ want to load the entire environment:
|
|
76
78
|
cache = XDG::Cache.new
|
77
79
|
config = XDG::Config.new
|
78
80
|
data = XDG::Data.new
|
81
|
+
state = XDG::State.new
|
79
82
|
----
|
80
83
|
|
81
|
-
The `cache`, `config`, and `
|
84
|
+
The `cache`, `config`, `data`, and `state` objects share the same API which means you can ask each the
|
82
85
|
following messages:
|
83
86
|
|
84
87
|
* `#home` - Answers the home directory as computed via the `$XDG_*_HOME` key.
|
@@ -100,31 +103,38 @@ environment = XDG::Environment.new
|
|
100
103
|
cache = XDG::Cache.new
|
101
104
|
config = XDG::Config.new
|
102
105
|
data = XDG::Data.new
|
106
|
+
state = XDG::State.new
|
103
107
|
|
104
108
|
# Inspection
|
105
|
-
environment.inspect
|
106
|
-
cache.inspect
|
107
|
-
config.inspect
|
108
|
-
data.inspect
|
109
|
+
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 XDG_STATE_HOME=/Users/bkuhlmann/.local/state"
|
110
|
+
cache.inspect # "XDG_CACHE_HOME=/Users/bkuhlmann/.cache"
|
111
|
+
config.inspect # "XDG_CONFIG_HOME=/Users/bkuhlmann/.config XDG_CONFIG_DIRS=/etc/xdg"
|
112
|
+
data.inspect # "XDG_DATA_HOME=/Users/bkuhlmann/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
|
113
|
+
state.inspect # "XDG_STATE_HOME=/Users/bkuhlmann/.local/state"
|
109
114
|
|
110
115
|
# Paths
|
111
|
-
environment.cache_home
|
112
|
-
environment.config_home
|
113
|
-
environment.config_dirs
|
114
|
-
environment.data_home
|
115
|
-
environment.data_dirs
|
116
|
-
|
117
|
-
|
118
|
-
cache.
|
119
|
-
cache.
|
120
|
-
|
121
|
-
|
122
|
-
config.
|
123
|
-
config.
|
124
|
-
|
125
|
-
|
126
|
-
data.
|
127
|
-
data.
|
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
|
+
environment.state_home # #<Pathname:/Users/bkuhlmann/.local/state>
|
122
|
+
|
123
|
+
cache.home # #<Pathname:/Users/bkuhlmann/.cache>
|
124
|
+
cache.directories # []
|
125
|
+
cache.all # [#<Pathname:/Users/bkuhlmann/.cache>]
|
126
|
+
|
127
|
+
config.home # #<Pathname:/Users/bkuhlmann/.config>
|
128
|
+
config.directories # [#<Pathname:/etc/xdg>]
|
129
|
+
config.all # [#<Pathname:/Users/bkuhlmann/.config>, #<Pathname:/etc/xdg>]
|
130
|
+
|
131
|
+
data.home # #<Pathname:/Users/bkuhlmann/.local/share>
|
132
|
+
data.directories # [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
133
|
+
data.all # [#<Pathname:/Users/bkuhlmann/.local/share>, #<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
134
|
+
|
135
|
+
state.home # #<Pathname:/Users/bkuhlmann/.local/state>
|
136
|
+
state.directories # []
|
137
|
+
state.all # [#<Pathname:/Users/bkuhlmann/.local/state>]
|
128
138
|
----
|
129
139
|
|
130
140
|
As you can see from above, each XDG object answers back a `Pathname` which means you have the full
|
@@ -142,6 +152,7 @@ objects:
|
|
142
152
|
* `$XDG_DATA_HOME="$HOME/.local/share"`
|
143
153
|
* `$XDG_DATA_DIRS="/usr/local/share/:/usr/share/"`
|
144
154
|
* `$XDG_RUNTIME_DIR`
|
155
|
+
* `$XDG_STATE_HOME="$HOME/.local/state"`
|
145
156
|
|
146
157
|
The `$XDG_RUNTIME_DIR` deserves special mention as it’s not, _currently_, implemented as part of
|
147
158
|
this gem because it is more user/environment specific. Here is how the `$XDG_RUNTIME_DIR` is meant
|
@@ -173,12 +184,12 @@ memory and cannot necessarily be swapped out to disk.
|
|
173
184
|
|
174
185
|
The behavior of most XDG environment variables can be lumped into two categories:
|
175
186
|
|
176
|
-
* `$XDG_*_HOME`
|
177
187
|
* `$XDG_*_DIRS`
|
188
|
+
* `$XDG_*_HOME`
|
178
189
|
|
179
190
|
Each is described in detail below.
|
180
191
|
|
181
|
-
====
|
192
|
+
==== Directories
|
182
193
|
|
183
194
|
These variables are used to define a colon (`:`) delimited list of directories. Order is important
|
184
195
|
as the first directory defined will take precedent over the following directory and so forth. For
|
@@ -203,7 +214,7 @@ Yields the following, colon delimited, array:
|
|
203
214
|
In the above example, the `"/example/one/.config"` path takes _highest_ priority since it was
|
204
215
|
defined first.
|
205
216
|
|
206
|
-
====
|
217
|
+
==== Homes
|
207
218
|
|
208
219
|
These variables take precedence over the corresponding `$XDG_*_DIRS` environment variables. Using
|
209
220
|
a modified version of the `$XDG_*_DIRS` example, shown above, we could have the following setup:
|
data/lib/xdg/cache.rb
CHANGED
data/lib/xdg/config.rb
CHANGED
data/lib/xdg/data.rb
CHANGED
data/lib/xdg/environment.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module XDG
|
4
|
+
# A convenience wrapper to all XDG functionality.
|
4
5
|
class Environment
|
5
6
|
def initialize home: Paths::Home, directories: Paths::Directory, environment: ENV
|
6
7
|
@cache = Cache.new(home:, directories:, environment:)
|
7
8
|
@config = Config.new(home:, directories:, environment:)
|
8
|
-
@data = Data.new
|
9
|
+
@data = Data.new(home:, directories:, environment:)
|
10
|
+
@state = State.new home:, directories:, environment:
|
9
11
|
end
|
10
12
|
|
11
13
|
def cache_home = cache.home
|
@@ -18,10 +20,12 @@ module XDG
|
|
18
20
|
|
19
21
|
def data_dirs = data.directories
|
20
22
|
|
21
|
-
def
|
23
|
+
def state_home = state.home
|
24
|
+
|
25
|
+
def inspect = "#{cache.inspect} #{config.inspect} #{data.inspect} #{state.inspect}"
|
22
26
|
|
23
27
|
private
|
24
28
|
|
25
|
-
attr_reader :cache, :config, :data
|
29
|
+
attr_reader :cache, :config, :data, :state
|
26
30
|
end
|
27
31
|
end
|
data/lib/xdg/state.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
|
5
|
+
module XDG
|
6
|
+
# Provides state support.
|
7
|
+
class State
|
8
|
+
extend Forwardable
|
9
|
+
|
10
|
+
HOME_PAIR = Pair["XDG_STATE_HOME", ".local/state"].freeze
|
11
|
+
|
12
|
+
delegate %i[home directories all inspect] => :combined
|
13
|
+
|
14
|
+
def initialize home: Paths::Home, directories: Paths::Directory, environment: ENV
|
15
|
+
@combined = Paths::Combined.new home.new(HOME_PAIR, environment),
|
16
|
+
directories.new(Pair.new, environment)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :combined
|
22
|
+
end
|
23
|
+
end
|
data/lib/xdg.rb
CHANGED
data/xdg.gemspec
CHANGED
data.tar.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�:�p��� �͝g�����!���Wc�B���J
|
2
|
+
b+�=�Z��6O�1ҙ8�a6$�a��'�QG��_�E�g�,�gF����M�P�x�0�JV�t��H���t��z��2��;�Ӗ7�%�(*�φI����XwsV4�w$//��p���-m�63��k�[�ieu��p�ё$
|
3
|
+
�~�ҵOh2F"Ť���Ŵ]r�Ol
|
4
|
+
e��EͲ(~}w�v�Q�?����2�3b��4Ԩ2Fb���aş��wj�w��
|
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: 6.
|
4
|
+
version: 6.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
|
29
29
|
RFE=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2022-
|
31
|
+
date: 2022-09-10 00:00:00.000000000 Z
|
32
32
|
dependencies: []
|
33
33
|
description:
|
34
34
|
email:
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/xdg/paths/combined.rb
|
51
51
|
- lib/xdg/paths/directory.rb
|
52
52
|
- lib/xdg/paths/home.rb
|
53
|
+
- lib/xdg/state.rb
|
53
54
|
- xdg.gemspec
|
54
55
|
homepage: https://www.alchemists.io/projects/xdg
|
55
56
|
licenses:
|
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
|
-
rubygems_version: 3.3.
|
81
|
+
rubygems_version: 3.3.22
|
81
82
|
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: Provides an implementation of the XDG Base Directory Specification.
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
�
|
2
|
-
|
1
|
+
t\3�X���/m���oֵR4dsI���#�.pd��#.+i�9pL�.��/(zϯbG$u|P�rЋ��GFϮ�۰q0
|
2
|
+
',(Å��!O��Ò� KX���S�_�[�.G7�S?�?��x���S��\E`��xh���2Nw\��F$��֨��i&F�fa��+s�\���� ������W1�q��۷Y�p;(
|