xdg 7.0.2 β†’ 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: 97e985af713c47c149f2d5bd336401cfb68afbac4bc08c51af7cd7b0df07b0cd
4
- data.tar.gz: 07f936d37e165c23935db2cfde3e1e3a261012fcd14069e80f0655831db8df3c
3
+ metadata.gz: ba35d3c6fb994dd6fe78559246713b0becaf734c1a041ab06d3a676ae7d27594
4
+ data.tar.gz: 42637de1bfe11259c973be52845bf458f5f865254ace39cd08fcd1e66c17e8a9
5
5
  SHA512:
6
- metadata.gz: ec73085d2e22cc7c441b087a55b9de75907d42778fb1bb116d46d8bdb44afbf2711be0035a46bc8c88bbfc6c407be9d4ff0ba687ba26211d375e3879ed66ac97
7
- data.tar.gz: a567f0e4dd2863a559c3fd8bb3c665d6f56f3554c7f98a471c5b7dcc807263c2fac2e3c0e29f33b1be50504f531be85d9364ede186881112eb0fcae126c42299
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`
@@ -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
- Add the following to your Gemfile:
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
- gem "xdg"
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 `+XDG::Environment+` as follows:
67
+ To get up and running quickly, use `XDG.new` as follows:
57
68
 
58
69
  [source,ruby]
59
70
  ----
60
- xdg = XDG::Environment.new
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
- The _computed_ value, in this case, is either the user-defined value of the key or the default
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
- The `cache`, `config`, `data`, and `state` objects share the same API which means you can ask each the
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
- environment = XDG::Environment.new
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
- 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"
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
- 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>]
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/bkuhlmann/xdg
263
+ git clone https://github.com/demo/xdg
257
264
  cd xdg
258
265
  bin/setup
259
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.2"
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.2
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-03-22 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.9
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