xdg 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby CHANGED
@@ -1,14 +1,17 @@
1
1
  ---
2
2
  name: xdg
3
- version: 2.0.0
3
+ version: 2.1.0
4
4
  title: XDG
5
5
  summary: XDG provides an interface for using XDG directory standard.
6
6
  description: XDG provides a module for supporting the XDG Base Directory Standard. See http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
7
7
  loadpath:
8
8
  - lib
9
9
  manifest: Manifest.txt
10
- requires: []
11
-
10
+ requires:
11
+ - name: qed
12
+ version: 0+
13
+ group:
14
+ - test
12
15
  conflicts: []
13
16
 
14
17
  replaces: []
@@ -18,7 +21,7 @@ engine_check: []
18
21
  organization: RubyWorks
19
22
  contact: Thomas Sawyer <transfire@gmail.com>
20
23
  created: 2008-09-27
21
- copyright: Copyright (c) 2008 Thomas Sawyer
24
+ copyright: Copyright (c) 2008,2011 Thomas Sawyer
22
25
  licenses:
23
26
  - Apache 2.0
24
27
  authors:
@@ -1,5 +1,19 @@
1
1
  = RELEASE HISTORY
2
2
 
3
+ == 2.1.0 / 2011-06-10
4
+
5
+ This release changes the BaseDir#list method, where as it used
6
+ to be an alias for #to_a, it now differs in that it does not
7
+ expand the paths. In addtion a few tests were fixed and version
8
+ number properly updated int hte version.rb file.
9
+
10
+ Changes:
11
+
12
+ * Change BaseDir#list to not expand paths.
13
+ * Properly assign VERSION constant.
14
+ * Fix broken qed tests.
15
+
16
+
3
17
  == 2.0.0 / 2011-06-09
4
18
 
5
19
  Major new release is full rewrite of the API, with an eye out for
@@ -48,7 +48,16 @@ module XDG
48
48
  @environment_variables
49
49
  end
50
50
 
51
- # Returns a complete list of directories.
51
+ # The equivalent environment setting.
52
+ #
53
+ # @return [String] evnironment vsetting
54
+ def env
55
+ environment_variables.map{ |v| ENV[v] }.join(':')
56
+ end
57
+
58
+ # Returns a complete list of expanded directories.
59
+ #
60
+ # @return [Array<String>] expanded directory list
52
61
  def to_a
53
62
  environment_variables.map do |v|
54
63
  if paths = ENV[v]
@@ -73,9 +82,22 @@ module XDG
73
82
  to_a.each(&block)
74
83
  end
75
84
 
76
- # Returns a complete list of directories.
85
+ # Returns an *unexpanded* list of directories.
86
+ #
87
+ # @return [Array<String>] unexpanded directory list
77
88
  def list
78
- to_a
89
+ environment_variables.map do |v|
90
+ if paths = ENV[v]
91
+ dirs = paths.split(/[:;]/)
92
+ else
93
+ dirs = DEFAULTS[v]
94
+ end
95
+ if subdirectory
96
+ dirs.map{ |path| File.join(path, subdirectory) }
97
+ else
98
+ dirs
99
+ end
100
+ end.flatten
79
101
  end
80
102
 
81
103
  # List of directories as Pathanme objects.
@@ -85,6 +107,32 @@ module XDG
85
107
  map{ |dir| Pathname.new(dir) }
86
108
  end
87
109
 
110
+ # This is same as #env, but also includes default values.
111
+ #
112
+ # @return [String] envinronment value.
113
+ def to_s
114
+ environment_variables.map{ |v| ENV[v] || DEFAULTS[v] }.join(':')
115
+ end
116
+
117
+ # @return [Pathname] pathname of first directory
118
+ def to_path
119
+ Pathname.new(to_a.first)
120
+ end
121
+
122
+ #
123
+ attr :subdirectory
124
+
125
+ #
126
+ def subdirectory=(path)
127
+ @subdirectory = path.to_s
128
+ end
129
+
130
+ #
131
+ def with_subdirectory(path)
132
+ @subdirectory = path if path
133
+ self
134
+ end
135
+
88
136
  # Return array of matching files or directories
89
137
  # in any of the resource locations, starting with
90
138
  # the home directory and searching outward into
@@ -98,7 +146,7 @@ module XDG
98
146
  def glob(*glob_and_flags)
99
147
  glob, flags = *parse_arguments(*glob_and_flags)
100
148
  find = []
101
- list.each do |dir|
149
+ to_a.each do |dir|
102
150
  glob.each do |pattern|
103
151
  find.concat(Dir.glob(File.join(dir, pattern), flags))
104
152
  end
@@ -123,7 +171,7 @@ module XDG
123
171
  def select(*glob_and_flags, &block)
124
172
  glob, flag = *parse_arguments(*glob_and_flags)
125
173
  find = []
126
- list.each do |dir|
174
+ to_a.each do |dir|
127
175
  path = File.join(dir, *glob)
128
176
  hits = Dir.glob(path, flag)
129
177
  hits = hits.select(&block) if block_given?
@@ -139,7 +187,7 @@ module XDG
139
187
  def find(*glob_and_flags, &block)
140
188
  glob, flag = *parse_arguments(*glob_and_flags)
141
189
  find = nil
142
- list.each do |dir|
190
+ to_a.each do |dir|
143
191
  path = File.join(dir, *glob)
144
192
  hits = Dir.glob(path, flag)
145
193
  hits = hits.select(&block) if block_given?
@@ -149,35 +197,6 @@ module XDG
149
197
  find
150
198
  end
151
199
 
152
- # @return [String] envinronment values.
153
- def to_s
154
- environment_variables.map{ |v| ENV[v] || DEFAULTS[v] }.join(':')
155
- end
156
-
157
- # @return [Pathname] pathname of first directory
158
- def to_path
159
- Pathname.new(to_s)
160
- end
161
-
162
- #
163
- def env
164
- environment_variables.map{ |v| ENV[v] }.join(':')
165
- end
166
-
167
- #
168
- attr :subdirectory
169
-
170
- #
171
- def subdirectory=(path)
172
- @subdirectory = path.to_s
173
- end
174
-
175
- #
176
- def with_subdirectory(path)
177
- @subdirectory = path if path
178
- self
179
- end
180
-
181
200
  private
182
201
 
183
202
  def parse_arguments(*glob_and_flags)
@@ -1,3 +1,3 @@
1
1
  module XDG
2
- VERSION = '1.0.0'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -7,11 +7,14 @@ The extended base directory standard provides
7
7
  == Resource
8
8
 
9
9
  XDG['RESOURCE_HOME'].env.assert == ENV['XDG_RESOURCE_HOME'].to_s
10
+
10
11
  XDG['RESOURCE_HOME'].environment_variables.assert == ['XDG_RESOURCE_HOME']
11
12
 
12
13
  Looking at the data home location by default it should be pointing to
13
14
  our joe user's home directory under `.local`.
14
15
 
16
+ XDG['RESOURCE_HOME'].list.assert == ['~/.local']
17
+
15
18
  XDG['RESOURCE_HOME'].to_a.assert == [$froot + 'home/joe/.local']
16
19
 
17
20
 
@@ -20,20 +23,26 @@ our joe user's home directory under `.local`.
20
23
  The working configuration directory
21
24
 
22
25
  XDG['CONFIG_WORK'].env.assert == ENV['XDG_CONFIG_WORK'].to_s
26
+
23
27
  XDG['CONFIG_WORK'].environment_variables.assert == ['XDG_CONFIG_WORK']
24
28
 
25
29
  Looking at the config work location, by default it should be pointing to
26
30
  the current working directory's `.config` or `config` directory.
27
31
 
28
- XDG['CONFIG_WORK'].to_a.assert == ['.config', 'config']
32
+ XDG['CONFIG_WORK'].list.assert == ['.config', 'config']
33
+
34
+ XDG['CONFIG_WORK'].to_a.assert == [Dir.pwd + '/.config', Dir.pwd + '/config']
29
35
 
30
36
  The working cache directory
31
37
 
32
38
  XDG['CACHE_WORK'].env.assert == ENV['XDG_CACHE_WORK'].to_s
39
+
33
40
  XDG['CACHE_WORK'].environment_variables.assert == ['XDG_CACHE_WORK']
34
41
 
35
42
  Looking at the cache work location, by default it should be pointing to
36
43
  the current working directory's `.tmp` or `tmp` directory.
37
44
 
38
- XDG['CONFIG_WORK'].to_a.assert == ['.tmp', 'tmp']
45
+ XDG['CACHE_WORK'].list.assert == ['.tmp', 'tmp']
46
+
47
+ XDG['CACHE_WORK'].to_a.assert == [Dir.pwd + '/.tmp', Dir.pwd + '/tmp']
39
48
 
@@ -15,5 +15,5 @@ access to a named subdirectory of the XDG directories.
15
15
 
16
16
  c = MyAppConfig.new
17
17
 
18
- c.config.home.to_s #=> '~/.config/myapp'
18
+ c.config.home.to_a #=> [$froot + 'home/joe/.config/myapp']
19
19
 
@@ -0,0 +1 @@
1
+ AE.ansi = false
@@ -4,6 +4,8 @@ dir = File.expand_path(File.dirname(File.dirname(__FILE__)))
4
4
 
5
5
  $froot = File.join(dir, 'fixtures/fakeroot/')
6
6
 
7
+ p $froot
8
+
7
9
  #
8
10
  ENV['HOME'] = $froot + 'home/joe'
9
11
  #ENV['XDG_DATA_HOME'] = $froot + '.local/share'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: xdg
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.0.0
5
+ version: 2.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas Sawyer
@@ -41,8 +41,9 @@ files:
41
41
  - lib/xdg/version.rb
42
42
  - lib/xdg.rb
43
43
  - qed/01_base_dir.rdoc
44
- - qed/02_base_dir_extended.rb
45
- - qed/03_base_dir_mixin.rb
44
+ - qed/02_base_dir_extended.rdoc
45
+ - qed/03_base_dir_mixin.rdoc
46
+ - qed/applique/ae.rb
46
47
  - qed/applique/fakeroot.rb
47
48
  - qed/fixtures/fakeroot/etc/xdg/bar.config
48
49
  - qed/fixtures/fakeroot/home/.cache/foo.cache