xdg 0.5.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
@@ -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.
@@ -1 +1 @@
1
- 7rans <transfire@gmail.com>
1
+ Thomas Sawyer
@@ -0,0 +1 @@
1
+ rubyworks
@@ -1 +1 @@
1
- tigerops-community@rubyforge.org
1
+ rubyworks-mailinglist@googlegroups.com
@@ -1,3 +1,2 @@
1
1
  XDG provides a module for supporting the XDG Base Directory Standard.
2
2
  See: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
3
-
File without changes
@@ -0,0 +1 @@
1
+ http://github.com/rubyworks/xdg.git
@@ -1 +1 @@
1
- 0.5.2
1
+ 1.0.0
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ system('testrb test/test_xdg.rb')
3
+
4
+
@@ -1,6 +1,7 @@
1
- require 'test/unit'
2
1
  $: << 'lib'
3
- require 'xdg'
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.config_home)
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.config_dirs)
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.data_home)
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.data_dirs)
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.cache_home)
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.data_find(file))
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.data_find(file))
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.config_find(file))
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.config_find(file))
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.cache_find(file))
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.data_select(file))
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.data_select(file))
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.config_select(file))
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.config_select(file))
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.cache_select(file))
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.config_work)
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.cache_work)
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.5.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - tigerops-community@rubyforge.org
8
- - 7rans <transfire@gmail.com>
7
+ - Thomas Sawyer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
11
 
13
- date: 2009-09-22 00:00:00 -04:00
12
+ date: 2009-12-01 00:00:00 -05:00
14
13
  default_executable:
15
14
  dependencies: []
16
15
 
17
- description: XDG provides an easy to use module for utilizing the XDG Base Directory Standard[1]. If your program utilizes user or system-wide support files
18
- email: tigerops-community@rubyforge.org
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/package
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
- - xdg api
61
+ - XDG API
57
62
  - --main
58
63
  - README
59
64
  require_paths: