xdg 2.2.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,86 +0,0 @@
1
- module XDG
2
- class BaseDir
3
- #
4
- # The BaseDir::Mixin module can be used to add XDG base directory
5
- # methods to your own classes.
6
- #
7
- # class MyAppConfig
8
- # include XDG::BaseDir::Mixin
9
- #
10
- # def subdirectory
11
- # 'myapp'
12
- # end
13
- # end
14
- #
15
- # c = MyAppConfig.new
16
- #
17
- # c.config.home.list #=> ['~/.config/myapp']
18
- #
19
- module Mixin
20
-
21
- # @todo do we need this?
22
- extend self
23
-
24
- # Override this method to change the subdirectory of the mixin.
25
- def subdirectory
26
- nil
27
- end
28
-
29
- #
30
- def home
31
- File.expand_path('~')
32
- end
33
-
34
- #
35
- def data
36
- obj = XDG['DATA'].with_subdirectory(subdirectory)
37
- class << obj
38
- def home
39
- XDG['DATA_HOME'].with_subdirectory(subdirectory)
40
- end
41
- def dirs
42
- XDG['DATA_DIRS'].with_subdirectory(subdirectory)
43
- end
44
- end
45
- return obj
46
- end
47
-
48
- #
49
- def config
50
- obj = XDG['CONFIG'].with_subdirectory(subdirectory)
51
- class << obj
52
- def home
53
- XDG['CONFIG_HOME'].with_subdirectory(subdirectory)
54
- end
55
- def dirs
56
- XDG['CONFIG_DIRS'].with_subdirectory(subdirectory)
57
- end
58
- def work
59
- XDG['CONFIG_WORK'].with_subdirectory(subdirectory)
60
- end
61
- end
62
- return obj
63
- end
64
-
65
- #
66
- def cache
67
- obj = XDG['CACHE'].with_subdirectory(subdirectory)
68
- class << obj
69
- def home
70
- XDG['CACHE_HOME'].with_subdirectory(subdirectory)
71
- end
72
- def dirs
73
- XDG['CACHE_DIRS'].with_subdirectory(subdirectory)
74
- end
75
- def work
76
- XDG['CACHE_WORK'].with_subdirectory(subdirectory)
77
- end
78
- end
79
- return obj
80
- end
81
-
82
- end
83
- end
84
- end
85
-
86
- # Copyright (c) 2008 Rubyworks
@@ -1,3 +0,0 @@
1
- module XDG
2
- VERSION = '2.2.3'
3
- end
@@ -1 +0,0 @@
1
- BAR.CONFIG
@@ -1 +0,0 @@
1
- BAR.DAT
@@ -1,117 +0,0 @@
1
- $:.unshift 'lib'
2
-
3
- require 'xdg/base_dir/legacy'
4
- require 'test/unit'
5
-
6
- # run test from fakeroot directory.
7
- Dir.chdir(File.join(File.dirname(__FILE__), 'fakeroot'))
8
-
9
- ENV['HOME'] = File.join(Dir.pwd, 'home')
10
- ENV['XDG_DATA_DIRS'] = File.join(Dir.pwd, 'usr/share')
11
- ENV['XDG_CONFIG_DIRS'] = File.join(Dir.pwd, 'etc/xdg')
12
-
13
- class TestXDG < Test::Unit::TestCase
14
-
15
- # Test the standard paths.
16
-
17
- def test_home
18
- assert_equal(File.join(Dir.pwd,'home'), XDG.home)
19
- end
20
-
21
- def test_config_home
22
- assert_equal(File.join(Dir.pwd,'home/.config'), XDG.config.home)
23
- end
24
-
25
- def test_config_dirs
26
- assert_equal([File.join(Dir.pwd,"etc/xdg")], XDG.config.dirs)
27
- end
28
-
29
- def test_data_home
30
- assert_equal(File.join(Dir.pwd,'home/.local/share'), XDG.data.home)
31
- end
32
-
33
- def test_data_dirs
34
- assert_equal([File.join(Dir.pwd,'usr/share')], XDG.data.dirs)
35
- end
36
-
37
- def test_cache_home
38
- assert_equal(File.join(Dir.pwd,'home/.cache'), XDG.cache.home)
39
- end
40
-
41
- # Test the find methods.
42
-
43
- def test_data_find
44
- file = 'foo.dat'
45
- assert_equal(File.join(Dir.pwd,'home/.local/share', file), XDG.data.find(file))
46
- file = 'bar.dat'
47
- assert_equal(File.join(Dir.pwd,'usr/share', file), XDG.data.find(file))
48
- end
49
-
50
- def test_config_find
51
- file = 'foo.config'
52
- assert_equal(File.join(Dir.pwd,'home/.config', file), XDG.config.find(file))
53
- file = 'bar.config'
54
- assert_equal(File.join(Dir.pwd,'etc/xdg', file), XDG.config.find(file))
55
- end
56
-
57
- def test_cache_find
58
- file = 'foo.cache'
59
- assert_equal(File.join(Dir.pwd,'home/.cache', file), XDG.cache.find(file))
60
- end
61
-
62
- # Test the glob methods.
63
-
64
- def test_data_select
65
- file = 'foo.dat'
66
- assert_equal([File.join(Dir.pwd,'home/.local/share', file)], XDG.data.select(file))
67
- file = 'bar.dat'
68
- assert_equal([File.join(Dir.pwd,'usr/share', file)], XDG.data.select(file))
69
- end
70
-
71
- def test_config_select
72
- file = 'foo.config'
73
- assert_equal([File.join(Dir.pwd,'home/.config', file)], XDG.config.select(file))
74
- file = 'bar.config'
75
- assert_equal([File.join(Dir.pwd,'etc/xdg', file)], XDG.config.select(file))
76
- end
77
-
78
- def test_cache_select
79
- file = 'foo.cache'
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))
102
- end
103
-
104
- # Test the working directory variations.
105
-
106
- def test_config_work
107
- result = [File.join(Dir.pwd,'.config'), File.join(Dir.pwd,'config')]
108
- assert_equal(result, XDG.config.work)
109
- end
110
-
111
- def test_cache_work
112
- result = [File.join(Dir.pwd,'.tmp'), File.join(Dir.pwd,'tmp')]
113
- assert_equal(result, XDG.cache.work)
114
- end
115
-
116
- end
117
-