dirtravel 0.0.5 → 0.0.6
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.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +2 -2
- data/doc/DirTravel.html +105 -20
- data/doc/DirTravel/DirEntry.html +14 -14
- data/doc/DirTravel/DirTravelError.html +15 -4
- data/doc/DirTravel/Entry.html +90 -90
- data/doc/DirTravel/FileEntry.html +40 -20
- data/doc/DirTravel/Travel.html +231 -109
- data/doc/_index.html +5 -5
- data/doc/class_list.html +6 -1
- data/doc/css/style.css +2 -1
- data/doc/file.CHANGELOG.html +14 -11
- data/doc/file.README.html +10 -10
- data/doc/file_list.html +6 -1
- data/doc/frames.html +5 -7
- data/doc/index.html +10 -10
- data/doc/js/app.js +7 -2
- data/doc/js/full_list.js +9 -6
- data/doc/method_list.html +12 -1
- data/doc/top-level-namespace.html +4 -4
- data/lib/dirtravel.rb +99 -40
- data/lib/version.rb +6 -0
- data/test/test_dirtravel.rb +5 -5
- metadata +34 -31
- data/Rakefile +0 -28
data/doc/_index.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<head>
|
5
5
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
6
|
<title>
|
7
|
-
Documentation by YARD 0.8.6
|
7
|
+
Documentation by YARD 0.8.7.6
|
8
8
|
|
9
9
|
</title>
|
10
10
|
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<script type="text/javascript" charset="utf-8">
|
16
16
|
hasFrames = window.top.frames.main ? true : false;
|
17
17
|
relpath = '';
|
18
|
-
framesUrl = "frames.html#!"
|
18
|
+
framesUrl = "frames.html#!_index.html";
|
19
19
|
</script>
|
20
20
|
|
21
21
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
<iframe id="search_frame"></iframe>
|
58
58
|
|
59
|
-
<div id="content"><h1 class="noborder title">Documentation by YARD 0.8.6
|
59
|
+
<div id="content"><h1 class="noborder title">Documentation by YARD 0.8.7.6</h1>
|
60
60
|
<div id="listing">
|
61
61
|
<h1 class="alphaindex">Alphabetic Index</h1>
|
62
62
|
|
@@ -163,9 +163,9 @@
|
|
163
163
|
</div>
|
164
164
|
|
165
165
|
<div id="footer">
|
166
|
-
Generated on
|
166
|
+
Generated on Sun Apr 19 15:01:49 2015 by
|
167
167
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
168
|
-
0.8.6
|
168
|
+
0.8.7.6 (ruby-2.1.2).
|
169
169
|
</div>
|
170
170
|
|
171
171
|
</body>
|
data/doc/class_list.html
CHANGED
@@ -15,11 +15,16 @@
|
|
15
15
|
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
16
|
|
17
17
|
|
18
|
+
<title>Class List</title>
|
18
19
|
<base id="base_target" target="_parent" />
|
19
20
|
</head>
|
20
21
|
<body>
|
21
22
|
<script type="text/javascript" charset="utf-8">
|
22
|
-
|
23
|
+
var hasFrames = false;
|
24
|
+
try {
|
25
|
+
hasFrames = window.top.frames.main ? true : false;
|
26
|
+
} catch (e) { }
|
27
|
+
if (hasFrames) {
|
23
28
|
document.getElementById('base_target').target = 'main';
|
24
29
|
document.body.className = 'frames';
|
25
30
|
}
|
data/doc/css/style.css
CHANGED
@@ -291,6 +291,7 @@ li.r2 { background: #fafafa; }
|
|
291
291
|
-moz-box-shadow: -2px 2px 6px #bbb;
|
292
292
|
z-index: 5000;
|
293
293
|
position: relative;
|
294
|
+
overflow-x: auto;
|
294
295
|
}
|
295
296
|
#toc.nofloat { float: none; max-width: none; border: none; padding: 0; margin: 20px 0; -webkit-box-shadow: none; -moz-box-shadow: none; }
|
296
297
|
#toc.nofloat.hidden { padding: 0; background: 0; margin-bottom: 5px; }
|
@@ -324,9 +325,9 @@ pre.code .dot + pre.code .id,
|
|
324
325
|
pre.code .rubyid_to_i pre.code .rubyid_each { color: #0085FF; }
|
325
326
|
pre.code .comment { color: #0066FF; }
|
326
327
|
pre.code .const, pre.code .constant { color: #585CF6; }
|
328
|
+
pre.code .label,
|
327
329
|
pre.code .symbol { color: #C5060B; }
|
328
330
|
pre.code .kw,
|
329
|
-
pre.code .label,
|
330
331
|
pre.code .rubyid_require,
|
331
332
|
pre.code .rubyid_extend,
|
332
333
|
pre.code .rubyid_include { color: #0000FF; }
|
data/doc/file.CHANGELOG.html
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
4
|
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
6
|
<title>
|
7
7
|
File: CHANGELOG
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.6
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
18
|
hasFrames = window.top.frames.main ? true : false;
|
19
19
|
relpath = '';
|
20
|
-
framesUrl = "frames.html#!
|
20
|
+
framesUrl = "frames.html#!file.CHANGELOG.html";
|
21
21
|
</script>
|
22
22
|
|
23
23
|
|
@@ -62,30 +62,33 @@
|
|
62
62
|
<iframe id="search_frame"></iframe>
|
63
63
|
|
64
64
|
<div id="content"><div id='filecontents'>
|
65
|
-
<h1>Version history</h1>
|
66
|
-
<dl class="rdoc-list"><dt>0.0.
|
65
|
+
<h1 id="label-Version+history">Version history</h1>
|
66
|
+
<dl class="rdoc-list label-list"><dt>0.0.6
|
67
|
+
<dd>
|
68
|
+
<p>Test file bugfix. Document improvements.</p>
|
69
|
+
</dd><dt>0.0.5
|
67
70
|
<dd>
|
68
71
|
<p>Abspath as Travel data member.</p>
|
69
|
-
</dd><dt>0.0.4
|
72
|
+
</dd><dt>0.0.4
|
70
73
|
<dd>
|
71
74
|
<p>Fix for relative path conversion in Travel.filetree.</p>
|
72
|
-
</dd><dt>0.0.3
|
75
|
+
</dd><dt>0.0.3
|
73
76
|
<dd>
|
74
77
|
<p>Entry#tip, Entry#relative?, Entry#rename methods added. New option for
|
75
78
|
Travel.filetree, :inclusive. It uses one-up directory as root.</p>
|
76
|
-
</dd><dt>0.0.2
|
79
|
+
</dd><dt>0.0.2
|
77
80
|
<dd>
|
78
81
|
<p>Comment typo.</p>
|
79
|
-
</dd><dt>0.0.1
|
82
|
+
</dd><dt>0.0.1
|
80
83
|
<dd>
|
81
84
|
<p>Initial version.</p>
|
82
85
|
</dd></dl>
|
83
86
|
</div></div>
|
84
87
|
|
85
88
|
<div id="footer">
|
86
|
-
Generated on
|
89
|
+
Generated on Sun Apr 19 15:01:49 2015 by
|
87
90
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
88
|
-
0.8.6
|
91
|
+
0.8.7.6 (ruby-2.1.2).
|
89
92
|
</div>
|
90
93
|
|
91
94
|
</body>
|
data/doc/file.README.html
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
4
|
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.6
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
18
|
hasFrames = window.top.frames.main ? true : false;
|
19
19
|
relpath = '';
|
20
|
-
framesUrl = "frames.html#!
|
20
|
+
framesUrl = "frames.html#!file.README.html";
|
21
21
|
</script>
|
22
22
|
|
23
23
|
|
@@ -62,22 +62,22 @@
|
|
62
62
|
<iframe id="search_frame"></iframe>
|
63
63
|
|
64
64
|
<div id="content"><div id='filecontents'>
|
65
|
-
<h1>DirTravel</h1>
|
65
|
+
<h1 id="label-DirTravel">DirTravel</h1>
|
66
66
|
|
67
|
-
<h2>Description</h2>
|
67
|
+
<h2 id="label-Description">Description</h2>
|
68
68
|
|
69
|
-
<p>DirTravel provides filesystem directory content organized as a RubyTree
|
69
|
+
<p><span class='object_link'><a href="DirTravel.html" title="DirTravel (module)">DirTravel</a></span> provides filesystem directory content organized as a RubyTree
|
70
70
|
structure. This structure can be conveniently accessed in various ways.</p>
|
71
71
|
|
72
|
-
<h2>Documentation</h2>
|
72
|
+
<h2 id="label-Documentation">Documentation</h2>
|
73
73
|
|
74
|
-
<p>Main documentation is generated from DirTravel source.</p>
|
74
|
+
<p>Main documentation is generated from <span class='object_link'><a href="DirTravel.html" title="DirTravel (module)">DirTravel</a></span> source.</p>
|
75
75
|
</div></div>
|
76
76
|
|
77
77
|
<div id="footer">
|
78
|
-
Generated on
|
78
|
+
Generated on Sun Apr 19 15:01:49 2015 by
|
79
79
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
80
|
-
0.8.6
|
80
|
+
0.8.7.6 (ruby-2.1.2).
|
81
81
|
</div>
|
82
82
|
|
83
83
|
</body>
|
data/doc/file_list.html
CHANGED
@@ -15,11 +15,16 @@
|
|
15
15
|
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
16
|
|
17
17
|
|
18
|
+
<title>File List</title>
|
18
19
|
<base id="base_target" target="_parent" />
|
19
20
|
</head>
|
20
21
|
<body>
|
21
22
|
<script type="text/javascript" charset="utf-8">
|
22
|
-
|
23
|
+
var hasFrames = false;
|
24
|
+
try {
|
25
|
+
hasFrames = window.top.frames.main ? true : false;
|
26
|
+
} catch (e) { }
|
27
|
+
if (hasFrames) {
|
23
28
|
document.getElementById('base_target').target = 'main';
|
24
29
|
document.body.className = 'frames';
|
25
30
|
}
|
data/doc/frames.html
CHANGED
@@ -4,18 +4,16 @@
|
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
5
|
<head>
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
-
<title>Documentation by YARD 0.8.6
|
7
|
+
<title>Documentation by YARD 0.8.7.6</title>
|
8
8
|
</head>
|
9
9
|
<script type="text/javascript" charset="utf-8">
|
10
10
|
window.onload = function() {
|
11
|
-
var match = window.location.hash.match(/^#!(.+)/);
|
12
|
-
var name = 'index.html';
|
13
|
-
|
14
|
-
name = unescape(match[1]);
|
15
|
-
}
|
11
|
+
var match = unescape(window.location.hash).match(/^#!(.+)/);
|
12
|
+
var name = match ? match[1] : 'index.html';
|
13
|
+
name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
|
16
14
|
document.writeln('<frameset cols="20%,*">' +
|
17
15
|
'<frame name="list" src="class_list.html" />' +
|
18
|
-
'<frame name="main" src="' + name + '" />' +
|
16
|
+
'<frame name="main" src="' + escape(name) + '" />' +
|
19
17
|
'</frameset>');
|
20
18
|
}
|
21
19
|
</script>
|
data/doc/index.html
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
4
|
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.6
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
18
|
hasFrames = window.top.frames.main ? true : false;
|
19
19
|
relpath = '';
|
20
|
-
framesUrl = "frames.html#!
|
20
|
+
framesUrl = "frames.html#!file.README.html";
|
21
21
|
</script>
|
22
22
|
|
23
23
|
|
@@ -62,22 +62,22 @@
|
|
62
62
|
<iframe id="search_frame"></iframe>
|
63
63
|
|
64
64
|
<div id="content"><div id='filecontents'>
|
65
|
-
<h1>DirTravel</h1>
|
65
|
+
<h1 id="label-DirTravel">DirTravel</h1>
|
66
66
|
|
67
|
-
<h2>Description</h2>
|
67
|
+
<h2 id="label-Description">Description</h2>
|
68
68
|
|
69
|
-
<p>DirTravel provides filesystem directory content organized as a RubyTree
|
69
|
+
<p><span class='object_link'><a href="DirTravel.html" title="DirTravel (module)">DirTravel</a></span> provides filesystem directory content organized as a RubyTree
|
70
70
|
structure. This structure can be conveniently accessed in various ways.</p>
|
71
71
|
|
72
|
-
<h2>Documentation</h2>
|
72
|
+
<h2 id="label-Documentation">Documentation</h2>
|
73
73
|
|
74
|
-
<p>Main documentation is generated from DirTravel source.</p>
|
74
|
+
<p>Main documentation is generated from <span class='object_link'><a href="DirTravel.html" title="DirTravel (module)">DirTravel</a></span> source.</p>
|
75
75
|
</div></div>
|
76
76
|
|
77
77
|
<div id="footer">
|
78
|
-
Generated on
|
78
|
+
Generated on Sun Apr 19 15:01:49 2015 by
|
79
79
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
80
|
-
0.8.6
|
80
|
+
0.8.7.6 (ruby-2.1.2).
|
81
81
|
</div>
|
82
82
|
|
83
83
|
</body>
|
data/doc/js/app.js
CHANGED
@@ -78,7 +78,12 @@ function framesInit() {
|
|
78
78
|
if (hasFrames) {
|
79
79
|
document.body.className = 'frames';
|
80
80
|
$('#menu .noframes a').attr('href', document.location);
|
81
|
-
|
81
|
+
try {
|
82
|
+
window.top.document.title = $('html head title').text();
|
83
|
+
} catch(error) {
|
84
|
+
// some browsers will not allow this when serving from file://
|
85
|
+
// but we don't want to stop the world.
|
86
|
+
}
|
82
87
|
}
|
83
88
|
else {
|
84
89
|
$('#menu .noframes a').text('frames').attr('href', framesUrl);
|
@@ -211,4 +216,4 @@ $(linkSummaries);
|
|
211
216
|
$(keyboardShortcuts);
|
212
217
|
$(summaryToggle);
|
213
218
|
$(fixOutsideWorldLinks);
|
214
|
-
$(generateTOC);
|
219
|
+
$(generateTOC);
|
data/doc/js/full_list.js
CHANGED
@@ -111,11 +111,11 @@ clicked = null;
|
|
111
111
|
function linkList() {
|
112
112
|
$('#full_list li, #full_list li a:last').click(function(evt) {
|
113
113
|
if ($(this).hasClass('toggle')) return true;
|
114
|
-
if ($(this).find('.object_link a').length === 0) {
|
115
|
-
$(this).children('a.toggle').click();
|
116
|
-
return false;
|
117
|
-
}
|
118
114
|
if (this.tagName.toLowerCase() == "li") {
|
115
|
+
if ($(this).find('.object_link a').length === 0) {
|
116
|
+
$(this).children('a.toggle').click();
|
117
|
+
return false;
|
118
|
+
}
|
119
119
|
var toggle = $(this).children('a.toggle');
|
120
120
|
if (toggle.size() > 0 && evt.pageX < toggle.offset().left) {
|
121
121
|
toggle.click();
|
@@ -123,9 +123,12 @@ function linkList() {
|
|
123
123
|
}
|
124
124
|
}
|
125
125
|
if (clicked) clicked.removeClass('clicked');
|
126
|
-
var win
|
126
|
+
var win;
|
127
|
+
try {
|
128
|
+
win = window.top.frames.main ? window.top.frames.main : window.parent;
|
129
|
+
} catch (e) { win = window.parent; }
|
127
130
|
if (this.tagName.toLowerCase() == "a") {
|
128
|
-
clicked = $(this).
|
131
|
+
clicked = $(this).parents('li').addClass('clicked');
|
129
132
|
win.location = this.href;
|
130
133
|
}
|
131
134
|
else {
|
data/doc/method_list.html
CHANGED
@@ -15,11 +15,16 @@
|
|
15
15
|
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
16
|
|
17
17
|
|
18
|
+
<title>Method List</title>
|
18
19
|
<base id="base_target" target="_parent" />
|
19
20
|
</head>
|
20
21
|
<body>
|
21
22
|
<script type="text/javascript" charset="utf-8">
|
22
|
-
|
23
|
+
var hasFrames = false;
|
24
|
+
try {
|
25
|
+
hasFrames = window.top.frames.main ? true : false;
|
26
|
+
} catch (e) { }
|
27
|
+
if (hasFrames) {
|
23
28
|
document.getElementById('base_target').target = 'main';
|
24
29
|
document.body.className = 'frames';
|
25
30
|
}
|
@@ -190,6 +195,12 @@
|
|
190
195
|
</li>
|
191
196
|
|
192
197
|
|
198
|
+
<li class="r1 ">
|
199
|
+
<span class='object_link'><a href="DirTravel.html#version-class_method" title="DirTravel.version (method)">version</a></span>
|
200
|
+
<small>DirTravel</small>
|
201
|
+
</li>
|
202
|
+
|
203
|
+
|
193
204
|
</ul>
|
194
205
|
</div>
|
195
206
|
</body>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Top Level Namespace
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.6
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
18
|
hasFrames = window.top.frames.main ? true : false;
|
19
19
|
relpath = '';
|
20
|
-
framesUrl = "frames.html#!"
|
20
|
+
framesUrl = "frames.html#!top-level-namespace.html";
|
21
21
|
</script>
|
22
22
|
|
23
23
|
|
@@ -103,9 +103,9 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Sun Apr 19 15:01:49 2015 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
|
-
0.8.6
|
108
|
+
0.8.7.6 (ruby-2.1.2).
|
109
109
|
</div>
|
110
110
|
|
111
111
|
</body>
|
data/lib/dirtravel.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
# DirTravel is a library for getting information about files and
|
1
|
+
# {DirTravel} is a library for getting information about files and
|
2
2
|
# directories recursively to a tree structure. This library extends
|
3
3
|
# the RubyTree classes to include directory and files info. Please
|
4
4
|
# refer to RubyTree documentation for RubyTree related features.
|
5
5
|
#
|
6
|
-
# A proxy object
|
6
|
+
# A proxy object {DirTravel::Travel} is used to gather the directory
|
7
7
|
# content. The "filetree" class method provides interface for getting
|
8
|
-
# the content with few options (see: DirTravel::Travel.filetree for
|
8
|
+
# the content with few options (see: {DirTravel::Travel.filetree} for
|
9
9
|
# details).
|
10
10
|
#
|
11
|
-
# See the DirTravel::Entry methods doc for possibilities in
|
12
|
-
# the directory hierachy.
|
11
|
+
# See the {DirTravel::Entry} methods doc for possibilities in
|
12
|
+
# examining the directory hierachy.
|
13
13
|
#
|
14
14
|
#
|
15
15
|
# Examples:
|
@@ -28,24 +28,30 @@
|
|
28
28
|
# puts i.abspath
|
29
29
|
# end
|
30
30
|
#
|
31
|
-
# # Get MP3 files and create a list of all album directories
|
32
|
-
# #
|
31
|
+
# # Get MP3 files and create a list of all album directories.
|
32
|
+
# # Assume: ".../<album>/<song>" hierarhcy
|
33
|
+
# #
|
33
34
|
# d = DirTravel::Travel.filetree( '.', { :suffix => '.mp3' } )
|
34
35
|
# albums = d.select_level( d.node_height - 1 )
|
35
36
|
#
|
36
37
|
|
37
38
|
module DirTravel
|
38
|
-
|
39
|
+
|
39
40
|
require 'rubytree'
|
40
41
|
|
41
42
|
|
43
|
+
# {DirTravel} error.
|
42
44
|
class DirTravelError < RuntimeError; end
|
43
|
-
|
45
|
+
|
44
46
|
|
45
47
|
# Extend RubyTree base class with file and directory features.
|
46
48
|
class Entry < Tree::TreeNode
|
49
|
+
|
50
|
+
# Node name.
|
47
51
|
attr_accessor :name
|
48
52
|
|
53
|
+
# Set name for {Entry} (Dir/File).
|
54
|
+
# Initialize abspath.
|
49
55
|
def initialize( name )
|
50
56
|
super( name, nil )
|
51
57
|
@abspath = nil
|
@@ -103,7 +109,7 @@ module DirTravel
|
|
103
109
|
|
104
110
|
|
105
111
|
# Relative path of parenting directory.
|
106
|
-
#
|
112
|
+
#
|
107
113
|
# @param basedir [Entry] Starting level for the hierarchy.
|
108
114
|
# @return [String] Containing directory.
|
109
115
|
def dir( basedir = self )
|
@@ -114,7 +120,7 @@ module DirTravel
|
|
114
120
|
# Select all siblings from given node depth.
|
115
121
|
#
|
116
122
|
# @param level [Integer] Selected level in hierachy. Level is
|
117
|
-
#
|
123
|
+
# number of steps down in hierarhcy.
|
118
124
|
# @return [Array] Array of siblings in selected hierarchy.
|
119
125
|
def select_level( level )
|
120
126
|
select do |i| i.node_depth == level; end
|
@@ -127,23 +133,25 @@ module DirTravel
|
|
127
133
|
end
|
128
134
|
|
129
135
|
|
130
|
-
# File.stat data for the Entry.
|
136
|
+
# File.stat data for the {Entry}.
|
131
137
|
def stat
|
132
138
|
File.stat( path )
|
133
139
|
end
|
134
140
|
|
135
|
-
|
141
|
+
|
142
|
+
# Relative path {Entry}.
|
136
143
|
def relative?
|
137
144
|
@name[0] != '/'
|
138
145
|
end
|
139
146
|
|
147
|
+
|
140
148
|
# Rename node.
|
141
149
|
#
|
142
|
-
# @param name [String] If name is abspath then Entry becomes
|
150
|
+
# @param name [String] If name is abspath then {Entry} becomes
|
143
151
|
# abspath.
|
144
152
|
def rename( name )
|
145
153
|
@name = name
|
146
|
-
|
154
|
+
|
147
155
|
# Absolute or relative path?
|
148
156
|
if name[0] == "/"
|
149
157
|
@abspath = name
|
@@ -153,15 +161,16 @@ module DirTravel
|
|
153
161
|
end
|
154
162
|
|
155
163
|
end
|
156
|
-
|
164
|
+
|
157
165
|
|
158
166
|
# Directory type entry.
|
159
167
|
class DirEntry < Entry
|
160
168
|
|
161
|
-
#
|
169
|
+
# Set name and abspath if given.
|
162
170
|
#
|
163
171
|
# @param name [String] Directory name.
|
164
|
-
# @param abspath [String] Set abspath if given.
|
172
|
+
# @param abspath [String] Set abspath if given. Otherwise it
|
173
|
+
# is generated from pieces.
|
165
174
|
def initialize( name, abspath = nil )
|
166
175
|
super( name )
|
167
176
|
if abspath
|
@@ -170,25 +179,33 @@ module DirTravel
|
|
170
179
|
end
|
171
180
|
|
172
181
|
end
|
173
|
-
|
174
|
-
|
182
|
+
|
183
|
+
|
175
184
|
# File type entry.
|
176
185
|
class FileEntry < Entry
|
177
186
|
attr_reader :suffix, :basename
|
178
|
-
|
187
|
+
|
188
|
+
# Set name, suffix, and basename.
|
189
|
+
#
|
190
|
+
# @param name [String] File name.
|
179
191
|
def initialize( name )
|
180
192
|
super( name )
|
181
193
|
@suffix = File.extname( name )
|
182
194
|
@basename = File.basename( name, @suffix )
|
183
195
|
end
|
184
|
-
|
196
|
+
|
185
197
|
end
|
186
198
|
|
187
199
|
|
188
200
|
# Create directory recursion tree (with
|
189
|
-
# Travel.filetree). Optionally filter with suffix and modify
|
190
|
-
#
|
191
|
-
#
|
201
|
+
# {Travel.filetree}). Optionally filter with suffix and modify tree
|
202
|
+
# building with options Hash (see below).
|
203
|
+
#
|
204
|
+
# If basedir is absolute path, the root name is the search
|
205
|
+
# path. If basedir is relative path, before search the current
|
206
|
+
# directory is changed to referenced directory and root name is
|
207
|
+
# the current directory, single level.
|
208
|
+
#
|
192
209
|
# == Parameters:
|
193
210
|
# sort::
|
194
211
|
# Sort directory entries (default: false).
|
@@ -204,65 +221,104 @@ module DirTravel
|
|
204
221
|
|
205
222
|
class Travel
|
206
223
|
|
207
|
-
# Root DirEntry of Travel.
|
224
|
+
# Root {DirEntry} of {Travel}.
|
208
225
|
attr_accessor :root
|
209
226
|
|
210
|
-
# Default options for Travel.
|
227
|
+
# Default options for {Travel}.
|
211
228
|
attr_accessor :defaults
|
212
229
|
|
213
|
-
# Starting directory for Travel.
|
230
|
+
# Starting directory for {Travel}.
|
214
231
|
attr_accessor :basedir
|
215
232
|
attr_accessor :abspath
|
216
|
-
|
217
|
-
|
233
|
+
|
234
|
+
|
235
|
+
# Create directory recursion tree and return root.
|
236
|
+
#
|
218
237
|
# @param basedir [String] Starting directory (top).
|
219
|
-
# @param options [Hash]
|
220
|
-
# @return [DirEntry] Root
|
238
|
+
# @param options [Hash] {Travel} options.
|
239
|
+
# @return [DirEntry] Root of the file travel hierarchy.
|
221
240
|
def Travel.filetree( basedir = '.', options = {} )
|
222
241
|
|
242
|
+
# Non-nil if directory needs to be changed.
|
223
243
|
pwd = nil
|
224
244
|
|
225
245
|
if basedir[0] == '/'
|
246
|
+
|
247
|
+
# Absolue path.
|
226
248
|
t = Travel.new( basedir, basedir, options )
|
227
249
|
t.travel
|
250
|
+
|
228
251
|
else
|
252
|
+
|
253
|
+
# Relative path.
|
254
|
+
|
255
|
+
# Store current directory before chdir.
|
229
256
|
pwd = Dir.pwd
|
257
|
+
|
258
|
+
# Generate target directory for chdir. One up from
|
259
|
+
# the reference.
|
230
260
|
full = File.absolute_path( basedir )
|
231
261
|
base = File.basename( full )
|
232
262
|
dir = File.dirname( full )
|
263
|
+
|
264
|
+
# Goto target.
|
233
265
|
Dir.chdir( dir )
|
266
|
+
|
234
267
|
t = Travel.new( base, full, options )
|
235
268
|
t.travel
|
236
269
|
end
|
237
270
|
|
271
|
+
|
238
272
|
if t.defaults[ :inclusive ]
|
273
|
+
|
274
|
+
# With inclusive the root is changed to one-up from
|
275
|
+
# target.
|
276
|
+
|
277
|
+
# One up from root.
|
239
278
|
uppath = File.dirname( t.root.abspath )
|
240
|
-
path = uppath
|
241
279
|
if t.root.relative?
|
242
280
|
path = File.basename( uppath )
|
281
|
+
else
|
282
|
+
path = uppath
|
243
283
|
end
|
284
|
+
|
285
|
+
# Create the "one-up" root.
|
244
286
|
newRoot = DirEntry.new( path, uppath )
|
287
|
+
|
288
|
+
# Rename old root.
|
245
289
|
t.root.rename( t.root.tip )
|
290
|
+
|
291
|
+
# Add to one-up root.
|
246
292
|
newRoot.add( t.root )
|
293
|
+
|
294
|
+
# Set root to one-up root.
|
247
295
|
t.root = newRoot
|
248
296
|
end
|
249
297
|
|
298
|
+
# Return back to start directory if dir changed.
|
250
299
|
Dir.chdir( pwd ) if pwd
|
251
300
|
|
301
|
+
# Return root {DirEntry}.
|
252
302
|
t.root
|
253
303
|
end
|
254
304
|
|
255
305
|
|
306
|
+
# Create directory recursion object. Overlay options on top of
|
307
|
+
# defaults. Initialize root {DirEntry}.
|
308
|
+
#
|
309
|
+
# @param basedir [String] Starting directory (top).
|
310
|
+
# @param abspath [String] Absolute path for root.
|
311
|
+
# @param options [Hash] {Travel} options.
|
256
312
|
def initialize( basedir, abspath, options = {} )
|
257
313
|
@basedir = basedir
|
258
314
|
@abspath = abspath
|
259
315
|
|
260
316
|
@defaults = {
|
261
|
-
:suffix => nil,
|
262
|
-
:sort => false,
|
263
|
-
:files => true,
|
264
|
-
:inclusive => false,
|
265
|
-
}
|
317
|
+
:suffix => nil,
|
318
|
+
:sort => false,
|
319
|
+
:files => true,
|
320
|
+
:inclusive => false,
|
321
|
+
}
|
266
322
|
|
267
323
|
@defaults.merge!( options )
|
268
324
|
|
@@ -288,7 +344,7 @@ module DirTravel
|
|
288
344
|
list.each do |i|
|
289
345
|
|
290
346
|
if File.file?( dir + '/' + i )
|
291
|
-
|
347
|
+
|
292
348
|
# File entry.
|
293
349
|
|
294
350
|
if ( !suffix || suffix == File.extname( i ) ) &&
|
@@ -325,5 +381,8 @@ module DirTravel
|
|
325
381
|
|
326
382
|
end
|
327
383
|
|
328
|
-
|
384
|
+
|
329
385
|
end
|
386
|
+
|
387
|
+
|
388
|
+
require_relative 'version'
|