runcom 4.2.1 → 5.0.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 +1 -1
- data.tar.gz.sig +0 -0
- data/README.md +11 -153
- data/lib/runcom.rb +1 -8
- data/lib/runcom/identity.rb +1 -1
- data/lib/runcom/paths/friendly.rb +4 -3
- metadata +25 -19
- metadata.gz.sig +0 -0
- data/lib/runcom/pair.rb +0 -10
- data/lib/runcom/paths/combined.rb +0 -31
- data/lib/runcom/paths/directory.rb +0 -31
- data/lib/runcom/paths/standard.rb +0 -39
- data/lib/runcom/xdg/cache.rb +0 -25
- data/lib/runcom/xdg/config.rb +0 -26
- data/lib/runcom/xdg/data.rb +0 -26
- data/lib/runcom/xdg/environment.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82272e07352edbead21370bbb09735ae0488a8284b66c87aa6ffd9758b3b88ca
|
4
|
+
data.tar.gz: dfb604f014545b8f7e809e132bd53fec84ce555b79f2b42e80178ec0d145220b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8748908614d8a56badb944120f49e8ae6c4817822d98f3f19a6e5163b4a6a7b721e4ed3588a0f8c7d8c667b5822b33ea1e091a0fe5a6e492942a2b9c8ff82f69
|
7
|
+
data.tar.gz: 4ac30ca2a5ce3b61afee3c4f1e3f4f7e4086a00134c57d2645342deec3efdd16d50298e0ab516814d45778499e9eafc66b4d4a2ff6872b34fff80bf26a31a3b5
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
}��>��Y��پ�S5�D"_��<V=&Wd-��]g���M�XFP�a@�_����@�E�t��'P-����N*��}�/�}����A�n��l�˅�nv�6|jXJ�S�r� ��m]1���Dm\3���Ɲx�XP�Qϵ�[,Лx��L�Ґ�6�&W��\ۖ�����k�z�{�:�0y���K>�"AW��Y��9��p����'�ou���d����L�U�!7���|�ۀ|-��4ӹ�ڙ�
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -9,11 +9,11 @@
|
|
9
9
|
[![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/129b7ea524a0f5a6a805/test_coverage)](https://codeclimate.com/github/bkuhlmann/runcom/test_coverage)
|
10
10
|
[![Circle CI Status](https://circleci.com/gh/bkuhlmann/runcom.svg?style=svg)](https://circleci.com/gh/bkuhlmann/runcom)
|
11
11
|
|
12
|
-
Runcom (
|
12
|
+
Runcom (short for [Run Command](https://en.wikipedia.org/wiki/Run_commands)) provides common
|
13
13
|
functionality for Command Line Interfaces (CLIs) in which to manage global, local, or multiple
|
14
14
|
caches, configurations, or data in general. It does this by leveraging the [XDG Base Directory
|
15
|
-
Specification](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
|
16
|
-
|
15
|
+
Specification](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) built atop
|
16
|
+
the [XDG](https://github.com/bkuhlmann/xdg) implementation.
|
17
17
|
|
18
18
|
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
19
19
|
|
@@ -23,16 +23,8 @@ further details.
|
|
23
23
|
- [Requirements](#requirements)
|
24
24
|
- [Setup](#setup)
|
25
25
|
- [Usage](#usage)
|
26
|
-
- [XDG](#xdg)
|
27
26
|
- [Overview](#overview)
|
28
|
-
- [Variable Defaults](#variable-defaults)
|
29
|
-
- [Variable Behavior](#variable-behavior)
|
30
|
-
- [`$XDG_*_DIRS`](#xdg__dirs)
|
31
|
-
- [`$XDG_*_HOME`](#xdg__home)
|
32
27
|
- [Variable Priority](#variable-priority)
|
33
|
-
- [Runcom](#runcom)
|
34
|
-
- [Overview](#overview-1)
|
35
|
-
- [Variable Priority](#variable-priority-1)
|
36
28
|
- [Configuration Specialization](#configuration-specialization)
|
37
29
|
- [Examples](#examples)
|
38
30
|
- [Tests](#tests)
|
@@ -47,15 +39,15 @@ further details.
|
|
47
39
|
|
48
40
|
## Features
|
49
41
|
|
50
|
-
-
|
51
|
-
|
42
|
+
- Wraps the [XDG](https://github.com/bkuhlmann/xdg) implementation which provides access to the
|
43
|
+
following environment variables:
|
52
44
|
- `$XDG_CACHE_HOME`
|
53
45
|
- `$XDG_CONFIG_HOME`
|
54
46
|
- `$XDG_CONFIG_DIRS`
|
55
47
|
- `$XDG_DATA_HOME`
|
56
48
|
- `$XDG_DATA_DIRS`
|
57
|
-
-
|
58
|
-
|
49
|
+
- Enhances the XDG cache, config, and data implementation. For the config, the following is
|
50
|
+
supported:
|
59
51
|
- Supports loading of CLI-specific [YAML](http://yaml.org) configuration file.
|
60
52
|
- Supports loading and merging of nested/complex configurations.
|
61
53
|
- Supports hash representation of configuration.
|
@@ -76,142 +68,8 @@ Add the following to your Gemfile:
|
|
76
68
|
|
77
69
|
## Usage
|
78
70
|
|
79
|
-
|
80
|
-
implementation.
|
81
|
-
|
82
|
-
### XDG
|
83
|
-
|
84
|
-
The following describes the embedded XDG implementation. It's worth noting there is a [XDG
|
85
|
-
Gem](https://github.com/rubyworks/xdg) which also implements the *XDG Base Directory Specification*
|
86
|
-
but hasn't been updated in ~6 years.
|
87
|
-
|
88
|
-
#### Overview
|
89
|
-
|
90
|
-
Provides an API that strictly adheres to the *XDG Base Directory Specification*. Usage:
|
91
|
-
|
92
|
-
xdg = Runcom::XDG::Environment.new
|
93
|
-
xdg.cache_home # <= Answers computed `$XDG_CACHE_HOME` value.
|
94
|
-
xdg.config_home # <= Answers computed `$XDG_CONFIG_HOME` value.
|
95
|
-
xdg.config_dirs # <= Answers computed `$XDG_CONFIG_DIRS` value.
|
96
|
-
xdg.data_home # <= Answers computed `$XDG_DATA_HOME` value.
|
97
|
-
xdg.data_dirs # <= Answers computed `$XDG_DATA_DIRS` value.
|
98
|
-
|
99
|
-
The *computed* value, in this case, is either the user-defined value of the key or the default
|
100
|
-
value, per specification, when the key is not defined or empty. For more on this, scroll down to the
|
101
|
-
*Variable Defaults* section to learn more.
|
102
|
-
|
103
|
-
The `Runcom::XDG::Environment` wraps the following objects which can be used individually if you
|
104
|
-
don't want to load the entire environment:
|
105
|
-
|
106
|
-
cache = Runcom::XDG::Cache.new
|
107
|
-
config = Runcom::XDG::Config.new
|
108
|
-
data = Runcom::XDG::Data.new
|
109
|
-
|
110
|
-
The `cache`, `config`, and `data` objects share the same API which means you can ask each the
|
111
|
-
following messages:
|
112
|
-
|
113
|
-
- `#home` - Answers the home directory as computed via the `$XDG_*_HOME` key.
|
114
|
-
- `#directories` - Answers an array directories as computed via the `$XDG_*_DIRS` key.
|
115
|
-
- `#all` - Answers an array of *all* directories as computed from the combined `$XDG_*_HOME` and
|
116
|
-
`$XDG_*_DIRS` values (with `$XDG_*_HOME` prefixed at the start of the array).
|
117
|
-
|
118
|
-
#### Variable Defaults
|
119
|
-
|
120
|
-
The *XDG Base Directory Specification* defines environment variables and associated default values
|
121
|
-
when not defined or empty. The following defaults, per specification, are implemented by the
|
122
|
-
`Runcom::XDG` objects:
|
123
|
-
|
124
|
-
- `$XDG_CACHE_HOME="$HOME/.cache"`
|
125
|
-
- `$XDG_CONFIG_HOME="$HOME/.config"`
|
126
|
-
- `$XDG_CONFIG_DIRS="/etc/xdg"`
|
127
|
-
- `$XDG_DATA_HOME="$HOME/.local/share"`
|
128
|
-
- `$XDG_DATA_DIRS="/usr/local/share/:/usr/share/"`
|
129
|
-
- `$XDG_RUNTIME_DIR`
|
130
|
-
|
131
|
-
The `$XDG_RUNTIME_DIR` deserves special mention as it's not, *currently*, implemented as part of
|
132
|
-
this gem because it is more user/environment specific. Here is how the `$XDG_RUNTIME_DIR` is meant
|
133
|
-
to be used should you choose to use it:
|
134
|
-
|
135
|
-
- *Must* reference user-specific non-essential runtime files and other file objects (such as
|
136
|
-
sockets, named pipes, etc.)
|
137
|
-
- *Must* be owned by the user with *only* the user having read and write access to it.
|
138
|
-
- *Must* have a Unix access mode of `0700`.
|
139
|
-
- *Must* be bound to the user when logging in.
|
140
|
-
- *Must* be removed when the user logs out.
|
141
|
-
- *Must* be pointed to the same directory when the user logs in more than once.
|
142
|
-
- *Must* exist from first login to last logout on the system and not removed in between.
|
143
|
-
- *Must* not allow files in the directory to survive reboot or a full logout/login cycle.
|
144
|
-
- *Must* keep the directory on the local file system and not shared with any other file systems.
|
145
|
-
- *Must* keep the directory fully-featured by the standards of the operating system. Specifically,
|
146
|
-
on Unix-like operating systems AF_UNIX sockets, symbolic links, hard links, proper permissions,
|
147
|
-
file locking, sparse files, memory mapping, file change notifications, a reliable hard link count
|
148
|
-
must be supported, and no restrictions on the file name character set should be imposed. Files in
|
149
|
-
this directory *may* be subjected to periodic clean-up. To ensure files are not removed,
|
150
|
-
they should have their access time timestamp modified at least once every 6 hours of monotonic
|
151
|
-
time or the 'sticky' bit should be set on the file.
|
152
|
-
- When not set, applications should fall back to a replacement directory with similar capabilities
|
153
|
-
and print a warning message. Applications should use this directory for communication and
|
154
|
-
synchronization purposes and should not place larger files in it, since it might reside in runtime
|
155
|
-
memory and cannot necessarily be swapped out to disk.
|
156
|
-
|
157
|
-
#### Variable Behavior
|
158
|
-
|
159
|
-
The behavior of most XDG environment variables can be lumped into two categories:
|
160
|
-
|
161
|
-
- `$XDG_*_HOME`
|
162
|
-
- `$XDG_*_DIRS`
|
163
|
-
|
164
|
-
Each is described in detail below.
|
165
|
-
|
166
|
-
##### `$XDG_*_DIRS`
|
167
|
-
|
168
|
-
These variables are used to define a colon (`:`) delimited list of directories. Order is important
|
169
|
-
as the first directory defined will take precedent over the following directory and so forth. For
|
170
|
-
example, here is a situation where the `XDG_CONFIG_DIRS` key has a custom value:
|
171
|
-
|
172
|
-
XDG_CONFIG_DIRS="/example/one/.config:/example/two/.settings:/example/three/.configuration"
|
173
|
-
|
174
|
-
# Yields the following, colon delimited, array:
|
175
|
-
[
|
176
|
-
"/example/one/.config",
|
177
|
-
"/example/two/.settings",
|
178
|
-
"/example/three/.configuration"
|
179
|
-
]
|
180
|
-
|
181
|
-
In the above example, the `"/example/one/.config"` path takes *highest* priority since it was
|
182
|
-
defined first.
|
183
|
-
|
184
|
-
##### `$XDG_*_HOME`
|
185
|
-
|
186
|
-
These variables take precidence over the corresponding `$XDG_*_DIRS` environment variables. Using a
|
187
|
-
modified version of the `$XDG_*_DIRS` example, shown above, we could have the following setup:
|
188
|
-
|
189
|
-
XDG_CONFIG_HOME="/example/priority"
|
190
|
-
XDG_CONFIG_DIRS="/example/one/.config:/example/two/.settings"
|
191
|
-
|
192
|
-
# Yields the following, colon delimited, array:
|
193
|
-
[
|
194
|
-
"/example/priority",
|
195
|
-
"/example/one/.config",
|
196
|
-
"/example/two/.settings"
|
197
|
-
]
|
198
|
-
|
199
|
-
Due to `XDG_CONFIG_HOME` taking precidence over the `XDG_CONFIG_DIRS`, the path with the *highest*
|
200
|
-
priority in this example is: `"/example/priority"`.
|
201
|
-
|
202
|
-
#### Variable Priority
|
203
|
-
|
204
|
-
Path precedence is determined in the following order (with the first taking highest priority):
|
205
|
-
|
206
|
-
1. `$XDG_*_HOME` - Will be used if defined. Otherwise, falls back to specification default.
|
207
|
-
1. `$XDG_*_DIRS` - Iterates through directories in order defined (with first taking highest
|
208
|
-
priority). Otherwise, falls back to specification default.
|
209
|
-
|
210
|
-
### Runcom
|
211
|
-
|
212
|
-
Provides wrapper objects around the `XDG` objects which extends and enhances beyond what is found in
|
213
|
-
the *XDG Base Directory Specification*. This includes preference of local over global configurations
|
214
|
-
by default as well as other conveniences.
|
71
|
+
The following describes the enhancements built atop the [XDG](https://github.com/bkuhlmann/xdg)
|
72
|
+
implementation.
|
215
73
|
|
216
74
|
#### Overview
|
217
75
|
|
@@ -244,7 +102,7 @@ Path precedence is determined in the following order (with the first taking high
|
|
244
102
|
|
245
103
|
The `Runcom::Config` deserves additional highlighting as it provides support for loading custom CLI
|
246
104
|
configurations directly from the command line or from custom locations. It is meant to be used
|
247
|
-
within your
|
105
|
+
within your program(s).
|
248
106
|
|
249
107
|
An object can be initialized as follows:
|
250
108
|
|
@@ -280,7 +138,7 @@ For further details, study the public interface as provided by the
|
|
280
138
|
|
281
139
|
### Examples
|
282
140
|
|
283
|
-
|
141
|
+
Examples of gems built atop this gem are:
|
284
142
|
|
285
143
|
- [Gemsmith](https://github.com/bkuhlmann/gemsmith) - A command line interface for smithing new Ruby
|
286
144
|
gems.
|
data/lib/runcom.rb
CHANGED
@@ -1,17 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "xdg"
|
3
4
|
require "runcom/identity"
|
4
5
|
require "runcom/errors/base"
|
5
6
|
require "runcom/errors/syntax"
|
6
|
-
require "runcom/pair"
|
7
|
-
require "runcom/paths/standard"
|
8
7
|
require "runcom/paths/friendly"
|
9
|
-
require "runcom/paths/directory"
|
10
|
-
require "runcom/paths/combined"
|
11
|
-
require "runcom/xdg/config"
|
12
|
-
require "runcom/xdg/data"
|
13
|
-
require "runcom/xdg/cache"
|
14
|
-
require "runcom/xdg/environment"
|
15
8
|
require "runcom/config"
|
16
9
|
require "runcom/cache"
|
17
10
|
require "runcom/data"
|
data/lib/runcom/identity.rb
CHANGED
@@ -12,12 +12,13 @@ module Runcom
|
|
12
12
|
delegate %i[key value default] => :standard
|
13
13
|
|
14
14
|
def initialize pair, environment = ENV
|
15
|
-
@standard = Standard.new pair, environment
|
15
|
+
@standard = XDG::Paths::Standard.new pair, environment
|
16
16
|
end
|
17
17
|
|
18
18
|
def dynamic
|
19
|
-
|
20
|
-
|
19
|
+
String(value).then do |path|
|
20
|
+
File.exist?(path) ? Pathname(path).expand_path : standard.dynamic
|
21
|
+
end
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runcom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
|
29
29
|
y84=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2019-
|
31
|
+
date: 2019-06-01 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: refinements
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '6.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: xdg
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: bundler-audit
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,14 +176,14 @@ dependencies:
|
|
162
176
|
requirements:
|
163
177
|
- - "~>"
|
164
178
|
- !ruby/object:Gem::Version
|
165
|
-
version: '5.
|
179
|
+
version: '5.4'
|
166
180
|
type: :development
|
167
181
|
prerelease: false
|
168
182
|
version_requirements: !ruby/object:Gem::Requirement
|
169
183
|
requirements:
|
170
184
|
- - "~>"
|
171
185
|
- !ruby/object:Gem::Version
|
172
|
-
version: '5.
|
186
|
+
version: '5.4'
|
173
187
|
- !ruby/object:Gem::Dependency
|
174
188
|
name: rspec
|
175
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,42 +204,42 @@ dependencies:
|
|
190
204
|
requirements:
|
191
205
|
- - "~>"
|
192
206
|
- !ruby/object:Gem::Version
|
193
|
-
version: '0.
|
207
|
+
version: '0.69'
|
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: '0.
|
214
|
+
version: '0.69'
|
201
215
|
- !ruby/object:Gem::Dependency
|
202
216
|
name: rubocop-performance
|
203
217
|
requirement: !ruby/object:Gem::Requirement
|
204
218
|
requirements:
|
205
219
|
- - "~>"
|
206
220
|
- !ruby/object:Gem::Version
|
207
|
-
version: '1.
|
221
|
+
version: '1.3'
|
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: '1.
|
228
|
+
version: '1.3'
|
215
229
|
- !ruby/object:Gem::Dependency
|
216
230
|
name: rubocop-rspec
|
217
231
|
requirement: !ruby/object:Gem::Requirement
|
218
232
|
requirements:
|
219
233
|
- - "~>"
|
220
234
|
- !ruby/object:Gem::Version
|
221
|
-
version: '1.
|
235
|
+
version: '1.33'
|
222
236
|
type: :development
|
223
237
|
prerelease: false
|
224
238
|
version_requirements: !ruby/object:Gem::Requirement
|
225
239
|
requirements:
|
226
240
|
- - "~>"
|
227
241
|
- !ruby/object:Gem::Version
|
228
|
-
version: '1.
|
242
|
+
version: '1.33'
|
229
243
|
- !ruby/object:Gem::Dependency
|
230
244
|
name: simplecov
|
231
245
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,15 +272,7 @@ files:
|
|
258
272
|
- lib/runcom/errors/base.rb
|
259
273
|
- lib/runcom/errors/syntax.rb
|
260
274
|
- lib/runcom/identity.rb
|
261
|
-
- lib/runcom/pair.rb
|
262
|
-
- lib/runcom/paths/combined.rb
|
263
|
-
- lib/runcom/paths/directory.rb
|
264
275
|
- lib/runcom/paths/friendly.rb
|
265
|
-
- lib/runcom/paths/standard.rb
|
266
|
-
- lib/runcom/xdg/cache.rb
|
267
|
-
- lib/runcom/xdg/config.rb
|
268
|
-
- lib/runcom/xdg/data.rb
|
269
|
-
- lib/runcom/xdg/environment.rb
|
270
276
|
homepage: https://github.com/bkuhlmann/runcom
|
271
277
|
licenses:
|
272
278
|
- Apache-2.0
|
@@ -292,5 +298,5 @@ requirements: []
|
|
292
298
|
rubygems_version: 3.0.3
|
293
299
|
signing_key:
|
294
300
|
specification_version: 4
|
295
|
-
summary:
|
301
|
+
summary: An XDG enhanced run command manager for command line interfaces (CLIs).
|
296
302
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/runcom/pair.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "pathname"
|
4
|
-
|
5
|
-
module Runcom
|
6
|
-
module Paths
|
7
|
-
# The combined home and directories for environment.
|
8
|
-
class Combined
|
9
|
-
def initialize initial_home, initial_directories
|
10
|
-
@initial_home = initial_home
|
11
|
-
@initial_directories = initial_directories
|
12
|
-
end
|
13
|
-
|
14
|
-
def home
|
15
|
-
initial_home.dynamic
|
16
|
-
end
|
17
|
-
|
18
|
-
def directories
|
19
|
-
initial_directories.dynamic
|
20
|
-
end
|
21
|
-
|
22
|
-
def all
|
23
|
-
directories.prepend home
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :initial_home, :initial_directories
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "pathname"
|
4
|
-
|
5
|
-
module Runcom
|
6
|
-
module Paths
|
7
|
-
# A collection of XDG directories with a strict adherence to the XDG specification.
|
8
|
-
class Directory
|
9
|
-
DELIMITER = ":"
|
10
|
-
|
11
|
-
def initialize pair, environment = ENV
|
12
|
-
@pair = pair
|
13
|
-
@environment = environment
|
14
|
-
end
|
15
|
-
|
16
|
-
def default
|
17
|
-
String(pair.value).split(DELIMITER).map { |path| Pathname(path).expand_path }
|
18
|
-
end
|
19
|
-
|
20
|
-
def dynamic
|
21
|
-
environment.fetch(pair.key, String(pair.value)).split(DELIMITER).uniq.map do |path|
|
22
|
-
Pathname(path).expand_path
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :pair, :environment
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "forwardable"
|
4
|
-
require "pathname"
|
5
|
-
|
6
|
-
module Runcom
|
7
|
-
module Paths
|
8
|
-
# A XDG home path with a strict adherence to the XDG specification.
|
9
|
-
class Standard
|
10
|
-
extend Forwardable
|
11
|
-
|
12
|
-
HOME_KEY = "HOME"
|
13
|
-
|
14
|
-
delegate %i[key value] => :pair
|
15
|
-
|
16
|
-
def initialize pair, environment = ENV
|
17
|
-
@pair = pair
|
18
|
-
@environment = environment
|
19
|
-
end
|
20
|
-
|
21
|
-
def default
|
22
|
-
home.join(String(value)).expand_path
|
23
|
-
end
|
24
|
-
|
25
|
-
def dynamic
|
26
|
-
path = String environment[key]
|
27
|
-
path.empty? ? default : home.join(path).expand_path
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
attr_reader :pair, :environment
|
33
|
-
|
34
|
-
def home
|
35
|
-
Pathname environment.fetch(HOME_KEY)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/runcom/xdg/cache.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "forwardable"
|
4
|
-
|
5
|
-
module Runcom
|
6
|
-
module XDG
|
7
|
-
# A XDG cache that adheres to specification defaults.
|
8
|
-
class Cache
|
9
|
-
extend Forwardable
|
10
|
-
|
11
|
-
HOME_PAIR = Pair.new("XDG_CACHE_HOME", ".cache").freeze
|
12
|
-
|
13
|
-
delegate %i[home directories all] => :combined
|
14
|
-
|
15
|
-
def initialize home: Paths::Standard, directories: Paths::Directory, environment: ENV
|
16
|
-
@combined = Paths::Combined.new home.new(HOME_PAIR, environment),
|
17
|
-
directories.new(Runcom::Pair.new, environment)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :combined
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/runcom/xdg/config.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "forwardable"
|
4
|
-
|
5
|
-
module Runcom
|
6
|
-
module XDG
|
7
|
-
# A XDG configuration that adheres to specification defaults.
|
8
|
-
class Config
|
9
|
-
extend Forwardable
|
10
|
-
|
11
|
-
HOME_PAIR = Pair.new("XDG_CONFIG_HOME", ".config").freeze
|
12
|
-
DIRS_PAIR = Pair.new("XDG_CONFIG_DIRS", "/etc/xdg").freeze
|
13
|
-
|
14
|
-
delegate %i[home directories all] => :combined
|
15
|
-
|
16
|
-
def initialize home: Paths::Standard, directories: Paths::Directory, environment: ENV
|
17
|
-
@combined = Paths::Combined.new home.new(HOME_PAIR, environment),
|
18
|
-
directories.new(DIRS_PAIR, environment)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
attr_reader :combined
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/runcom/xdg/data.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "forwardable"
|
4
|
-
|
5
|
-
module Runcom
|
6
|
-
module XDG
|
7
|
-
# XDG data that adheres to specification defaults.
|
8
|
-
class Data
|
9
|
-
extend Forwardable
|
10
|
-
|
11
|
-
HOME_PAIR = Pair.new("XDG_DATA_HOME", ".local/share").freeze
|
12
|
-
DIRS_PAIR = Pair.new("XDG_DATA_DIRS", "/usr/local/share:/usr/share").freeze
|
13
|
-
|
14
|
-
delegate %i[home directories all] => :combined
|
15
|
-
|
16
|
-
def initialize home: Paths::Standard, directories: Paths::Directory, environment: ENV
|
17
|
-
@combined = Paths::Combined.new home.new(HOME_PAIR, environment),
|
18
|
-
directories.new(DIRS_PAIR, environment)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
attr_reader :combined
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Runcom
|
4
|
-
module XDG
|
5
|
-
# A XDG environment that provides access to all variables.
|
6
|
-
class Environment
|
7
|
-
def initialize home: Paths::Standard, directories: Paths::Directory, environment: ENV
|
8
|
-
@cache = Cache.new home: home, directories: directories, environment: environment
|
9
|
-
@config = Config.new home: home, directories: directories, environment: environment
|
10
|
-
@data = Data.new home: home, directories: directories, environment: environment
|
11
|
-
end
|
12
|
-
|
13
|
-
def cache_home
|
14
|
-
cache.home
|
15
|
-
end
|
16
|
-
|
17
|
-
def config_home
|
18
|
-
config.home
|
19
|
-
end
|
20
|
-
|
21
|
-
def config_dirs
|
22
|
-
config.directories
|
23
|
-
end
|
24
|
-
|
25
|
-
def data_home
|
26
|
-
data.home
|
27
|
-
end
|
28
|
-
|
29
|
-
def data_dirs
|
30
|
-
data.directories
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
attr_reader :cache, :config, :data
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|