xdg 2.2.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/xdg.rb CHANGED
@@ -1,45 +1,11 @@
1
- # XDG Base Directory Standard
2
- #
3
- # This provides a conveient library for conforming to the
4
- # XDG Base Directory Standard.
5
- #
6
- # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
7
- #
8
- # Some important clarifications, not made clear by the above specification.
9
- #
10
- # The data directories are for "read-only" files. In other words once
11
- # something is put there, it should only be read, and never written to
12
- # by a program. (Generally speaking only users or package managers should
13
- # be adding, changing or removing files from the data locations.)
14
- #
15
- # The config locations are where you store files that may change,
16
- # and effect your applications depending on their content. This is like
17
- # etc/ in the FHS, but alterable by end users and end user programs,
18
- # not just root and sudo admin scripts.
19
- #
20
- # The cache locations stores files that could just as well be deleted
21
- # and everything would still work fine. This is for variable and
22
- # temporary files. Much like var/ and tmp/ in FHS.
23
- #
24
- # The module returns all paths as String.
25
- #
26
- module XDG
27
- if RUBY_VERSION > '1.9'
28
- require_relative 'xdg/version'
29
- require_relative 'xdg/base_dir'
30
- require_relative 'xdg/base_dir/extended'
31
- require_relative 'xdg/base_dir/mixin'
32
- else
33
- require 'xdg/version'
34
- require 'xdg/base_dir'
35
- require 'xdg/base_dir/extended'
36
- require 'xdg/base_dir/mixin'
37
- end
1
+ # frozen_string_literal: true
38
2
 
39
- #
40
- def self.[](*env_path)
41
- BaseDir.new(*env_path)
42
- end
43
- end
44
-
45
- # Copyright (c) 2008 Rubyworks
3
+ require "xdg/identity"
4
+ require "xdg/pair"
5
+ require "xdg/paths/standard"
6
+ require "xdg/paths/directory"
7
+ require "xdg/paths/combined"
8
+ require "xdg/config"
9
+ require "xdg/data"
10
+ require "xdg/cache"
11
+ require "xdg/environment"
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "forwardable"
4
+
5
+ module XDG
6
+ class Cache
7
+ extend Forwardable
8
+
9
+ HOME_PAIR = Pair.new("XDG_CACHE_HOME", ".cache").freeze
10
+
11
+ delegate %i[home directories all] => :combined
12
+
13
+ def initialize home: Paths::Standard, directories: Paths::Directory, environment: ENV
14
+ @combined = Paths::Combined.new home.new(HOME_PAIR, environment),
15
+ directories.new(Pair.new, environment)
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :combined
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "forwardable"
4
+
5
+ module XDG
6
+ class Config
7
+ extend Forwardable
8
+
9
+ HOME_PAIR = Pair.new("XDG_CONFIG_HOME", ".config").freeze
10
+ DIRS_PAIR = Pair.new("XDG_CONFIG_DIRS", "/etc/xdg").freeze
11
+
12
+ delegate %i[home directories all] => :combined
13
+
14
+ def initialize home: Paths::Standard, directories: Paths::Directory, environment: ENV
15
+ @combined = Paths::Combined.new home.new(HOME_PAIR, environment),
16
+ directories.new(DIRS_PAIR, environment)
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :combined
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "forwardable"
4
+
5
+ module XDG
6
+ class Data
7
+ extend Forwardable
8
+
9
+ HOME_PAIR = Pair.new("XDG_DATA_HOME", ".local/share").freeze
10
+ DIRS_PAIR = Pair.new("XDG_DATA_DIRS", "/usr/local/share:/usr/share").freeze
11
+
12
+ delegate %i[home directories all] => :combined
13
+
14
+ def initialize home: Paths::Standard, directories: Paths::Directory, environment: ENV
15
+ @combined = Paths::Combined.new home.new(HOME_PAIR, environment),
16
+ directories.new(DIRS_PAIR, environment)
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :combined
22
+ end
23
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module XDG
4
+ class Environment
5
+ def initialize home: Paths::Standard, directories: Paths::Directory, environment: ENV
6
+ @cache = Cache.new home: home, directories: directories, environment: environment
7
+ @config = Config.new home: home, directories: directories, environment: environment
8
+ @data = Data.new home: home, directories: directories, environment: environment
9
+ end
10
+
11
+ def cache_home
12
+ cache.home
13
+ end
14
+
15
+ def config_home
16
+ config.home
17
+ end
18
+
19
+ def config_dirs
20
+ config.directories
21
+ end
22
+
23
+ def data_home
24
+ data.home
25
+ end
26
+
27
+ def data_dirs
28
+ data.directories
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :cache, :config, :data
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module XDG
4
+ # Gem identity information.
5
+ module Identity
6
+ def self.name
7
+ "xdg"
8
+ end
9
+
10
+ def self.label
11
+ "XDG"
12
+ end
13
+
14
+ def self.version
15
+ "3.0.0"
16
+ end
17
+
18
+ def self.version_label
19
+ "#{label} #{version}"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module XDG
4
+ # A generic key-value pair (KVP).
5
+ Pair = Struct.new :key, :value do
6
+ def to_env
7
+ Hash[*values]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+
5
+ module XDG
6
+ module Paths
7
+ # The combined home and directory paths.
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
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+
5
+ module XDG
6
+ module Paths
7
+ # A collection of XDG directories.
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
+ paths.split(DELIMITER).map(&method(:expand))
18
+ end
19
+
20
+ def dynamic
21
+ environment.fetch(pair.key, paths).split(DELIMITER).uniq.map(&method(:expand))
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :pair, :environment
27
+
28
+ def paths
29
+ String pair.value
30
+ end
31
+
32
+ def expand path
33
+ Pathname(path).expand_path
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "forwardable"
4
+ require "pathname"
5
+
6
+ module XDG
7
+ module Paths
8
+ # A XDG home path.
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
+ expand_home_for String(value)
23
+ end
24
+
25
+ def dynamic
26
+ String(environment[key]).then { |path| path.empty? ? default : expand_home_for(path) }
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :pair, :environment
32
+
33
+ def home
34
+ Pathname environment.fetch(HOME_KEY)
35
+ end
36
+
37
+ def expand_home_for path
38
+ home.join(path).expand_path
39
+ end
40
+ end
41
+ end
42
+ end
metadata CHANGED
@@ -1,10 +1,9 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xdg
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Trans
8
7
  - Brooke Kuhlmann
9
8
  autorequire:
10
9
  bindir: bin
@@ -29,60 +28,227 @@ cert_chain:
29
28
  dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
30
29
  y84=
31
30
  -----END CERTIFICATE-----
32
- date: 2019-05-22 00:00:00.000000000 Z
33
- dependencies: []
31
+ date: 2019-06-01 00:00:00.000000000 Z
32
+ dependencies:
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler-audit
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.6'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: gemsmith
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '13.4'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '13.4'
61
+ - !ruby/object:Gem::Dependency
62
+ name: git-cop
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: guard-rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '4.7'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '4.7'
89
+ - !ruby/object:Gem::Dependency
90
+ name: pry
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.10'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.10'
103
+ - !ruby/object:Gem::Dependency
104
+ name: pry-byebug
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.5'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.5'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rake
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '12.3'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '12.3'
131
+ - !ruby/object:Gem::Dependency
132
+ name: reek
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '5.4'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '5.4'
145
+ - !ruby/object:Gem::Dependency
146
+ name: rspec
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '3.8'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '3.8'
159
+ - !ruby/object:Gem::Dependency
160
+ name: rubocop
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '0.69'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '0.69'
173
+ - !ruby/object:Gem::Dependency
174
+ name: rubocop-performance
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '1.3'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '1.3'
187
+ - !ruby/object:Gem::Dependency
188
+ name: rubocop-rspec
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: '1.33'
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: '1.33'
201
+ - !ruby/object:Gem::Dependency
202
+ name: simplecov
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: '0.13'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: '0.13'
34
215
  description:
35
216
  email:
36
- - transfire@gmail.com
37
217
  - brooke@alchemists.io
38
218
  executables: []
39
219
  extensions: []
40
220
  extra_rdoc_files:
41
221
  - README.md
42
- - LICENSE.txt
43
- - DEMO.md
44
- - HISTORY.md
222
+ - LICENSE.md
45
223
  files:
46
- - ".index"
47
- - ".yardopts"
48
- - DEMO.md
49
- - HISTORY.md
50
- - LICENSE.txt
224
+ - LICENSE.md
51
225
  - README.md
52
- - demo/01_base_dir.md
53
- - demo/02_base_dir_extended.md
54
- - demo/03_base_dir_mixin.md
55
- - demo/applique/ae.rb
56
- - demo/applique/fakeroot.rb
57
- - demo/applique/xdg.rb
58
- - demo/fixtures/fakeroot/etc/xdg/bar.config
59
- - demo/fixtures/fakeroot/home/joe/foo.txt
60
- - demo/fixtures/fakeroot/usr/share/bar.dat
61
226
  - lib/xdg.rb
62
- - lib/xdg/base_dir.rb
63
- - lib/xdg/base_dir/extended.rb
64
- - lib/xdg/base_dir/global_variables.rb
65
- - lib/xdg/base_dir/legacy.rb
66
- - lib/xdg/base_dir/mixin.rb
67
- - lib/xdg/version.rb
68
- - test/fakeroot/etc/xdg/bar.config
69
- - test/fakeroot/usr/share/bar.dat
70
- - test/test_xdg_legacy.rb
227
+ - lib/xdg/cache.rb
228
+ - lib/xdg/config.rb
229
+ - lib/xdg/data.rb
230
+ - lib/xdg/environment.rb
231
+ - lib/xdg/identity.rb
232
+ - lib/xdg/pair.rb
233
+ - lib/xdg/paths/combined.rb
234
+ - lib/xdg/paths/directory.rb
235
+ - lib/xdg/paths/standard.rb
71
236
  homepage: https://github.com/bkuhlmann/xdg
72
237
  licenses:
73
- - BSD-2-Clause
74
- metadata: {}
75
- post_install_message: 'Development of this project has been transfered here: https://github.com/bkuhlmann/xdg.
76
- This will be the last version supported within the 2.2.x series. Be aware major
77
- breaking changes will be introduced in the upcoming 3.0.0 release (2019-06-01).'
238
+ - Apache-2.0
239
+ metadata:
240
+ source_code_uri: https://github.com/bkuhlmann/xdg
241
+ changelog_uri: https://github.com/bkuhlmann/xdg/blob/master/CHANGES.md
242
+ bug_tracker_uri: https://github.com/bkuhlmann/xdg/issues
243
+ post_install_message:
78
244
  rdoc_options: []
79
245
  require_paths:
80
246
  - lib
81
247
  required_ruby_version: !ruby/object:Gem::Requirement
82
248
  requirements:
83
- - - ">="
249
+ - - "~>"
84
250
  - !ruby/object:Gem::Version
85
- version: '0'
251
+ version: '2.6'
86
252
  required_rubygems_version: !ruby/object:Gem::Requirement
87
253
  requirements:
88
254
  - - ">="
@@ -92,5 +258,5 @@ requirements: []
92
258
  rubygems_version: 3.0.3
93
259
  signing_key:
94
260
  specification_version: 4
95
- summary: XDG provides an interface for using XDG directory standard.
261
+ summary: Provides an implementation of the XDG Base Directory Specification.
96
262
  test_files: []