term_utils 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -2
- data/COPYING +3 -3
- data/README.md +51 -16
- data/Rakefile +6 -0
- data/doc/TermUtils/AP/Article.html +57 -55
- data/doc/TermUtils/AP/ArticleResult.html +584 -0
- data/doc/TermUtils/AP/Flag.html +295 -78
- data/doc/TermUtils/AP/Parameter.html +891 -103
- data/doc/TermUtils/AP/ParameterResult.html +980 -0
- data/doc/TermUtils/{FF/Cursor/Context.html → AP/ParameterWalkerHooks.html} +60 -60
- data/doc/TermUtils/AP/ParseError.html +651 -19
- data/doc/TermUtils/AP/Parser.html +181 -121
- data/doc/TermUtils/AP/Result.html +201 -528
- data/doc/TermUtils/AP/Syntax.html +103 -393
- data/doc/TermUtils/AP/SyntaxError.html +9 -91
- data/doc/TermUtils/AP/Walker.html +686 -0
- data/doc/TermUtils/AP.html +49 -160
- data/doc/TermUtils/FF/Config.html +203 -35
- data/doc/TermUtils/FF/Context.html +585 -0
- data/doc/TermUtils/FF/Entry.html +626 -0
- data/doc/TermUtils/FF/Finder.html +850 -0
- data/doc/TermUtils/FF/{Cursor.html → FinderEntry.html} +473 -211
- data/doc/TermUtils/FF/FinderQuery.html +946 -0
- data/doc/TermUtils/FF/Query.html +402 -70
- data/doc/TermUtils/FF.html +135 -11
- data/doc/TermUtils/PropertyTreeNode.html +304 -190
- data/doc/TermUtils/Tab/Column.html +98 -96
- data/doc/TermUtils/Tab/Header.html +30 -30
- data/doc/TermUtils/Tab/Holder.html +81 -81
- data/doc/TermUtils/Tab/Printer.html +43 -43
- data/doc/TermUtils/Tab/Table.html +124 -128
- data/doc/TermUtils/Tab/TableError.html +7 -89
- data/doc/TermUtils/Tab.html +93 -86
- data/doc/TermUtils.html +10 -10
- data/doc/_index.html +62 -42
- data/doc/class_list.html +3 -3
- data/doc/css/style.css +3 -2
- data/doc/file.README.html +63 -26
- data/doc/file_list.html +2 -2
- data/doc/frames.html +2 -2
- data/doc/index.html +63 -26
- data/doc/js/app.js +14 -3
- data/doc/method_list.html +708 -236
- data/doc/top-level-namespace.html +7 -7
- data/lib/term_utils/ap/article.rb +15 -9
- data/lib/term_utils/ap/flag.rb +37 -20
- data/lib/term_utils/ap/parameter.rb +88 -19
- data/lib/term_utils/ap/parser.rb +143 -116
- data/lib/term_utils/ap/result.rb +208 -161
- data/lib/term_utils/ap/syntax.rb +53 -69
- data/lib/term_utils/ap.rb +79 -24
- data/lib/term_utils/ff/config.rb +22 -10
- data/lib/term_utils/{ap/no_such_value_error.rb → ff/entry.rb} +26 -8
- data/lib/term_utils/ff/finder.rb +255 -0
- data/lib/term_utils/ff/query.rb +94 -17
- data/lib/term_utils/ff.rb +12 -2
- data/lib/term_utils/property_tree_node.rb +47 -19
- data/lib/term_utils/tab.rb +106 -61
- data/lib/term_utils.rb +8 -1
- data/term_utils.gemspec +4 -4
- metadata +18 -17
- data/doc/TermUtils/AP/Element.html +0 -1025
- data/doc/TermUtils/AP/Level.html +0 -638
- data/doc/TermUtils/AP/NoSuchValueError.html +0 -217
- data/lib/term_utils/ap/element.rb +0 -78
- data/lib/term_utils/ap/level.rb +0 -57
- data/lib/term_utils/ap/parse_error.rb +0 -27
- data/lib/term_utils/ap/syntax_error.rb +0 -27
- data/lib/term_utils/ff/cursor.rb +0 -153
@@ -1,217 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>
|
7
|
-
Exception: TermUtils::AP::NoSuchValueError
|
8
|
-
|
9
|
-
— Documentation by YARD 0.9.20
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
pathId = "TermUtils::AP::NoSuchValueError";
|
19
|
-
relpath = '../../';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
|
23
|
-
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
-
|
25
|
-
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
-
|
27
|
-
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div class="nav_wrap">
|
31
|
-
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
-
<div id="resizer"></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="main" tabindex="-1">
|
36
|
-
<div id="header">
|
37
|
-
<div id="menu">
|
38
|
-
|
39
|
-
<a href="../../_index.html">Index (N)</a> »
|
40
|
-
<span class='title'><span class='object_link'><a href="../../TermUtils.html" title="TermUtils (module)">TermUtils</a></span></span> » <span class='title'><span class='object_link'><a href="../AP.html" title="TermUtils::AP (module)">AP</a></span></span>
|
41
|
-
»
|
42
|
-
<span class="title">NoSuchValueError</span>
|
43
|
-
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<div id="search">
|
47
|
-
|
48
|
-
<a class="full_list_link" id="class_list_link"
|
49
|
-
href="../../class_list.html">
|
50
|
-
|
51
|
-
<svg width="24" height="24">
|
52
|
-
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
-
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
-
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
-
</svg>
|
56
|
-
</a>
|
57
|
-
|
58
|
-
</div>
|
59
|
-
<div class="clear"></div>
|
60
|
-
</div>
|
61
|
-
|
62
|
-
<div id="content"><h1>Exception: TermUtils::AP::NoSuchValueError
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</h1>
|
67
|
-
<div class="box_info">
|
68
|
-
|
69
|
-
<dl>
|
70
|
-
<dt>Inherits:</dt>
|
71
|
-
<dd>
|
72
|
-
<span class="inheritName">StandardError</span>
|
73
|
-
|
74
|
-
<ul class="fullTree">
|
75
|
-
<li>Object</li>
|
76
|
-
|
77
|
-
<li class="next">StandardError</li>
|
78
|
-
|
79
|
-
<li class="next">TermUtils::AP::NoSuchValueError</li>
|
80
|
-
|
81
|
-
</ul>
|
82
|
-
<a href="#" class="inheritanceTree">show all</a>
|
83
|
-
|
84
|
-
</dd>
|
85
|
-
</dl>
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
<dl>
|
98
|
-
<dt>Defined in:</dt>
|
99
|
-
<dd>lib/term_utils/ap/no_such_value_error.rb</dd>
|
100
|
-
</dl>
|
101
|
-
|
102
|
-
</div>
|
103
|
-
|
104
|
-
<h2>Overview</h2><div class="docstring">
|
105
|
-
<div class="discussion">
|
106
|
-
|
107
|
-
<p>No such value error.</p>
|
108
|
-
|
109
|
-
|
110
|
-
</div>
|
111
|
-
</div>
|
112
|
-
<div class="tags">
|
113
|
-
|
114
|
-
|
115
|
-
</div>
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
<h2>
|
124
|
-
Instance Method Summary
|
125
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
126
|
-
</h2>
|
127
|
-
|
128
|
-
<ul class="summary">
|
129
|
-
|
130
|
-
<li class="public ">
|
131
|
-
<span class="summary_signature">
|
132
|
-
|
133
|
-
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(msg) ⇒ NoSuchValueError </a>
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
</span>
|
138
|
-
|
139
|
-
|
140
|
-
<span class="note title constructor">constructor</span>
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
<span class="summary_desc"><div class='inline'>
|
150
|
-
<p>A new instance of NoSuchValueError.</p>
|
151
|
-
</div></span>
|
152
|
-
|
153
|
-
</li>
|
154
|
-
|
155
|
-
|
156
|
-
</ul>
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
<div id="constructor_details" class="method_details_list">
|
161
|
-
<h2>Constructor Details</h2>
|
162
|
-
|
163
|
-
<div class="method_details first">
|
164
|
-
<h3 class="signature first" id="initialize-instance_method">
|
165
|
-
|
166
|
-
#<strong>initialize</strong>(msg) ⇒ <tt><span class='object_link'><a href="" title="TermUtils::AP::NoSuchValueError (class)">NoSuchValueError</a></span></tt>
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
</h3><div class="docstring">
|
173
|
-
<div class="discussion">
|
174
|
-
|
175
|
-
<p>Returns a new instance of NoSuchValueError</p>
|
176
|
-
|
177
|
-
|
178
|
-
</div>
|
179
|
-
</div>
|
180
|
-
<div class="tags">
|
181
|
-
|
182
|
-
|
183
|
-
</div><table class="source_code">
|
184
|
-
<tr>
|
185
|
-
<td>
|
186
|
-
<pre class="lines">
|
187
|
-
|
188
|
-
|
189
|
-
22
|
190
|
-
23
|
191
|
-
24</pre>
|
192
|
-
</td>
|
193
|
-
<td>
|
194
|
-
<pre class="code"><span class="info file"># File 'lib/term_utils/ap/no_such_value_error.rb', line 22</span>
|
195
|
-
|
196
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span><span class='rparen'>)</span>
|
197
|
-
<span class='kw'>super</span>
|
198
|
-
<span class='kw'>end</span></pre>
|
199
|
-
</td>
|
200
|
-
</tr>
|
201
|
-
</table>
|
202
|
-
</div>
|
203
|
-
|
204
|
-
</div>
|
205
|
-
|
206
|
-
|
207
|
-
</div>
|
208
|
-
|
209
|
-
<div id="footer">
|
210
|
-
Generated on Fri Feb 7 18:54:42 2020 by
|
211
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
212
|
-
0.9.20 (ruby-2.6.5).
|
213
|
-
</div>
|
214
|
-
|
215
|
-
</div>
|
216
|
-
</body>
|
217
|
-
</html>
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
#
|
3
|
-
# Copyright (C) 2019 Thomas Baron
|
4
|
-
#
|
5
|
-
# This file is part of term_utils.
|
6
|
-
#
|
7
|
-
# term_utils is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# term_utils is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with term_utils. If not, see <https://www.gnu.org/licenses/>.
|
18
|
-
module TermUtils
|
19
|
-
module AP
|
20
|
-
# Represents a syntax element (abstract).
|
21
|
-
class Element
|
22
|
-
# @return [Symbol]
|
23
|
-
attr_accessor :id
|
24
|
-
# @return [Integer]
|
25
|
-
attr_accessor :min_occurs
|
26
|
-
# @return [Integer]
|
27
|
-
attr_accessor :max_occurs
|
28
|
-
# @return [Array<TermUtils::AP::Flag>]
|
29
|
-
attr_accessor :flags
|
30
|
-
# For dup method.
|
31
|
-
def initialize_dup(other)
|
32
|
-
if other.flags
|
33
|
-
@flags = []
|
34
|
-
other.flags.each do |f|
|
35
|
-
@flags << f.dup
|
36
|
-
end
|
37
|
-
end
|
38
|
-
super
|
39
|
-
end
|
40
|
-
# Finalizes this one. Internal use.
|
41
|
-
# @return [nil]
|
42
|
-
def finalize!(opts = {})
|
43
|
-
raise TermUtils::AP::SyntaxError, "min_occurs must be equal or greater than 0" unless (@min_occurs.is_a? Integer) && (@min_occurs >= 0)
|
44
|
-
raise TermUtils::AP::SyntaxError, "max_occurs must be equal or greater than min_occurs" unless !occur_bounded? || (@max_occurs >= @min_occurs)
|
45
|
-
unless @id
|
46
|
-
opts[:anonymous] += 1
|
47
|
-
@id = "anonymous#{opts[:anonymous]}".intern
|
48
|
-
end
|
49
|
-
end
|
50
|
-
# Tests whether this one has mutiple occurs.
|
51
|
-
# @return [Boolean]
|
52
|
-
def multiple_occurs?
|
53
|
-
(@max_occurs == nil) || (@max_occurs == :infinity) || ((@max_occurs.is_a? Integer) && (@max_occurs > 1))
|
54
|
-
end
|
55
|
-
# Tests whether the number of occurs are fixed.
|
56
|
-
# @return [Boolean]
|
57
|
-
def occur_bounded?
|
58
|
-
(@max_occurs != nil) && (@max_occurs != :infinity) && (@max_occurs.is_a? Integer)
|
59
|
-
end
|
60
|
-
# Tests whether this one is flagged.
|
61
|
-
# @return [Boolean]
|
62
|
-
def flagged?
|
63
|
-
!@flags.empty?
|
64
|
-
end
|
65
|
-
# Adds a new Flag to this one.
|
66
|
-
# @param opts [Hash]
|
67
|
-
# @option opts [String] :label
|
68
|
-
# @option opts [Symbol] :flavor `:anchor`, `:long`, `:short`.
|
69
|
-
# @return [TermUtils::AP::Flag]
|
70
|
-
def define_flag(opts = {}, &block)
|
71
|
-
new_flag = TermUtils::AP::Flag.new(opts)
|
72
|
-
@flags << new_flag
|
73
|
-
block.call(new_flag) if block
|
74
|
-
new_flag
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/lib/term_utils/ap/level.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
#
|
3
|
-
# Copyright (C) 2019 Thomas Baron
|
4
|
-
#
|
5
|
-
# This file is part of term_utils.
|
6
|
-
#
|
7
|
-
# term_utils is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# term_utils is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with term_utils. If not, see <https://www.gnu.org/licenses/>.
|
18
|
-
module TermUtils
|
19
|
-
module AP
|
20
|
-
# Represents an argument list subset. It must lead with a Flag. It has its
|
21
|
-
# own syntax.
|
22
|
-
class Level < TermUtils::AP::Element
|
23
|
-
# @return [TermUtils::AP::Syntax]
|
24
|
-
attr_accessor :syntax
|
25
|
-
# Constructs a new Level.
|
26
|
-
# @param opts [Hash]
|
27
|
-
# @option opts [Symbol] :id
|
28
|
-
# @option opts [Integer] :min_occurs Default value is `0`.
|
29
|
-
# @option opts [Integer] :max_occurs Default value is `1`.
|
30
|
-
def initialize(opts = {})
|
31
|
-
@id = opts.fetch(:id, nil)
|
32
|
-
@min_occurs = opts.fetch(:min_occurs, 0)
|
33
|
-
@max_occurs = opts.fetch(:max_occurs, 1)
|
34
|
-
@flags = []
|
35
|
-
@syntax = TermUtils::AP::Syntax.new
|
36
|
-
end
|
37
|
-
# For dup method.
|
38
|
-
def initialize_dup(other)
|
39
|
-
@syntax = other.syntax.dup
|
40
|
-
super
|
41
|
-
end
|
42
|
-
# Finalizes this one. Internal use.
|
43
|
-
# @return [nil]
|
44
|
-
def finalize!(opts = {})
|
45
|
-
super
|
46
|
-
raise TermUtils::AP::SyntaxError, "level must contain at least one flag" if @flags.empty?
|
47
|
-
@syntax.finalize!(opts)
|
48
|
-
end
|
49
|
-
# Defines the syntax.
|
50
|
-
# @return [TermUtils::AP::Syntax]
|
51
|
-
def define_syntax(&block)
|
52
|
-
block.call(@syntax) if block
|
53
|
-
@syntax
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
#
|
3
|
-
# Copyright (C) 2019 Thomas Baron
|
4
|
-
#
|
5
|
-
# This file is part of term_utils.
|
6
|
-
#
|
7
|
-
# term_utils is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# term_utils is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with term_utils. If not, see <https://www.gnu.org/licenses/>.
|
18
|
-
module TermUtils
|
19
|
-
module AP
|
20
|
-
# Parse error.
|
21
|
-
class ParseError < StandardError
|
22
|
-
def initialize(msg)
|
23
|
-
super
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
#
|
3
|
-
# Copyright (C) 2019 Thomas Baron
|
4
|
-
#
|
5
|
-
# This file is part of term_utils.
|
6
|
-
#
|
7
|
-
# term_utils is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# term_utils is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with term_utils. If not, see <https://www.gnu.org/licenses/>.
|
18
|
-
module TermUtils
|
19
|
-
module AP
|
20
|
-
# Syntax error.
|
21
|
-
class SyntaxError < StandardError
|
22
|
-
def initialize(msg)
|
23
|
-
super
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/term_utils/ff/cursor.rb
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
#
|
3
|
-
# Copyright (C) 2019 Thomas Baron
|
4
|
-
#
|
5
|
-
# This file is part of term_utils.
|
6
|
-
#
|
7
|
-
# term_utils is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# term_utils is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with term_utils. If not, see <https://www.gnu.org/licenses/>.
|
18
|
-
module TermUtils
|
19
|
-
# The ff module provides a way to find files.
|
20
|
-
module FF
|
21
|
-
# Represents a query cursor.
|
22
|
-
class Cursor
|
23
|
-
# Represents a directory context.
|
24
|
-
Context = Struct.new(:path, :components, :entries)
|
25
|
-
# @return [Integer]
|
26
|
-
attr_reader :index
|
27
|
-
# @param config [TermUtils::FF::Config]
|
28
|
-
# @param path [String]
|
29
|
-
def initialize(config, path)
|
30
|
-
@config = config
|
31
|
-
@path = path
|
32
|
-
@contexts = []
|
33
|
-
push_context(path)
|
34
|
-
@index = 0
|
35
|
-
end
|
36
|
-
# Starts the query.
|
37
|
-
# @return [TermUtils::FF::Cursor, nil]
|
38
|
-
def bootstrap
|
39
|
-
res = self
|
40
|
-
if @config.min_depth
|
41
|
-
while depth < @config.min_depth
|
42
|
-
res = following0
|
43
|
-
break unless res
|
44
|
-
end
|
45
|
-
end
|
46
|
-
res
|
47
|
-
end
|
48
|
-
# Returns the next cursor.
|
49
|
-
# @return [TermUtils::FF::Cursor, nil]
|
50
|
-
def following
|
51
|
-
res = nil
|
52
|
-
loop do
|
53
|
-
res = following0
|
54
|
-
break unless res
|
55
|
-
if @config.min_depth
|
56
|
-
next if depth < @config.min_depth
|
57
|
-
end
|
58
|
-
if @config.max_depth
|
59
|
-
next if depth > @config.max_depth
|
60
|
-
end
|
61
|
-
@index += 1
|
62
|
-
break
|
63
|
-
end
|
64
|
-
res
|
65
|
-
end
|
66
|
-
# Returns the result associated to this one.
|
67
|
-
# @return [String]
|
68
|
-
def result
|
69
|
-
@contexts.last.path
|
70
|
-
end
|
71
|
-
# @return [Integer]
|
72
|
-
def depth
|
73
|
-
@contexts.last.components.length
|
74
|
-
end
|
75
|
-
# @return [String]
|
76
|
-
def relative_path
|
77
|
-
@contexts.last.components.join("/")
|
78
|
-
end
|
79
|
-
# @return [String]
|
80
|
-
def name
|
81
|
-
@contexts.last.components[-1]
|
82
|
-
end
|
83
|
-
# Returns the path components.
|
84
|
-
# @return [Array<String>]
|
85
|
-
def components
|
86
|
-
@contexts.last.components.dup
|
87
|
-
end
|
88
|
-
private
|
89
|
-
# Returns the next cursor.
|
90
|
-
# @return [TermUtils::FF::Cursor, nil]
|
91
|
-
def following0
|
92
|
-
ctx = @contexts.last
|
93
|
-
if ctx
|
94
|
-
if ctx.entries
|
95
|
-
# Directory.
|
96
|
-
until ctx.entries.empty?
|
97
|
-
name = ctx.entries.first
|
98
|
-
break if accept_name(name)
|
99
|
-
ctx.entries.shift
|
100
|
-
end
|
101
|
-
if ctx.entries.empty?
|
102
|
-
# Walked through every entry of directory.
|
103
|
-
@contexts.pop
|
104
|
-
following0
|
105
|
-
else
|
106
|
-
# Directory entry.
|
107
|
-
new_path = StringIO.new
|
108
|
-
new_path << ctx.path
|
109
|
-
new_path << "/" if ctx.path[-1] != "/"
|
110
|
-
new_path << ctx.entries.first
|
111
|
-
new_components = ctx.components.dup
|
112
|
-
new_components << ctx.entries.first
|
113
|
-
push_context(new_path.string, new_components)
|
114
|
-
ctx.entries.shift
|
115
|
-
self
|
116
|
-
end
|
117
|
-
else
|
118
|
-
# Not directory.
|
119
|
-
@contexts.pop
|
120
|
-
following0
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
# Pushes a new context on the stask.
|
125
|
-
# @param path [String]
|
126
|
-
def push_context(path, components = [])
|
127
|
-
entries = nil
|
128
|
-
if File.directory? path
|
129
|
-
entries = Dir.entries(path)
|
130
|
-
entries.sort! if @config.sorted
|
131
|
-
end
|
132
|
-
@contexts.push(Context.new(path, components, entries))
|
133
|
-
end
|
134
|
-
# Tests whether a given name shall be accepted.
|
135
|
-
# @param name [String]
|
136
|
-
# @return [Boolean]
|
137
|
-
def accept_name(name)
|
138
|
-
if (name != ".") and (name != "..")
|
139
|
-
ret = true
|
140
|
-
@config.ignore_list.each do |i|
|
141
|
-
if i.match? name
|
142
|
-
ret = false
|
143
|
-
break
|
144
|
-
end
|
145
|
-
end
|
146
|
-
ret
|
147
|
-
else
|
148
|
-
false
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|