xdg 7.0.3 β†’ 7.1.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: e84b7333763769c797591aea4308d932f0de3c1d4c4898847082bf03cb328430
4
- data.tar.gz: dc5e8bb9cffaf7eadf5e2e6b23dd8d7b9d3a3c46e4c69b3e31a541b863e74df8
3
+ metadata.gz: ba35d3c6fb994dd6fe78559246713b0becaf734c1a041ab06d3a676ae7d27594
4
+ data.tar.gz: 42637de1bfe11259c973be52845bf458f5f865254ace39cd08fcd1e66c17e8a9
5
5
  SHA512:
6
- metadata.gz: 1a2a79438b254a77e33511f02119eec868e81cb824c6b826edc73cf7fd4ea067f22cb19a321964ae0dfa6d56c6ab0de9e92d873e1280989fd4153720712cb02e
7
- data.tar.gz: 431e946e8d9983352c1f462bb50f680e7696b61041e01ec8b40a12ec239dd5c9d8657e2f84c7d48a2e0e14ab3ff188ba35255df41837e0a27ae12b800bc1f4d7
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
- https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html[XDG Base Directory
9
- Specification] for managing common configurations without polluting your dotfiles. XDG is great for
10
- command line interfaces or any application that needs a common configuration, cache, data, or
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::Environment` object that adheres to the _XDG Base Directory Specification_ with
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 `+XDG::Environment+` as follows:
67
+ To get up and running quickly, use `XDG.new` as follows:
73
68
 
74
69
  [source,ruby]
75
70
  ----
76
- xdg = XDG::Environment.new
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
- The _computed_ value, in this case, is either the user-defined value of the key or the default
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
- The `cache`, `config`, `data`, and `state` objects share the same API which means you can ask each the
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
- environment = XDG::Environment.new
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
- 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"
126
- cache.inspect # "XDG_CACHE_HOME=/Users/bkuhlmann/.cache"
127
- config.inspect # "XDG_CONFIG_HOME=/Users/bkuhlmann/.config XDG_CONFIG_DIRS=/etc/xdg"
128
- data.inspect # "XDG_DATA_HOME=/Users/bkuhlmann/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
129
- state.inspect # "XDG_STATE_HOME=/Users/bkuhlmann/.local/state"
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
- environment.cache_home # #<Pathname:/Users/bkuhlmann/.cache>
133
- environment.config_home # #<Pathname:/Users/bkuhlmann/.config>
134
- environment.config_dirs # [#<Pathname:/etc/xdg>]
135
- environment.data_home # #<Pathname:/Users/bkuhlmann/.local/share>
136
- environment.data_dirs # [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
137
- environment.state_home # #<Pathname:/Users/bkuhlmann/.local/state>
138
-
139
- cache.home # #<Pathname:/Users/bkuhlmann/.cache>
140
- cache.directories # []
141
- cache.all # [#<Pathname:/Users/bkuhlmann/.cache>]
142
-
143
- config.home # #<Pathname:/Users/bkuhlmann/.config>
144
- config.directories # [#<Pathname:/etc/xdg>]
145
- config.all # [#<Pathname:/Users/bkuhlmann/.config>, #<Pathname:/etc/xdg>]
146
-
147
- data.home # #<Pathname:/Users/bkuhlmann/.local/share>
148
- data.directories # [#<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
149
- data.all # [#<Pathname:/Users/bkuhlmann/.local/share>, #<Pathname:/usr/local/share>, #<Pathname:/usr/share>]
150
-
151
- state.home # #<Pathname:/Users/bkuhlmann/.local/state>
152
- state.directories # []
153
- state.all # [#<Pathname:/Users/bkuhlmann/.local/state>]
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/bkuhlmann/xdg
263
+ git clone https://github.com/demo/xdg
273
264
  cd xdg
274
265
  bin/setup
275
266
  ----
@@ -22,7 +22,7 @@ module XDG
22
22
 
23
23
  def state_home = state.home
24
24
 
25
- def inspect = "#{cache.inspect} #{config.inspect} #{data.inspect} #{state.inspect}"
25
+ def inspect = [cache, config, data, state].map(&:inspect).join " "
26
26
 
27
27
  private
28
28
 
@@ -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
 
@@ -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(XDG::DELIMITER)
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(pair.key)
31
+ def key = String pair.key
32
32
 
33
- def value = String(pair.value)
33
+ def value = String pair.value
34
34
 
35
35
  def expand(path) = Pathname(path).expand_path
36
36
  end
@@ -18,11 +18,11 @@ module XDG
18
18
  @environment = environment
19
19
  end
20
20
 
21
- def default = expand(String(value))
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(XDG::DELIMITER)
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(environment.fetch(KEY))
33
+ def home = Pathname environment.fetch(KEY)
34
34
  end
35
35
  end
36
36
  end
data/lib/xdg.rb CHANGED
@@ -10,6 +10,9 @@ require "xdg/paths/directory"
10
10
  require "xdg/paths/home"
11
11
  require "xdg/state"
12
12
 
13
+ # Main namespace.
13
14
  module XDG
14
15
  DELIMITER = "="
16
+
17
+ def self.new = Environment.new
15
18
  end
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.3"
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 = "Provides an implementation of the XDG Base Directory Specification."
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.3
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-04-30 00:00:00.000000000 Z
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.12
88
+ rubygems_version: 3.4.13
89
89
  signing_key:
90
90
  specification_version: 4
91
- summary: Provides an implementation of the XDG Base Directory Specification.
91
+ summary: An XDG Base Directory Specification implementation.
92
92
  test_files: []
metadata.gz.sig CHANGED
Binary file