xdg 6.3.3 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f743d4c33425b9faee440f4fc818cb97ffb352860aea21e1ec590ab6c3e842c7
4
- data.tar.gz: 5071b91c337b342c90e307c47d68b6c5fce9a99a34239aa68108aa61eea2fa6c
3
+ metadata.gz: f1a337c5649d81e8d7421794ff85c904aef168e84dc713ddb146a5959f8f7e7e
4
+ data.tar.gz: 8e5d15918077dff3d4bb0b1edd70ae413a9f975a559fb72dd6d10b2126ac4bad
5
5
  SHA512:
6
- metadata.gz: ef0ad8bb2c923c21ab2f6ddd052589365f1713cd2966b874f0c7905930f65f4768c9796004149626c96ca4bb9148f1341bfd3d1e4d6e741e19e874f77320d319
7
- data.tar.gz: 1982eded991e16bb3db371fdca99442e9cb6e61238e557669e0c8b8583205a22197e63906a4266c96d438535ca18dc72786438092200e3183831a3377576119f
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 XDG implementation.
52
+ The following describes how to use this implementation.
52
53
 
53
- === Overview
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 # <= Answers computed `$XDG_CACHE_HOME` value.
61
- xdg.config_home # <= Answers computed `$XDG_CONFIG_HOME` value.
62
- xdg.config_dirs # <= Answers computed `$XDG_CONFIG_DIRS` value.
63
- xdg.data_home # <= Answers computed `$XDG_DATA_HOME` value.
64
- xdg.data_dirs # <= Answers computed `$XDG_DATA_DIRS` value.
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 `data` objects share the same API which means you can ask each the
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 # => 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
106
- cache.inspect # => "XDG_CACHE_HOME=/Users/bkuhlmann/.cache"
107
- config.inspect # => "XDG_CONFIG_HOME=/Users/bkuhlmann/.config XDG_CONFIG_DIRS=/etc/xdg"
108
- data.inspect # => "XDG_DATA_HOME=/Users/bkuhlmann/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
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 # => #<Pathname:/Users/bkuhlmann/.cache>
112
- environment.config_home # => #<Pathname:/Users/bkuhlmann/.config>
113
- environment.config_dirs # => [#<Pathname:/etc/xdg>]
114
- environment.data_home # => #<Pathname:/Users/bkuhlmann/.local/share>
115
- environment.data_dirs # => [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
116
-
117
- cache.home # => #<Pathname:/Users/bkuhlmann/.cache>
118
- cache.directories # => []
119
- cache.all # => [#<Pathname:/Users/bkuhlmann/.cache>]
120
-
121
- config.home # => #<Pathname:/Users/bkuhlmann/.config>
122
- config.directories # => [#<Pathname:/etc/xdg>]
123
- config.all # => [#<Pathname:/Users/bkuhlmann/.config>, #<Pathname:/etc/xdg>]
124
-
125
- data.home # => #<Pathname:/Users/bkuhlmann/.local/share>
126
- data.directories # => [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
127
- data.all # => [#<Pathname:/Users/bkuhlmann/.local/share>, #<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
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
- ==== `$XDG_*_DIRS`
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
- ==== `$XDG_*_HOME`
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
@@ -3,6 +3,7 @@
3
3
  require "forwardable"
4
4
 
5
5
  module XDG
6
+ # Provides cache support.
6
7
  class Cache
7
8
  extend Forwardable
8
9
 
data/lib/xdg/config.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "forwardable"
4
4
 
5
5
  module XDG
6
+ # Provides configuration support.
6
7
  class Config
7
8
  extend Forwardable
8
9
 
data/lib/xdg/data.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "forwardable"
4
4
 
5
5
  module XDG
6
+ # Provides data support.
6
7
  class Data
7
8
  extend Forwardable
8
9
 
@@ -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 home:, directories:, environment:
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 inspect = "#{cache.inspect} #{config.inspect} #{data.inspect}"
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
@@ -7,4 +7,5 @@ require "xdg/paths/combined"
7
7
  require "xdg/config"
8
8
  require "xdg/data"
9
9
  require "xdg/cache"
10
+ require "xdg/state"
10
11
  require "xdg/environment"
data/xdg.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "xdg"
5
- spec.version = "6.3.3"
5
+ spec.version = "6.6.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://www.alchemists.io/projects/xdg"
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
13
13
  "bug_tracker_uri" => "https://github.com/bkuhlmann/xdg/issues",
14
14
  "changelog_uri" => "https://www.alchemists.io/projects/xdg/versions",
15
15
  "documentation_uri" => "https://www.alchemists.io/projects/xdg",
16
+ "funding_uri" => "https://github.com/sponsors/bkuhlmann",
16
17
  "label" => "XDG",
17
18
  "rubygems_mfa_required" => "true",
18
19
  "source_code_uri" => "https://github.com/bkuhlmann/xdg"
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: 6.3.3
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-04-23 00:00:00.000000000 Z
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:
@@ -58,6 +59,7 @@ metadata:
58
59
  bug_tracker_uri: https://github.com/bkuhlmann/xdg/issues
59
60
  changelog_uri: https://www.alchemists.io/projects/xdg/versions
60
61
  documentation_uri: https://www.alchemists.io/projects/xdg
62
+ funding_uri: https://github.com/sponsors/bkuhlmann
61
63
  label: XDG
62
64
  rubygems_mfa_required: 'true'
63
65
  source_code_uri: https://github.com/bkuhlmann/xdg
@@ -76,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
78
  - !ruby/object:Gem::Version
77
79
  version: '0'
78
80
  requirements: []
79
- rubygems_version: 3.3.12
81
+ rubygems_version: 3.3.22
80
82
  signing_key:
81
83
  specification_version: 4
82
84
  summary: Provides an implementation of the XDG Base Directory Specification.
metadata.gz.sig CHANGED
Binary file