xdg 7.0.2 β 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 +59 -52
- 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`
|
@@ -33,18 +28,34 @@ access to the following environment settings:
|
|
33
28
|
|
34
29
|
== Setup
|
35
30
|
|
36
|
-
To install, run:
|
31
|
+
To install _with_ security, run:
|
32
|
+
|
33
|
+
[source,bash]
|
34
|
+
----
|
35
|
+
# π‘ Skip this line if you already have the public certificate installed.
|
36
|
+
gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem)
|
37
|
+
gem install xdg --trust-policy HighSecurity
|
38
|
+
----
|
39
|
+
|
40
|
+
To install _without_ security, run:
|
37
41
|
|
38
42
|
[source,bash]
|
39
43
|
----
|
40
44
|
gem install xdg
|
41
45
|
----
|
42
46
|
|
43
|
-
|
47
|
+
You can also add the gem directly to your project:
|
48
|
+
|
49
|
+
[source,bash]
|
50
|
+
----
|
51
|
+
bundle add xdg
|
52
|
+
----
|
53
|
+
|
54
|
+
Once the gem is installed, you only need to require it:
|
44
55
|
|
45
56
|
[source,ruby]
|
46
57
|
----
|
47
|
-
|
58
|
+
require "xdg"
|
48
59
|
----
|
49
60
|
|
50
61
|
== Usage
|
@@ -53,11 +64,11 @@ The following describes how to use this implementation.
|
|
53
64
|
|
54
65
|
=== Objects
|
55
66
|
|
56
|
-
To get up and running quickly, use
|
67
|
+
To get up and running quickly, use `XDG.new` as follows:
|
57
68
|
|
58
69
|
[source,ruby]
|
59
70
|
----
|
60
|
-
xdg = XDG
|
71
|
+
xdg = XDG.new
|
61
72
|
xdg.cache_home # Answers computed `$XDG_CACHE_HOME` value.
|
62
73
|
xdg.config_home # Answers computed `$XDG_CONFIG_HOME` value.
|
63
74
|
xdg.config_dirs # Answers computed `$XDG_CONFIG_DIRS` value.
|
@@ -66,12 +77,7 @@ xdg.data_dirs # Answers computed `$XDG_DATA_DIRS` value.
|
|
66
77
|
xdg.state_home # Answers computed `$XDG_STATE_HOME` value.
|
67
78
|
----
|
68
79
|
|
69
|
-
|
70
|
-
value, per specification, when the key is not defined or empty. For more on this, scroll down to the
|
71
|
-
_Variable Defaults_ section to learn more.
|
72
|
-
|
73
|
-
The `XDG::Environment` wraps the following objects which can be used individually if you donβt
|
74
|
-
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:
|
75
81
|
|
76
82
|
[source,ruby]
|
77
83
|
----
|
@@ -81,14 +87,15 @@ data = XDG::Data.new
|
|
81
87
|
state = XDG::State.new
|
82
88
|
----
|
83
89
|
|
84
|
-
|
85
|
-
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:
|
86
91
|
|
87
92
|
* `#home` - Answers the home directory as computed via the `$XDG_*_HOME` key.
|
88
93
|
* `#directories` - Answers an array directories as computed via the `$XDG_*_DIRS` key.
|
89
94
|
* `#all` - Answers an array of _all_ directories as computed from the combined `$XDG_*_HOME` and
|
90
95
|
`$XDG_*_DIRS` values (with `$XDG_*_HOME` prefixed at the start of the array).
|
91
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
|
+
|
92
99
|
=== Examples
|
93
100
|
|
94
101
|
The following are examples of what you would see when playing around with the XDG objects within an
|
@@ -99,42 +106,42 @@ IRB console (taken from my own environment):
|
|
99
106
|
require "xdg"
|
100
107
|
|
101
108
|
# Initialization
|
102
|
-
|
109
|
+
xdg = XDG.new
|
103
110
|
cache = XDG::Cache.new
|
104
111
|
config = XDG::Config.new
|
105
112
|
data = XDG::Data.new
|
106
113
|
state = XDG::State.new
|
107
114
|
|
108
115
|
# Inspection
|
109
|
-
|
110
|
-
cache.inspect
|
111
|
-
config.inspect
|
112
|
-
data.inspect
|
113
|
-
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"
|
114
121
|
|
115
122
|
# Paths
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
cache.home
|
124
|
-
cache.directories
|
125
|
-
cache.all
|
126
|
-
|
127
|
-
config.home
|
128
|
-
config.directories
|
129
|
-
config.all
|
130
|
-
|
131
|
-
data.home
|
132
|
-
data.directories
|
133
|
-
data.all
|
134
|
-
|
135
|
-
state.home
|
136
|
-
state.directories
|
137
|
-
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>]
|
138
145
|
----
|
139
146
|
|
140
147
|
As you can see from above, each XDG object answers back a `Pathname` which means you have the full
|
@@ -253,7 +260,7 @@ To contribute, run:
|
|
253
260
|
|
254
261
|
[source,bash]
|
255
262
|
----
|
256
|
-
git clone https://github.com/
|
263
|
+
git clone https://github.com/demo/xdg
|
257
264
|
cd xdg
|
258
265
|
bin/setup
|
259
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
|