xdg 7.0.3 β 7.1.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/README.adoc +40 -49
- data/lib/xdg/environment.rb +1 -1
- data/lib/xdg/paths/combined.rb +1 -1
- data/lib/xdg/paths/directory.rb +3 -3
- data/lib/xdg/paths/home.rb +3 -3
- data/lib/xdg.rb +3 -0
- data/xdg.gemspec +2 -2
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba35d3c6fb994dd6fe78559246713b0becaf734c1a041ab06d3a676ae7d27594
|
4
|
+
data.tar.gz: 42637de1bfe11259c973be52845bf458f5f865254ace39cd08fcd1e66c17e8a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a16e6afd1906a893bb92b92718c46109d520a1bab072a7adc44ba90e80e0ae6a38e10671c6f361473a45f2bf14b4e945e13512ff85e8acad1969913d24eb3d4
|
7
|
+
data.tar.gz: 904e7e87d2db00887562bd2df5c0af46757616a59f4547855bd4ea55c0cbf54caf3d8620d2bf299beeaacdced2a6bc5c8bbdbf68d1caa9ac659c50fb047d5ee5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -4,22 +4,17 @@
|
|
4
4
|
|
5
5
|
= XDG
|
6
6
|
|
7
|
-
Provides a Ruby implementation of the
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
runtime.
|
12
|
-
|
13
|
-
π‘ If you write a lot of Command Line Interfaces and would like additional/advanced syntactic sugar
|
14
|
-
that includes what is found in this gem, make sure to check out the
|
7
|
+
Provides a Ruby implementation of the link:https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html[XDG Base Directory
|
8
|
+
Specification] for managing common configurations without polluting your dotfiles. XDG is great for command line interfaces or any application that needs a common configuration, cache, data, state, or runtime.
|
9
|
+
|
10
|
+
π‘ If you write a lot of Command Line Interfaces and would like additional/advanced syntactic sugar that includes what is found in this gem, make sure to check out the
|
15
11
|
link:https://alchemists.io/projects/runcom[Runcom] gem too.
|
16
12
|
|
17
13
|
toc::[]
|
18
14
|
|
19
15
|
== Features
|
20
16
|
|
21
|
-
* Provides a `XDG
|
22
|
-
access to the following environment settings:
|
17
|
+
* Provides a `XDG` object that adheres to the _XDG Base Directory Specification_ with access to the following environment settings:
|
23
18
|
** `$XDG_CACHE_HOME`
|
24
19
|
** `$XDG_CONFIG_HOME`
|
25
20
|
** `$XDG_CONFIG_DIRS`
|
@@ -69,11 +64,11 @@ The following describes how to use this implementation.
|
|
69
64
|
|
70
65
|
=== Objects
|
71
66
|
|
72
|
-
To get up and running quickly, use
|
67
|
+
To get up and running quickly, use `XDG.new` as follows:
|
73
68
|
|
74
69
|
[source,ruby]
|
75
70
|
----
|
76
|
-
xdg = XDG
|
71
|
+
xdg = XDG.new
|
77
72
|
xdg.cache_home # Answers computed `$XDG_CACHE_HOME` value.
|
78
73
|
xdg.config_home # Answers computed `$XDG_CONFIG_HOME` value.
|
79
74
|
xdg.config_dirs # Answers computed `$XDG_CONFIG_DIRS` value.
|
@@ -82,12 +77,7 @@ xdg.data_dirs # Answers computed `$XDG_DATA_DIRS` value.
|
|
82
77
|
xdg.state_home # Answers computed `$XDG_STATE_HOME` value.
|
83
78
|
----
|
84
79
|
|
85
|
-
|
86
|
-
value, per specification, when the key is not defined or empty. For more on this, scroll down to the
|
87
|
-
_Variable Defaults_ section to learn more.
|
88
|
-
|
89
|
-
The `XDG::Environment` wraps the following objects which can be used individually if you donβt
|
90
|
-
want to load the entire environment:
|
80
|
+
Behinds the scenes, use of `XDG.new` provides a convenient wrapper of `XDG::Environment.new` which, in turn, provides a unified API to the following objects:
|
91
81
|
|
92
82
|
[source,ruby]
|
93
83
|
----
|
@@ -97,14 +87,15 @@ data = XDG::Data.new
|
|
97
87
|
state = XDG::State.new
|
98
88
|
----
|
99
89
|
|
100
|
-
|
101
|
-
following messages:
|
90
|
+
Generally, use of `XDG.new` is all you need but knowing you can create a specialized instance of any aspect of the XDG specification can be handy for specific use cases. Additionally, the `cache`, `config`, `data`, and `state` objects share the same API which means you can send the following messages:
|
102
91
|
|
103
92
|
* `#home` - Answers the home directory as computed via the `$XDG_*_HOME` key.
|
104
93
|
* `#directories` - Answers an array directories as computed via the `$XDG_*_DIRS` key.
|
105
94
|
* `#all` - Answers an array of _all_ directories as computed from the combined `$XDG_*_HOME` and
|
106
95
|
`$XDG_*_DIRS` values (with `$XDG_*_HOME` prefixed at the start of the array).
|
107
96
|
|
97
|
+
The _computed_ value of each method is either the user-defined value of the key or the default value, per specification, when the key is not defined or empty. For more on this, scroll down to the _Variable Defaults_ section to learn more.
|
98
|
+
|
108
99
|
=== Examples
|
109
100
|
|
110
101
|
The following are examples of what you would see when playing around with the XDG objects within an
|
@@ -115,42 +106,42 @@ IRB console (taken from my own environment):
|
|
115
106
|
require "xdg"
|
116
107
|
|
117
108
|
# Initialization
|
118
|
-
|
109
|
+
xdg = XDG.new
|
119
110
|
cache = XDG::Cache.new
|
120
111
|
config = XDG::Config.new
|
121
112
|
data = XDG::Data.new
|
122
113
|
state = XDG::State.new
|
123
114
|
|
124
115
|
# Inspection
|
125
|
-
|
126
|
-
cache.inspect
|
127
|
-
config.inspect
|
128
|
-
data.inspect
|
129
|
-
state.inspect
|
116
|
+
xdg.inspect # "XDG_CACHE_HOME=/Users/demo/.cache XDG_CONFIG_HOME=/Users/demo/.config XDG_CONFIG_DIRS=/etc/xdg XDG_DATA_HOME=/Users/demo/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share XDG_STATE_HOME=/Users/demo/.local/state"
|
117
|
+
cache.inspect # "XDG_CACHE_HOME=/Users/demo/.cache"
|
118
|
+
config.inspect # "XDG_CONFIG_HOME=/Users/demo/.config XDG_CONFIG_DIRS=/etc/xdg"
|
119
|
+
data.inspect # "XDG_DATA_HOME=/Users/demo/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
|
120
|
+
state.inspect # "XDG_STATE_HOME=/Users/demo/.local/state"
|
130
121
|
|
131
122
|
# Paths
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
cache.home
|
140
|
-
cache.directories
|
141
|
-
cache.all
|
142
|
-
|
143
|
-
config.home
|
144
|
-
config.directories
|
145
|
-
config.all
|
146
|
-
|
147
|
-
data.home
|
148
|
-
data.directories
|
149
|
-
data.all
|
150
|
-
|
151
|
-
state.home
|
152
|
-
state.directories
|
153
|
-
state.all
|
123
|
+
xdg.cache_home # #<Pathname:/Users/demo/.cache>
|
124
|
+
xdg.config_home # #<Pathname:/Users/demo/.config>
|
125
|
+
xdg.config_dirs # [#<Pathname:/etc/xdg>]
|
126
|
+
xdg.data_home # #<Pathname:/Users/demo/.local/share>
|
127
|
+
xdg.data_dirs # [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
128
|
+
xdg.state_home # #<Pathname:/Users/demo/.local/state>
|
129
|
+
|
130
|
+
cache.home # #<Pathname:/Users/demo/.cache>
|
131
|
+
cache.directories # []
|
132
|
+
cache.all # [#<Pathname:/Users/demo/.cache>]
|
133
|
+
|
134
|
+
config.home # #<Pathname:/Users/demo/.config>
|
135
|
+
config.directories # [#<Pathname:/etc/xdg>]
|
136
|
+
config.all # [#<Pathname:/Users/demo/.config>, #<Pathname:/etc/xdg>]
|
137
|
+
|
138
|
+
data.home # #<Pathname:/Users/demo/.local/share>
|
139
|
+
data.directories # [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
140
|
+
data.all # [#<Pathname:/Users/demo/.local/share>, #<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
|
141
|
+
|
142
|
+
state.home # #<Pathname:/Users/demo/.local/state>
|
143
|
+
state.directories # []
|
144
|
+
state.all # [#<Pathname:/Users/demo/.local/state>]
|
154
145
|
----
|
155
146
|
|
156
147
|
As you can see from above, each XDG object answers back a `Pathname` which means you have the full
|
@@ -269,7 +260,7 @@ To contribute, run:
|
|
269
260
|
|
270
261
|
[source,bash]
|
271
262
|
----
|
272
|
-
git clone https://github.com/
|
263
|
+
git clone https://github.com/demo/xdg
|
273
264
|
cd xdg
|
274
265
|
bin/setup
|
275
266
|
----
|
data/lib/xdg/environment.rb
CHANGED
data/lib/xdg/paths/combined.rb
CHANGED
@@ -17,7 +17,7 @@ module XDG
|
|
17
17
|
|
18
18
|
def all = directories.prepend(*home)
|
19
19
|
|
20
|
-
def inspect = [initial_home.inspect, initial_directories.inspect].reject(&:empty?).join
|
20
|
+
def inspect = [initial_home.inspect, initial_directories.inspect].reject(&:empty?).join " "
|
21
21
|
|
22
22
|
private
|
23
23
|
|
data/lib/xdg/paths/directory.rb
CHANGED
@@ -22,15 +22,15 @@ module XDG
|
|
22
22
|
.map { |path| expand path }
|
23
23
|
end
|
24
24
|
|
25
|
-
def inspect = [key, dynamic.join(DELIMITER)].reject(&:empty?).join
|
25
|
+
def inspect = [key, dynamic.join(DELIMITER)].reject(&:empty?).join XDG::DELIMITER
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
29
|
attr_reader :pair, :environment
|
30
30
|
|
31
|
-
def key = String
|
31
|
+
def key = String pair.key
|
32
32
|
|
33
|
-
def value = String
|
33
|
+
def value = String pair.value
|
34
34
|
|
35
35
|
def expand(path) = Pathname(path).expand_path
|
36
36
|
end
|
data/lib/xdg/paths/home.rb
CHANGED
@@ -18,11 +18,11 @@ module XDG
|
|
18
18
|
@environment = environment
|
19
19
|
end
|
20
20
|
|
21
|
-
def default = expand
|
21
|
+
def default = expand String(value)
|
22
22
|
|
23
23
|
def dynamic = String(environment[key]).then { |path| path.empty? ? default : expand(path) }
|
24
24
|
|
25
|
-
def inspect = [pair.key, dynamic].compact.join
|
25
|
+
def inspect = [pair.key, dynamic].compact.join XDG::DELIMITER
|
26
26
|
|
27
27
|
private
|
28
28
|
|
@@ -30,7 +30,7 @@ module XDG
|
|
30
30
|
|
31
31
|
def expand(path) = home.join(path).expand_path
|
32
32
|
|
33
|
-
def home = Pathname
|
33
|
+
def home = Pathname environment.fetch(KEY)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/lib/xdg.rb
CHANGED
data/xdg.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "xdg"
|
5
|
-
spec.version = "7.0
|
5
|
+
spec.version = "7.1.0"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/xdg"
|
9
|
-
spec.summary = "
|
9
|
+
spec.summary = "An XDG Base Directory Specification implementation."
|
10
10
|
spec.license = "Hippocratic-2.1"
|
11
11
|
|
12
12
|
spec.metadata = {
|
data.tar.gz.sig
CHANGED
Binary file
|
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: 7.0
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-
|
38
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -85,8 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
|
-
rubygems_version: 3.4.
|
88
|
+
rubygems_version: 3.4.13
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
|
-
summary:
|
91
|
+
summary: An XDG Base Directory Specification implementation.
|
92
92
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|