xdg 0.5.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +783 -162
- data/HISTORY +46 -30
- data/MANIFEST +8 -19
- data/README +57 -32
- data/lib/xdg.rb +191 -170
- data/lib/xdg/compat.rb +66 -0
- data/lib/xdg/extended.rb +84 -0
- data/meta/authors +1 -1
- data/meta/collection +1 -0
- data/meta/contact +1 -1
- data/meta/{abstract → description} +0 -1
- data/meta/{package → name} +0 -0
- data/meta/repository +1 -0
- data/meta/version +1 -1
- data/script/test +4 -0
- data/test/test_xdg.rb +41 -23
- metadata +15 -10
data/lib/xdg/compat.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module XDG
|
2
|
+
|
3
|
+
def data_home
|
4
|
+
data.home
|
5
|
+
end
|
6
|
+
|
7
|
+
def config_home
|
8
|
+
config.home
|
9
|
+
end
|
10
|
+
|
11
|
+
def cache_home
|
12
|
+
cache.home
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def data_dirs
|
17
|
+
data.home
|
18
|
+
end
|
19
|
+
|
20
|
+
def config_dirs
|
21
|
+
config.dirs
|
22
|
+
end
|
23
|
+
|
24
|
+
#def cache_dirs
|
25
|
+
# cache.dirs
|
26
|
+
#end
|
27
|
+
|
28
|
+
|
29
|
+
def data_select(*args, &block)
|
30
|
+
data.select(*args, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def config_select(*args, &block)
|
34
|
+
config.select(*args, &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def cache_select(*args, &block)
|
38
|
+
cache.select(*args, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def data_find(*args, &block)
|
43
|
+
data.find(*args, &block)
|
44
|
+
end
|
45
|
+
|
46
|
+
def config_find(*args, &block)
|
47
|
+
config.find(*args, &block)
|
48
|
+
end
|
49
|
+
|
50
|
+
def cache_find(*args, &block)
|
51
|
+
cache.find(*args, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def config_work
|
56
|
+
config.work
|
57
|
+
end
|
58
|
+
|
59
|
+
def cache_work
|
60
|
+
cache.work
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# Copyright (c) 2008,2009 Thomas Sawyer
|
66
|
+
# Distributed under the terms of the LGPL v3.
|
data/lib/xdg/extended.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'xdg'
|
2
|
+
|
3
|
+
module XDG
|
4
|
+
|
5
|
+
# Access to resource locations.
|
6
|
+
#
|
7
|
+
# XDG.resource.each{ |dir| ... }
|
8
|
+
#
|
9
|
+
def resource(*glob_and_flags, &block)
|
10
|
+
if !glob_and_flags.empty? or block_given?
|
11
|
+
Resource.select(*glob_and_flags, &block)
|
12
|
+
else
|
13
|
+
Resource
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# = USER RESOURCES
|
18
|
+
#
|
19
|
+
module Resource
|
20
|
+
include Common
|
21
|
+
|
22
|
+
# Location of personal resource directory.
|
23
|
+
def home
|
24
|
+
@home ||= (
|
25
|
+
File.expand_path(
|
26
|
+
ENV['XDG_RESOURCE_HOME'] || File.join(XDG.home, '.local')
|
27
|
+
)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# List of common user directores.
|
32
|
+
def dirs
|
33
|
+
@dirs ||= (
|
34
|
+
dirs = ENV['XDG_RESOURCE_DIRS'].split(/[:;]/)
|
35
|
+
if dirs.empty?
|
36
|
+
dirs = ['/usr/local', '/usr']
|
37
|
+
end
|
38
|
+
dirs = dirs.map{ |d| File.expand_path(d) }.uniq
|
39
|
+
dirs = dirs.select{ |d| File.directory?(d) }
|
40
|
+
dirs
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
extend self
|
45
|
+
end
|
46
|
+
|
47
|
+
module Config
|
48
|
+
|
49
|
+
# Location of working config directory.
|
50
|
+
#
|
51
|
+
# This is not not strictly XDG spec, but it
|
52
|
+
# can be useful in an analogous respect.
|
53
|
+
#
|
54
|
+
def work
|
55
|
+
@work ||= (
|
56
|
+
File.expand_path(
|
57
|
+
File.join(Dir.pwd, '.config')
|
58
|
+
)
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
module Cache
|
65
|
+
|
66
|
+
# Location of working cache directory.
|
67
|
+
#
|
68
|
+
# This is not strictly XDG spec, but it
|
69
|
+
# can be useful in an analogous respect.
|
70
|
+
#
|
71
|
+
def work
|
72
|
+
@work ||= (
|
73
|
+
File.expand_path(
|
74
|
+
File.join(Dir.pwd, '.cache')
|
75
|
+
)
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
# Copyright (c) 2008,2009 Thomas Sawyer
|
84
|
+
# Distributed under the terms of the LGPL v3.
|
data/meta/authors
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Thomas Sawyer
|
data/meta/collection
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rubyworks
|
data/meta/contact
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
rubyworks-mailinglist@googlegroups.com
|
data/meta/{package → name}
RENAMED
File without changes
|
data/meta/repository
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
http://github.com/rubyworks/xdg.git
|
data/meta/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/script/test
ADDED
data/test/test_xdg.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require 'test/unit'
|
2
1
|
$: << 'lib'
|
3
|
-
|
2
|
+
|
3
|
+
require 'xdg/extended'
|
4
|
+
require 'test/unit'
|
4
5
|
|
5
6
|
# run test from fakeroot directory.
|
6
7
|
Dir.chdir(File.join(File.dirname(__FILE__), 'fakeroot'))
|
@@ -18,79 +19,96 @@ class TestXDG < Test::Unit::TestCase
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def test_config_home
|
21
|
-
assert_equal(File.join(Dir.pwd,'home/.config'), XDG.
|
22
|
+
assert_equal(File.join(Dir.pwd,'home/.config'), XDG.config.home)
|
22
23
|
end
|
23
24
|
|
24
25
|
def test_config_dirs
|
25
|
-
assert_equal([File.join(Dir.pwd,"etc/xdg")], XDG.
|
26
|
+
assert_equal([File.join(Dir.pwd,"etc/xdg")], XDG.config.dirs)
|
26
27
|
end
|
27
28
|
|
28
29
|
def test_data_home
|
29
|
-
assert_equal(File.join(Dir.pwd,'home/.local/share'), XDG.
|
30
|
+
assert_equal(File.join(Dir.pwd,'home/.local/share'), XDG.data.home)
|
30
31
|
end
|
31
32
|
|
32
33
|
def test_data_dirs
|
33
|
-
assert_equal([File.join(Dir.pwd,'usr/share')], XDG.
|
34
|
+
assert_equal([File.join(Dir.pwd,'usr/share')], XDG.data.dirs)
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_cache_home
|
37
|
-
assert_equal(File.join(Dir.pwd,'home/.cache'), XDG.
|
38
|
+
assert_equal(File.join(Dir.pwd,'home/.cache'), XDG.cache.home)
|
38
39
|
end
|
39
40
|
|
40
41
|
# Test the find methods.
|
41
42
|
|
42
43
|
def test_data_find
|
43
44
|
file = 'foo.dat'
|
44
|
-
assert_equal(File.join(Dir.pwd,'home/.local/share', file), XDG.
|
45
|
+
assert_equal(File.join(Dir.pwd,'home/.local/share', file), XDG.data.find(file))
|
45
46
|
file = 'bar.dat'
|
46
|
-
assert_equal(File.join(Dir.pwd,'usr/share', file), XDG.
|
47
|
+
assert_equal(File.join(Dir.pwd,'usr/share', file), XDG.data.find(file))
|
47
48
|
end
|
48
49
|
|
49
50
|
def test_config_find
|
50
51
|
file = 'foo.config'
|
51
|
-
assert_equal(File.join(Dir.pwd,'home/.config', file), XDG.
|
52
|
+
assert_equal(File.join(Dir.pwd,'home/.config', file), XDG.config.find(file))
|
52
53
|
file = 'bar.config'
|
53
|
-
assert_equal(File.join(Dir.pwd,'etc/xdg', file), XDG.
|
54
|
+
assert_equal(File.join(Dir.pwd,'etc/xdg', file), XDG.config.find(file))
|
54
55
|
end
|
55
56
|
|
56
57
|
def test_cache_find
|
57
58
|
file = 'foo.cache'
|
58
|
-
assert_equal(File.join(Dir.pwd,'home/.cache', file), XDG.
|
59
|
+
assert_equal(File.join(Dir.pwd,'home/.cache', file), XDG.cache.find(file))
|
59
60
|
end
|
60
61
|
|
61
62
|
# Test the glob methods.
|
62
63
|
|
63
64
|
def test_data_select
|
64
65
|
file = 'foo.dat'
|
65
|
-
assert_equal([File.join(Dir.pwd,'home/.local/share', file)], XDG.
|
66
|
+
assert_equal([File.join(Dir.pwd,'home/.local/share', file)], XDG.data.select(file))
|
66
67
|
file = 'bar.dat'
|
67
|
-
assert_equal([File.join(Dir.pwd,'usr/share', file)], XDG.
|
68
|
+
assert_equal([File.join(Dir.pwd,'usr/share', file)], XDG.data.select(file))
|
68
69
|
end
|
69
70
|
|
70
71
|
def test_config_select
|
71
72
|
file = 'foo.config'
|
72
|
-
assert_equal([File.join(Dir.pwd,'home/.config', file)], XDG.
|
73
|
+
assert_equal([File.join(Dir.pwd,'home/.config', file)], XDG.config.select(file))
|
73
74
|
file = 'bar.config'
|
74
|
-
assert_equal([File.join(Dir.pwd,'etc/xdg', file)], XDG.
|
75
|
+
assert_equal([File.join(Dir.pwd,'etc/xdg', file)], XDG.config.select(file))
|
75
76
|
end
|
76
77
|
|
77
78
|
def test_cache_select
|
78
79
|
file = 'foo.cache'
|
79
|
-
assert_equal([File.join(Dir.pwd,'home/.cache', file)], XDG.
|
80
|
+
assert_equal([File.join(Dir.pwd,'home/.cache', file)], XDG.cache.select(file))
|
81
|
+
end
|
82
|
+
|
83
|
+
# Test the glob methods.
|
84
|
+
|
85
|
+
def test_data_glob
|
86
|
+
file = 'foo.dat'
|
87
|
+
assert_equal([File.join(Dir.pwd,'home/.local/share', file)], XDG.data.glob(file))
|
88
|
+
file = 'bar.dat'
|
89
|
+
assert_equal([File.join(Dir.pwd,'usr/share', file)], XDG.data.glob(file))
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_config_glob
|
93
|
+
file = 'foo.config'
|
94
|
+
assert_equal([File.join(Dir.pwd,'home/.config', file)], XDG.config.glob(file))
|
95
|
+
file = 'bar.config'
|
96
|
+
assert_equal([File.join(Dir.pwd,'etc/xdg', file)], XDG.config.glob(file))
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_cache_glob
|
100
|
+
file = 'foo.cache'
|
101
|
+
assert_equal([File.join(Dir.pwd,'home/.cache', file)], XDG.cache.glob(file))
|
80
102
|
end
|
81
103
|
|
82
104
|
# Test the working directory variations.
|
83
105
|
|
84
106
|
def test_config_work
|
85
|
-
assert_equal(File.join(Dir.pwd,'.config'), XDG.
|
107
|
+
assert_equal(File.join(Dir.pwd,'.config'), XDG.config.work)
|
86
108
|
end
|
87
109
|
|
88
|
-
#def test_data_work
|
89
|
-
# assert_equal(File.join(Dir.pwd,'.share'), XDG.data_work)
|
90
|
-
#end
|
91
|
-
|
92
110
|
def test_cache_work
|
93
|
-
assert_equal(File.join(Dir.pwd,'.cache'), XDG.
|
111
|
+
assert_equal(File.join(Dir.pwd,'.cache'), XDG.cache.work)
|
94
112
|
end
|
95
113
|
|
96
114
|
end
|
metadata
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xdg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
- 7rans <transfire@gmail.com>
|
7
|
+
- Thomas Sawyer
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
|
13
|
-
date: 2009-
|
12
|
+
date: 2009-12-01 00:00:00 -05:00
|
14
13
|
default_executable:
|
15
14
|
dependencies: []
|
16
15
|
|
17
|
-
description:
|
18
|
-
|
16
|
+
description: |-
|
17
|
+
XDG provides a module for supporting the XDG Base Directory Standard.
|
18
|
+
See: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
|
19
|
+
email: rubyworks-mailinglist@googlegroups.com
|
19
20
|
executables: []
|
20
21
|
|
21
22
|
extensions: []
|
@@ -26,15 +27,20 @@ extra_rdoc_files:
|
|
26
27
|
- HISTORY
|
27
28
|
- COPYING
|
28
29
|
files:
|
30
|
+
- lib/xdg/compat.rb
|
31
|
+
- lib/xdg/extended.rb
|
29
32
|
- lib/xdg.rb
|
30
|
-
- meta/abstract
|
31
33
|
- meta/authors
|
34
|
+
- meta/collection
|
32
35
|
- meta/contact
|
36
|
+
- meta/description
|
33
37
|
- meta/homepage
|
34
|
-
- meta/
|
38
|
+
- meta/name
|
39
|
+
- meta/repository
|
35
40
|
- meta/summary
|
36
41
|
- meta/title
|
37
42
|
- meta/version
|
43
|
+
- script/test
|
38
44
|
- test/fakeroot/etc/xdg/bar.config
|
39
45
|
- test/fakeroot/home/.cache/foo.cache
|
40
46
|
- test/fakeroot/home/.config/foo.config
|
@@ -51,9 +57,8 @@ licenses: []
|
|
51
57
|
|
52
58
|
post_install_message:
|
53
59
|
rdoc_options:
|
54
|
-
- --inline-source
|
55
60
|
- --title
|
56
|
-
-
|
61
|
+
- XDG API
|
57
62
|
- --main
|
58
63
|
- README
|
59
64
|
require_paths:
|