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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30975075f268b1c985edbdb4a76aca31ad0770b106925f5822b802f5f0291223
4
- data.tar.gz: d2a3c16503d6296982f8a300e1ece4dcecfa0dc7da885849543616dba044eccb
3
+ metadata.gz: f1a337c5649d81e8d7421794ff85c904aef168e84dc713ddb146a5959f8f7e7e
4
+ data.tar.gz: 8e5d15918077dff3d4bb0b1edd70ae413a9f975a559fb72dd6d10b2126ac4bad
5
5
  SHA512:
6
- metadata.gz: f74d0255a577f818b7df8c0c5d3f4e7c7730dca69e4e94bb6cc40ca75ece68d1f20634637819e56d957b574571d467fbe6b908d696385728af545a57e3155b55
7
- data.tar.gz: 74863dba2cd460a07d141d053d38650c8c23719df7d9de5a4a7964134f6d0dc032ba4434c2eb9a6d62345241fe6b1ed57f2b054d2f2a1565637726e8beda71eb
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.5.0"
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"
data.tar.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
- H�oY��\���l�9�Ϸ!OҪ�t��/��u&W~��:2/9�M��f�:��^��6eD� �Ɍ��"1v�$��S~R�V��N�Oݺ�m2���N�}s2?�A,�o��DT
2
- �+�DsEZ�E�ۿz��RӠ����P&�.rf���`�bSr6�&�orK��Cl0�jz������n�����7����:D(JY,����[_#Mr3�]ӗˁF#|zqb���3��%��t���wv�^
1
+ �:�p��� �͝g�����!���Wc�B���J
2
+ b+�=�Z��6O�1ҙ8a6$�a��'�QG��_�E�g�,�gF����M�P�x�0�JV�t��H���t��z��2��;�Ӗ7�%�(*�φI����Xws V4w$//��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.5.0
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-07-17 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:
@@ -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.18
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
- A7�}ȿ�00^�=���K�� ���al+��u�""��a7/10 ���:U�Ep��� �J*�0,�@�U�)�1��ɻ�:���)�
2
- &5�8��t+َaǘ'TV�a���Z>㳨������@�I���J+Em���r���#n@i��{�
1
+ t\3X���/m���oֵR4dsI��� #�.pd��#.+i9pL�.��/(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;(