maid-xdg 2.2.1.1 → 2.2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ module XDG
2
+
3
+ # Base directory interface class.
4
+ class BaseDir
5
+
6
+ #
7
+ DEFAULTS['XDG_RESOURCE_HOME'] = ['~/.local']
8
+ DEFAULTS['XDG_RESOURCE_DIRS'] = ['/usr/local','/usr']
9
+
10
+ # Working directory
11
+ # TODO: Not sure about these defaults
12
+ DEFAULTS['XDG_CONFIG_WORK'] = ['.config','config']
13
+ DEFAULTS['XDG_CACHE_WORK'] = ['.tmp','tmp']
14
+ DEFAULTS['XDG_RESOURCE_WORK'] = ['.local']
15
+ end
16
+
17
+ end
18
+
19
+ # Copyright (c) 2008,2011 Thomas Sawyer
20
+ # Distributed under the terms of the APACHE 2.0 license.
@@ -0,0 +1,18 @@
1
+ if RUBY_VERSION > '1.9'
2
+ require_relative 'base_dir'
3
+ else
4
+ require 'xdg/base_dir'
5
+ end
6
+
7
+ $XDG_DATA = XDG::BaseDir.new('DATA')
8
+ $XDG_DATA_HOME = XDG::BaseDir.new('DATA', 'HOME')
9
+ $XDG_DATA_DIRS = XDG::BaseDir.new('DATA', 'DIRS')
10
+
11
+ $XDG_CONFIG = XDG::BaseDir.new('CONFIG')
12
+ $XDG_CONFIG_HOME = XDG::BaseDir.new('CONFIG', 'HOME')
13
+ $XDG_CONFIG_DIRS = XDG::BaseDir.new('CONFIG', 'DIRS')
14
+
15
+ $XDG_CACHE = XDG::BaseDir.new('CACHE')
16
+ $XDG_CACHE_HOME = XDG::BaseDir.new('CACHE', 'HOME')
17
+ $XDG_CACHE_DIRS = XDG::BaseDir.new('CACHE', 'DIRS')
18
+
@@ -0,0 +1,72 @@
1
+ module XDG
2
+ class BaseDir
3
+ # Legacy API can serve as a stop gap until a developer
4
+ # has time to update an program already using XDG.
5
+ #
6
+ # Do NOT use this module for future development!!!
7
+ module Legacy
8
+ #
9
+ require 'xdg'
10
+ require 'xdg/base_dir/extended'
11
+
12
+ #
13
+ extend self
14
+
15
+ #
16
+ def home
17
+ File.expand_path('~')
18
+ end
19
+
20
+ #
21
+ def data
22
+ obj = XDG['DATA']
23
+ class << obj
24
+ def home
25
+ XDG['DATA_HOME'].to_a.first
26
+ end
27
+ def dirs
28
+ XDG['DATA_DIRS'].to_a
29
+ end
30
+ end
31
+ return obj
32
+ end
33
+
34
+ #
35
+ def config
36
+ obj = XDG['CONFIG']
37
+ class << obj
38
+ def home
39
+ XDG['CONFIG_HOME'].to_a.first
40
+ end
41
+ def dirs
42
+ XDG['CONFIG_DIRS'].to_a
43
+ end
44
+ def work
45
+ XDG['CONFIG_WORK'].to_a
46
+ end
47
+ end
48
+ return obj
49
+ end
50
+
51
+ #
52
+ def cache
53
+ obj = XDG['CACHE']
54
+ class << obj
55
+ def home
56
+ XDG['CACHE_HOME'].to_a.first
57
+ end
58
+ def dirs
59
+ XDG['CACHE_DIRS'].to_a
60
+ end
61
+ def work
62
+ XDG['CACHE_WORK'].to_a
63
+ end
64
+ end
65
+ return obj
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ extend BaseDir::Legacy
72
+ end
@@ -0,0 +1,84 @@
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
@@ -0,0 +1,3 @@
1
+ module XDG
2
+ VERSION = '2.2.1.2'
3
+ end
@@ -0,0 +1 @@
1
+ Just here to provide a file for github to keep this directory.
@@ -0,0 +1 @@
1
+ BAR.CONFIG
@@ -0,0 +1 @@
1
+ FOO.CACHE
@@ -0,0 +1 @@
1
+ FOO.DAT
@@ -0,0 +1 @@
1
+ BAR.DAT
@@ -0,0 +1,117 @@
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
+
data/xdg.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xdg/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "maid-xdg"
8
+ gem.version = XDG::VERSION
9
+ gem.authors = ["Trans (RubyWorks)"]
10
+ gem.email = ["transfire@gmail.com"]
11
+ gem.description = %q{XDG provides an interface for using XDG directory standard.}
12
+ gem.summary = %q{XDG provides an interface for using XDG directory standard.}
13
+ gem.homepage = "http://rubyworks.github.com/xdg"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency 'detroit'
21
+ gem.add_development_dependency 'qed'
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maid-xdg
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1.1
4
+ version: 2.2.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-20 00:00:00.000000000 Z
12
+ date: 2012-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: detroit
16
- requirement: &12121500 !ruby/object:Gem::Requirement
16
+ requirement: &17817400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *12121500
24
+ version_requirements: *17817400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: qed
27
- requirement: &12120360 !ruby/object:Gem::Requirement
27
+ requirement: &17816900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,14 +32,52 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *12120360
35
+ version_requirements: *17816900
36
36
  description: XDG provides an interface for using XDG directory standard.
37
37
  email:
38
38
  - transfire@gmail.com
39
39
  executables: []
40
40
  extensions: []
41
41
  extra_rdoc_files: []
42
- files: []
42
+ files:
43
+ - .gitignore
44
+ - .travis.yml
45
+ - .yardopts
46
+ - Assembly
47
+ - COPYING.rdoc
48
+ - DEMO.rdoc
49
+ - Gemfile
50
+ - HISTORY.rdoc
51
+ - LICENSE.txt
52
+ - MANIFEST
53
+ - README.rdoc
54
+ - Rakefile
55
+ - demo/01_base_dir.rdoc
56
+ - demo/02_base_dir_extended.rdoc
57
+ - demo/03_base_dir_mixin.rdoc
58
+ - demo/applique/ae.rb
59
+ - demo/applique/fakeroot.rb
60
+ - demo/applique/xdg.rb
61
+ - demo/fixtures/fakeroot/.cache/DUMMY.txt
62
+ - demo/fixtures/fakeroot/etc/xdg/bar.config
63
+ - demo/fixtures/fakeroot/home/.cache/foo.cache
64
+ - demo/fixtures/fakeroot/home/.local/share/foo.dat
65
+ - demo/fixtures/fakeroot/home/joe/foo.txt
66
+ - demo/fixtures/fakeroot/usr/share/bar.dat
67
+ - lib/xdg.rb
68
+ - lib/xdg/base_dir.rb
69
+ - lib/xdg/base_dir/extended.rb
70
+ - lib/xdg/base_dir/global_variables.rb
71
+ - lib/xdg/base_dir/legacy.rb
72
+ - lib/xdg/base_dir/mixin.rb
73
+ - lib/xdg/version.rb
74
+ - test/fakeroot/.cache/DUMMY.txt
75
+ - test/fakeroot/etc/xdg/bar.config
76
+ - test/fakeroot/home/.cache/foo.cache
77
+ - test/fakeroot/home/.local/share/foo.dat
78
+ - test/fakeroot/usr/share/bar.dat
79
+ - test/test_xdg_legacy.rb
80
+ - xdg.gemspec
43
81
  homepage: http://rubyworks.github.com/xdg
44
82
  licenses: []
45
83
  post_install_message:
@@ -64,4 +102,10 @@ rubygems_version: 1.8.11
64
102
  signing_key:
65
103
  specification_version: 3
66
104
  summary: XDG provides an interface for using XDG directory standard.
67
- test_files: []
105
+ test_files:
106
+ - test/fakeroot/.cache/DUMMY.txt
107
+ - test/fakeroot/etc/xdg/bar.config
108
+ - test/fakeroot/home/.cache/foo.cache
109
+ - test/fakeroot/home/.local/share/foo.dat
110
+ - test/fakeroot/usr/share/bar.dat
111
+ - test/test_xdg_legacy.rb