xdg 0.1.0
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.
- data/COPYING +168 -0
- data/MANIFEST +17 -0
- data/README +36 -0
- data/RELEASE +5 -0
- data/VERSION +1 -0
- data/doc/book/basedir-spec-0.6.html +138 -0
- data/lib/xdg.rb +133 -0
- data/meta/abstract +1 -0
- data/meta/authors +1 -0
- data/meta/contact +1 -0
- data/meta/homepage +1 -0
- data/meta/releases +1 -0
- data/meta/summary +1 -0
- metadata +83 -0
data/COPYING
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
.
|
|
2
|
+
|
|
3
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
4
|
+
Version 3, 29 June 2007
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
7
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
8
|
+
of this license document, but changing it is not allowed.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
This version of the GNU Lesser General Public License incorporates
|
|
12
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
13
|
+
License, supplemented by the additional permissions listed below.
|
|
14
|
+
|
|
15
|
+
0. Additional Definitions.
|
|
16
|
+
|
|
17
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
18
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
19
|
+
General Public License.
|
|
20
|
+
|
|
21
|
+
"The Library" refers to a covered work governed by this License,
|
|
22
|
+
other than an Application or a Combined Work as defined below.
|
|
23
|
+
|
|
24
|
+
An "Application" is any work that makes use of an interface provided
|
|
25
|
+
by the Library, but which is not otherwise based on the Library.
|
|
26
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
27
|
+
of using an interface provided by the Library.
|
|
28
|
+
|
|
29
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
30
|
+
Application with the Library. The particular version of the Library
|
|
31
|
+
with which the Combined Work was made is also called the "Linked
|
|
32
|
+
Version".
|
|
33
|
+
|
|
34
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
35
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
36
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
37
|
+
based on the Application, and not on the Linked Version.
|
|
38
|
+
|
|
39
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
40
|
+
object code and/or source code for the Application, including any data
|
|
41
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
42
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
43
|
+
|
|
44
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
45
|
+
|
|
46
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
47
|
+
without being bound by section 3 of the GNU GPL.
|
|
48
|
+
|
|
49
|
+
2. Conveying Modified Versions.
|
|
50
|
+
|
|
51
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
52
|
+
facility refers to a function or data to be supplied by an Application
|
|
53
|
+
that uses the facility (other than as an argument passed when the
|
|
54
|
+
facility is invoked), then you may convey a copy of the modified
|
|
55
|
+
version:
|
|
56
|
+
|
|
57
|
+
a) under this License, provided that you make a good faith effort to
|
|
58
|
+
ensure that, in the event an Application does not supply the
|
|
59
|
+
function or data, the facility still operates, and performs
|
|
60
|
+
whatever part of its purpose remains meaningful, or
|
|
61
|
+
|
|
62
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
63
|
+
this License applicable to that copy.
|
|
64
|
+
|
|
65
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
66
|
+
|
|
67
|
+
The object code form of an Application may incorporate material from
|
|
68
|
+
a header file that is part of the Library. You may convey such object
|
|
69
|
+
code under terms of your choice, provided that, if the incorporated
|
|
70
|
+
material is not limited to numerical parameters, data structure
|
|
71
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
72
|
+
(ten or fewer lines in length), you do both of the following:
|
|
73
|
+
|
|
74
|
+
a) Give prominent notice with each copy of the object code that the
|
|
75
|
+
Library is used in it and that the Library and its use are
|
|
76
|
+
covered by this License.
|
|
77
|
+
|
|
78
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
79
|
+
document.
|
|
80
|
+
|
|
81
|
+
4. Combined Works.
|
|
82
|
+
|
|
83
|
+
You may convey a Combined Work under terms of your choice that,
|
|
84
|
+
taken together, effectively do not restrict modification of the
|
|
85
|
+
portions of the Library contained in the Combined Work and reverse
|
|
86
|
+
engineering for debugging such modifications, if you also do each of
|
|
87
|
+
the following:
|
|
88
|
+
|
|
89
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
90
|
+
the Library is used in it and that the Library and its use are
|
|
91
|
+
covered by this License.
|
|
92
|
+
|
|
93
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
94
|
+
document.
|
|
95
|
+
|
|
96
|
+
c) For a Combined Work that displays copyright notices during
|
|
97
|
+
execution, include the copyright notice for the Library among
|
|
98
|
+
these notices, as well as a reference directing the user to the
|
|
99
|
+
copies of the GNU GPL and this license document.
|
|
100
|
+
|
|
101
|
+
d) Do one of the following:
|
|
102
|
+
|
|
103
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
104
|
+
License, and the Corresponding Application Code in a form
|
|
105
|
+
suitable for, and under terms that permit, the user to
|
|
106
|
+
recombine or relink the Application with a modified version of
|
|
107
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
108
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
109
|
+
Corresponding Source.
|
|
110
|
+
|
|
111
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
112
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
113
|
+
a copy of the Library already present on the user's computer
|
|
114
|
+
system, and (b) will operate properly with a modified version
|
|
115
|
+
of the Library that is interface-compatible with the Linked
|
|
116
|
+
Version.
|
|
117
|
+
|
|
118
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
119
|
+
be required to provide such information under section 6 of the
|
|
120
|
+
GNU GPL, and only to the extent that such information is
|
|
121
|
+
necessary to install and execute a modified version of the
|
|
122
|
+
Combined Work produced by recombining or relinking the
|
|
123
|
+
Application with a modified version of the Linked Version. (If
|
|
124
|
+
you use option 4d0, the Installation Information must accompany
|
|
125
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
126
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
127
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
128
|
+
for conveying Corresponding Source.)
|
|
129
|
+
|
|
130
|
+
5. Combined Libraries.
|
|
131
|
+
|
|
132
|
+
You may place library facilities that are a work based on the
|
|
133
|
+
Library side by side in a single library together with other library
|
|
134
|
+
facilities that are not Applications and are not covered by this
|
|
135
|
+
License, and convey such a combined library under terms of your
|
|
136
|
+
choice, if you do both of the following:
|
|
137
|
+
|
|
138
|
+
a) Accompany the combined library with a copy of the same work based
|
|
139
|
+
on the Library, uncombined with any other library facilities,
|
|
140
|
+
conveyed under the terms of this License.
|
|
141
|
+
|
|
142
|
+
b) Give prominent notice with the combined library that part of it
|
|
143
|
+
is a work based on the Library, and explaining where to find the
|
|
144
|
+
accompanying uncombined form of the same work.
|
|
145
|
+
|
|
146
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
147
|
+
|
|
148
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
149
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
150
|
+
versions will be similar in spirit to the present version, but may
|
|
151
|
+
differ in detail to address new problems or concerns.
|
|
152
|
+
|
|
153
|
+
Each version is given a distinguishing version number. If the
|
|
154
|
+
Library as you received it specifies that a certain numbered version
|
|
155
|
+
of the GNU Lesser General Public License "or any later version"
|
|
156
|
+
applies to it, you have the option of following the terms and
|
|
157
|
+
conditions either of that published version or of any later version
|
|
158
|
+
published by the Free Software Foundation. If the Library as you
|
|
159
|
+
received it does not specify a version number of the GNU Lesser
|
|
160
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
161
|
+
General Public License ever published by the Free Software Foundation.
|
|
162
|
+
|
|
163
|
+
If the Library as you received it specifies that a proxy can decide
|
|
164
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
165
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
166
|
+
permanent authorization for you to choose that version for the
|
|
167
|
+
Library.
|
|
168
|
+
|
data/MANIFEST
ADDED
data/README
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
= XDG
|
|
2
|
+
|
|
3
|
+
XDG provides an easy to use interface for utilizing
|
|
4
|
+
the XDG Base Base Directory Standards.
|
|
5
|
+
|
|
6
|
+
== Usage
|
|
7
|
+
|
|
8
|
+
XDG is a module with a small set of easy to understand
|
|
9
|
+
module methods, so it very easy to use.
|
|
10
|
+
|
|
11
|
+
See RDOC's for more information.
|
|
12
|
+
|
|
13
|
+
== Installation
|
|
14
|
+
|
|
15
|
+
=== RubyGems
|
|
16
|
+
|
|
17
|
+
$ gem install xdg
|
|
18
|
+
|
|
19
|
+
=== Tarball
|
|
20
|
+
|
|
21
|
+
Installing the tarball requires Ruby Setup
|
|
22
|
+
(see http://setup.rubyforge.org).
|
|
23
|
+
|
|
24
|
+
$ tar -xvzf xdg-0.1.0
|
|
25
|
+
$ cd xdg-0.1.0
|
|
26
|
+
$ setup.rb all
|
|
27
|
+
|
|
28
|
+
== Development
|
|
29
|
+
|
|
30
|
+
Visit http://rubyforge.org/projects/xdg
|
|
31
|
+
|
|
32
|
+
== Copyright
|
|
33
|
+
|
|
34
|
+
Copyright (c) 2008 Tiger Ops / 7rans
|
|
35
|
+
Distributed under the terms of the MIT license.
|
|
36
|
+
|
data/RELEASE
ADDED
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
xdg 0.1.0 beta (2008-09-27)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>XDG Base Directory Specification</title><meta name="generator" content="DocBook XSL Stylesheets V1.66.1"></head><body link="#0000ff" alink="#0000ff" bgcolor="white" text="black" vlink="#840084"><div class="article" lang="en"><div class="titlepage"><div><div><h1 class="title"><a name="index"></a>XDG Base Directory Specification</h1></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Waldo</span> <span class="surname">Bastian</span></h3><div class="affiliation"><div class="address"><p><br>
|
|
2
|
+
<tt class="email"><<a href="mailto:bastian@kde.org">bastian@kde.org</a>></tt><br>
|
|
3
|
+
</p></div></div></div></div></div><div><p class="releaseinfo">Version 0.6</p></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#introduction">Introduction</a></span></dt><dt><span class="sect1"><a href="#basics">Basics</a></span></dt><dt><span class="sect1"><a href="#variables">Environment variables</a></span></dt><dt><span class="sect1"><a href="#referencing">Referencing this specification</a></span></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;"><a name="introduction"></a>Introduction</h2></div></div></div><p>
|
|
4
|
+
Various specifications specify files and file formats. This
|
|
5
|
+
specification defines where these files should be looked for by
|
|
6
|
+
defining one or more base directories relative to which files
|
|
7
|
+
should be located.
|
|
8
|
+
</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;"><a name="basics"></a>Basics</h2></div></div></div><p>
|
|
9
|
+
The XDG Base Directory Specification is based on the following concepts:
|
|
10
|
+
</p><div class="itemizedlist"><ul type="disc"><li><p>
|
|
11
|
+
There is a single base directory relative to which user-specific
|
|
12
|
+
data files should be written. This directory is defined by the
|
|
13
|
+
environment variable <tt class="literal">$XDG_DATA_HOME</tt>.
|
|
14
|
+
</p></li><li><p>
|
|
15
|
+
There is a single base directory relative to which user-specific
|
|
16
|
+
configuration files should be written. This directory is defined by the
|
|
17
|
+
environment variable <tt class="literal">$XDG_CONFIG_HOME</tt>.
|
|
18
|
+
</p></li><li><p>
|
|
19
|
+
There is a set of preference ordered base directories relative to
|
|
20
|
+
which data files should be searched. This set of directories is defined
|
|
21
|
+
by the environment variable <tt class="literal">$XDG_DATA_DIRS</tt>.
|
|
22
|
+
</p></li><li><p>
|
|
23
|
+
There is a set of preference ordered base directories relative to
|
|
24
|
+
which configuration files should be searched.
|
|
25
|
+
This set of directories is defined
|
|
26
|
+
by the environment variable <tt class="literal">$XDG_CONFIG_DIRS</tt>.
|
|
27
|
+
</p></li><li><p>
|
|
28
|
+
There is a single base directory relative to which user-specific
|
|
29
|
+
non-essential (cached) data should be written.
|
|
30
|
+
This directory is defined by the
|
|
31
|
+
environment variable <tt class="literal">$XDG_CACHE_HOME</tt>.
|
|
32
|
+
</p></li></ul></div><p>
|
|
33
|
+
</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;"><a name="variables"></a>Environment variables</h2></div></div></div><p>
|
|
34
|
+
<tt class="literal">$XDG_DATA_HOME</tt> defines the base directory relative to
|
|
35
|
+
which user specific data files should be stored. If
|
|
36
|
+
<tt class="literal">$XDG_DATA_HOME</tt> is either not set or empty, a default equal to
|
|
37
|
+
<tt class="literal">$HOME</tt>/.local/share should be used.
|
|
38
|
+
</p><p>
|
|
39
|
+
<tt class="literal">$XDG_CONFIG_HOME</tt> defines the base directory relative to
|
|
40
|
+
which user specific configuration files should be stored. If
|
|
41
|
+
<tt class="literal">$XDG_CONFIG_HOME</tt> is either not set or empty, a default equal to
|
|
42
|
+
<tt class="literal">$HOME</tt>/.config should be used.
|
|
43
|
+
</p><p>
|
|
44
|
+
<tt class="literal">$XDG_DATA_DIRS</tt> defines the preference-ordered set of
|
|
45
|
+
base directories to search for data files in addition to the
|
|
46
|
+
<tt class="literal">$XDG_DATA_HOME</tt> base directory.
|
|
47
|
+
The directories in <tt class="literal">$XDG_DATA_DIRS</tt> should be seperated
|
|
48
|
+
with a colon ':'.
|
|
49
|
+
</p><p>
|
|
50
|
+
If <tt class="literal">$XDG_DATA_DIRS</tt> is either not set or empty, a value equal to
|
|
51
|
+
/usr/local/share/:/usr/share/ should be used.
|
|
52
|
+
</p><p>
|
|
53
|
+
<tt class="literal">$XDG_CONFIG_DIRS</tt> defines the preference-ordered set of
|
|
54
|
+
base directories to search for configuration files in addition to the
|
|
55
|
+
<tt class="literal">$XDG_CONFIG_HOME</tt> base directory.
|
|
56
|
+
The directories in <tt class="literal">$XDG_CONFIG_DIRS</tt> should be seperated
|
|
57
|
+
with a colon ':'.
|
|
58
|
+
</p><p>
|
|
59
|
+
If <tt class="literal">$XDG_CONFIG_DIRS</tt> is either not set or empty, a value equal to
|
|
60
|
+
/etc/xdg should be used.
|
|
61
|
+
</p><p>
|
|
62
|
+
The order of base directories denotes their importance; the first
|
|
63
|
+
directory listed is the most important. When the same information is
|
|
64
|
+
defined in multiple places the information defined relative to the more
|
|
65
|
+
important base directory takes precedent. The base directory defined
|
|
66
|
+
by <tt class="literal">$XDG_DATA_HOME</tt> is considered more important than
|
|
67
|
+
any of the base directories defined by <tt class="literal">$XDG_DATA_DIRS</tt>.
|
|
68
|
+
The base directory defined
|
|
69
|
+
by <tt class="literal">$XDG_CONFIG_HOME</tt> is considered more important than
|
|
70
|
+
any of the base directories defined by <tt class="literal">$XDG_CONFIG_DIRS</tt>.
|
|
71
|
+
</p><p>
|
|
72
|
+
<tt class="literal">$XDG_CACHE_HOME</tt> defines the base directory relative to
|
|
73
|
+
which user specific non-essential data files should be stored. If
|
|
74
|
+
<tt class="literal">$XDG_CACHE_HOME</tt> is either not set or empty, a default equal to
|
|
75
|
+
<tt class="literal">$HOME</tt>/.cache should be used.
|
|
76
|
+
</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;"><a name="referencing"></a>Referencing this specification</h2></div></div></div><p>
|
|
77
|
+
Other specifications may reference this specification by specifying the
|
|
78
|
+
location of a data file as
|
|
79
|
+
<tt class="literal">$XDG_DATA_DIRS</tt>/subdir/filename. This implies that:
|
|
80
|
+
</p><div class="itemizedlist"><ul type="disc"><li><p>
|
|
81
|
+
Such file should be installed to <tt class="literal">$datadir</tt>/subdir/filename
|
|
82
|
+
with <tt class="literal">$datadir</tt> defaulting to /usr/share.
|
|
83
|
+
</p></li><li><p>
|
|
84
|
+
A user specific version of the data file may be created in
|
|
85
|
+
<tt class="literal">$XDG_DATA_HOME</tt>/subdir/filename, taking into
|
|
86
|
+
account the default value for <tt class="literal">$XDG_DATA_HOME</tt> if
|
|
87
|
+
<tt class="literal">$XDG_DATA_HOME</tt> is not set.
|
|
88
|
+
</p></li><li><p>
|
|
89
|
+
Lookups of the data file should search for ./subdir/filename relative to
|
|
90
|
+
all base directories specified by <tt class="literal">$XDG_DATA_HOME</tt> and
|
|
91
|
+
<tt class="literal">$XDG_DATA_DIRS</tt> . If an environment
|
|
92
|
+
variable is either not set or empty, its default value as defined by this specification
|
|
93
|
+
should be used instead.
|
|
94
|
+
</p></li></ul></div><p>
|
|
95
|
+
</p><p>
|
|
96
|
+
Specifications may reference this specification by specifying the
|
|
97
|
+
location of a configuration file as
|
|
98
|
+
<tt class="literal">$XDG_CONFIG_DIRS</tt>/subdir/filename. This implies that:
|
|
99
|
+
</p><div class="itemizedlist"><ul type="disc"><li><p>
|
|
100
|
+
Default configuration files should be installed to <tt class="literal">$sysconfdir</tt>/xdg/subdir/filename
|
|
101
|
+
with <tt class="literal">$sysconfdir</tt> defaulting to /etc.
|
|
102
|
+
</p></li><li><p>
|
|
103
|
+
A user specific version of the configuration file may be created in
|
|
104
|
+
<tt class="literal">$XDG_CONFIG_HOME</tt>/subdir/filename, taking into
|
|
105
|
+
account the default value for <tt class="literal">$XDG_CONFIG_HOME</tt> if
|
|
106
|
+
<tt class="literal">$XDG_CONFIG_HOME</tt> is not set.
|
|
107
|
+
</p></li><li><p>
|
|
108
|
+
Lookups of the configuration file should search for ./subdir/filename relative to
|
|
109
|
+
all base directories indicated by <tt class="literal">$XDG_CONFIG_HOME</tt> and
|
|
110
|
+
<tt class="literal">$XDG_CONFIG_DIRS</tt> . If an environment
|
|
111
|
+
variable is either not set or empty, its default value as defined by this specification
|
|
112
|
+
should be used instead.
|
|
113
|
+
</p></li></ul></div><p>
|
|
114
|
+
</p><p>
|
|
115
|
+
If, when attempting to write a file, the destination
|
|
116
|
+
directory is non-existant an attempt should be made to create it
|
|
117
|
+
with permission <tt class="literal">0700</tt>. If the destination directory
|
|
118
|
+
exists already the permissions should not be changed.
|
|
119
|
+
The application should be prepared to handle the case where the file
|
|
120
|
+
could not be written, either because the directory was non-existant
|
|
121
|
+
and could not be created, or for any other reason. In such case it
|
|
122
|
+
may chose to present an error message to the user.
|
|
123
|
+
</p><p>
|
|
124
|
+
When attempting to read a file, if for any reason a file in a certain
|
|
125
|
+
directory is unaccessible, e.g. because the directory is non-existant,
|
|
126
|
+
the file is non-existant or the user is not authorized to open the file,
|
|
127
|
+
then the processing of the file in that directory should be skipped.
|
|
128
|
+
If due to this a required file could not be found at all, the
|
|
129
|
+
application may chose to present an error message to the user.
|
|
130
|
+
</p><p>
|
|
131
|
+
A specification that refers to <tt class="literal">$XDG_DATA_DIRS</tt> or
|
|
132
|
+
<tt class="literal">$XDG_CONFIG_DIRS</tt> should define what the behaviour
|
|
133
|
+
must be when a file is located under multiple base directories.
|
|
134
|
+
It could, for example, define that only the file under the most
|
|
135
|
+
important base directory should be used or, as another example,
|
|
136
|
+
it could define rules for merging the information from the different
|
|
137
|
+
files.
|
|
138
|
+
</p></div></div></body></html>
|
data/lib/xdg.rb
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# :Title: XDG
|
|
2
|
+
# :Author: &trans;
|
|
3
|
+
# :Copyright: (c)2008 Tiger Ops
|
|
4
|
+
# :License: GPLv3
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# = XDG Base Directory Standard
|
|
8
|
+
#
|
|
9
|
+
# This provides a conveient library for conforming to the
|
|
10
|
+
# XDG Base Directory Standard.
|
|
11
|
+
#
|
|
12
|
+
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
13
|
+
#
|
|
14
|
+
# Some important clarifications, not made clear by the
|
|
15
|
+
# above specification.
|
|
16
|
+
#
|
|
17
|
+
# The data directories are for "read-only" files. In other words once
|
|
18
|
+
# something is put there, it should only be read, never written to
|
|
19
|
+
# by a program. (Generally speaking only users or pacakge mangers should
|
|
20
|
+
# be adding, changing or removing files from the data locations.
|
|
21
|
+
#
|
|
22
|
+
# The config locations are where you should store files that may change,
|
|
23
|
+
# and effect operations depending one there content. This is like etc/
|
|
24
|
+
# in the FHS, but alterable by end users and and end user programs,
|
|
25
|
+
# not just root and sudo admin scripts.
|
|
26
|
+
#
|
|
27
|
+
# The cache location stores files that could judt as well be deleted
|
|
28
|
+
# and everyihtng still works find. This is for variable and temporary
|
|
29
|
+
# files. Like var/ in FHS.
|
|
30
|
+
#
|
|
31
|
+
# This module returns paths as strings.
|
|
32
|
+
|
|
33
|
+
module XDG
|
|
34
|
+
|
|
35
|
+
###############
|
|
36
|
+
module_function
|
|
37
|
+
###############
|
|
38
|
+
|
|
39
|
+
def xdg_home
|
|
40
|
+
ENV['HOME'] || File.expand_path('~')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Location of user's personal config directory.
|
|
44
|
+
def xdg_config_home
|
|
45
|
+
File.expand_path(
|
|
46
|
+
ENV['XDG_CONFIG_HOME'] || File.join(xdg_home, '.config')
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# List of user's shared config directories.
|
|
51
|
+
def xdg_config_dirs
|
|
52
|
+
dirs = ENV['XDG_CONFIG_DIRS'].split(/[:;]/)
|
|
53
|
+
if dirs.empty?
|
|
54
|
+
dirs = %w{/etc/xdg}
|
|
55
|
+
end
|
|
56
|
+
dir.collect{ |d| File.expand_path(d) }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Location of user's personal data directory.
|
|
60
|
+
def xdg_data_home
|
|
61
|
+
File.expand_path(
|
|
62
|
+
ENV['XDG_DATA_HOME'] || File.join(xdg_home, '.local', 'share')
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# List of user's shared data directores.
|
|
67
|
+
def xdg_data_dirs
|
|
68
|
+
dirs = ENV['XDG_DATA_DIRS'].split(/[:;]/)
|
|
69
|
+
if dirs.empty?
|
|
70
|
+
dirs = %w{/usr/local/share/ /usr/share/}
|
|
71
|
+
end
|
|
72
|
+
dir.collect{ |d| File.expand_path(d) }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Location of user's personal cache directory.
|
|
76
|
+
def xdg_cache_home
|
|
77
|
+
File.expand_path(
|
|
78
|
+
ENV['XDG_CACHE_HOME'] || File.join(xdg_home, '.cache')
|
|
79
|
+
)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Find a file or directory in data dirs.
|
|
83
|
+
def xdg_data_file(file)
|
|
84
|
+
[data_home, *data_dirs].each do |dir|
|
|
85
|
+
path = File.join(dir,file)
|
|
86
|
+
break path if File.exist?(path)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Find a file or directory in config dirs.
|
|
91
|
+
def xdg_config_file(file)
|
|
92
|
+
[config_home, *config_dirs].each do |dir|
|
|
93
|
+
path = File.join(dir,file)
|
|
94
|
+
break path if File.exist?(path)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Find a file or directory in the user cache.
|
|
99
|
+
def xdg_cache_file(file)
|
|
100
|
+
File.join(cache_home,file)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
############################################
|
|
104
|
+
# The following are not strictly XDG spec, #
|
|
105
|
+
# but are useful in the same respect. #
|
|
106
|
+
############################################
|
|
107
|
+
|
|
108
|
+
# Location of working config directory.
|
|
109
|
+
def xdg_config_work
|
|
110
|
+
File.expand_path(
|
|
111
|
+
#ENV['XDG_CONFIG_WORK'] || File.join(Dir.pwd, '.config')
|
|
112
|
+
File.join(Dir.pwd, '.config')
|
|
113
|
+
)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Location of working data directory.
|
|
117
|
+
def xdg_data_work
|
|
118
|
+
File.expand_path(
|
|
119
|
+
#ENV['XDG_DATA_WORK'] || File.join(Dir.pwd, '.share')
|
|
120
|
+
File.join(Dir.pwd, '.share')
|
|
121
|
+
)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Location of working cache directory.
|
|
125
|
+
def xdg_cache_work
|
|
126
|
+
File.expand_path(
|
|
127
|
+
#ENV['XDG_CACHE_WORK'] || File.join(Dir.pwd, '.cache')
|
|
128
|
+
File.join(Dir.pwd, '.cache')
|
|
129
|
+
)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
end # module XDG
|
|
133
|
+
|
data/meta/abstract
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
XDG provides and interface for using the XDG directory standard.
|
data/meta/authors
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7rans <transfire@gmail.com>
|
data/meta/contact
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tigerops-community@rubyforge.org
|
data/meta/homepage
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
http://xdg.rubyforge.org
|
data/meta/releases
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
data/meta/summary
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
XDG provides an interface for using XDG directory standard.
|
metadata
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: xdg
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- |
|
|
8
|
+
tigerops-community@rubyforge.org
|
|
9
|
+
|
|
10
|
+
- 7rans <transfire@gmail.com>
|
|
11
|
+
autorequire:
|
|
12
|
+
bindir: bin
|
|
13
|
+
cert_chain: []
|
|
14
|
+
|
|
15
|
+
date: 2008-09-27 00:00:00 -04:00
|
|
16
|
+
default_executable:
|
|
17
|
+
dependencies: []
|
|
18
|
+
|
|
19
|
+
description: XDG provides and interface for using the XDG directory standard.
|
|
20
|
+
email:
|
|
21
|
+
executables: []
|
|
22
|
+
|
|
23
|
+
extensions: []
|
|
24
|
+
|
|
25
|
+
extra_rdoc_files:
|
|
26
|
+
- README
|
|
27
|
+
- MANIFEST
|
|
28
|
+
- RELEASE
|
|
29
|
+
- VERSION
|
|
30
|
+
- COPYING
|
|
31
|
+
files:
|
|
32
|
+
- doc
|
|
33
|
+
- doc/book
|
|
34
|
+
- doc/book/basedir-spec-0.6.html
|
|
35
|
+
- MANIFEST
|
|
36
|
+
- test
|
|
37
|
+
- RELEASE
|
|
38
|
+
- README
|
|
39
|
+
- meta
|
|
40
|
+
- meta/homepage
|
|
41
|
+
- meta/summary
|
|
42
|
+
- meta/abstract
|
|
43
|
+
- meta/releases
|
|
44
|
+
- meta/authors
|
|
45
|
+
- meta/contact
|
|
46
|
+
- lib
|
|
47
|
+
- lib/xdg.rb
|
|
48
|
+
- VERSION
|
|
49
|
+
- COPYING
|
|
50
|
+
has_rdoc: true
|
|
51
|
+
homepage: |
|
|
52
|
+
http://xdg.rubyforge.org
|
|
53
|
+
|
|
54
|
+
post_install_message:
|
|
55
|
+
rdoc_options:
|
|
56
|
+
- --inline-source
|
|
57
|
+
- --title
|
|
58
|
+
- xdg api
|
|
59
|
+
- --main
|
|
60
|
+
- README
|
|
61
|
+
require_paths:
|
|
62
|
+
- lib
|
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: "0"
|
|
68
|
+
version:
|
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: "0"
|
|
74
|
+
version:
|
|
75
|
+
requirements: []
|
|
76
|
+
|
|
77
|
+
rubyforge_project: xdg
|
|
78
|
+
rubygems_version: 1.2.0
|
|
79
|
+
signing_key:
|
|
80
|
+
specification_version: 2
|
|
81
|
+
summary: XDG provides and interface for using the XDG directory standard.
|
|
82
|
+
test_files: []
|
|
83
|
+
|