tdiary 3.2.2.20130518 → 3.2.2.20130527
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +17 -11
- data/Rakefile +2 -0
- data/config.ru +2 -1
- data/tdiary.gemspec +7 -0
- data/tdiary.rb +6 -2
- data/tdiary/cli.rb +27 -1
- data/tdiary/environment.rb +0 -1
- data/tdiary/tasks/release.rake +7 -1
- data/tdiary/version.rb +1 -1
- metadata +87 -132
- data/vendor/hikidoc-0.0.6/COPYING +0 -28
- data/vendor/hikidoc-0.0.6/NEWS +0 -30
- data/vendor/hikidoc-0.0.6/NEWS.ja +0 -30
- data/vendor/hikidoc-0.0.6/README +0 -86
- data/vendor/hikidoc-0.0.6/README.ja +0 -83
- data/vendor/hikidoc-0.0.6/Rakefile +0 -68
- data/vendor/hikidoc-0.0.6/TextFormattingRules +0 -320
- data/vendor/hikidoc-0.0.6/TextFormattingRules.ja +0 -318
- data/vendor/hikidoc-0.0.6/bin/hikidoc +0 -66
- data/vendor/hikidoc-0.0.6/lib/hikidoc.rb +0 -914
- data/vendor/hikidoc-0.0.6/setup.rb +0 -1360
- data/vendor/hikidoc-0.0.6/test/run-test.rb +0 -13
- data/vendor/hikidoc-0.0.6/test/test_hikidoc.rb +0 -506
- data/vendor/imagesize-0.1.1/Manifest.txt +0 -19
- data/vendor/imagesize-0.1.1/README.txt +0 -49
- data/vendor/imagesize-0.1.1/lib/image_size.rb +0 -305
- data/vendor/imagesize-0.1.1/lib/image_size/version.rb +0 -9
- data/vendor/imagesize-0.1.1/setup.rb +0 -1585
- data/vendor/imagesize-0.1.1/test/2-4-7.png +0 -0
- data/vendor/imagesize-0.1.1/test/4_1_2.gif +0 -0
- data/vendor/imagesize-0.1.1/test/bmp.bmp +0 -0
- data/vendor/imagesize-0.1.1/test/cursor.xbm +0 -6
- data/vendor/imagesize-0.1.1/test/detect.swf +0 -0
- data/vendor/imagesize-0.1.1/test/pbm.pbm +0 -0
- data/vendor/imagesize-0.1.1/test/pcx.pcx +0 -0
- data/vendor/imagesize-0.1.1/test/pgm.pgm +0 -5
- data/vendor/imagesize-0.1.1/test/test.xpm +0 -38
- data/vendor/imagesize-0.1.1/test/test_helper.rb +0 -2
- data/vendor/imagesize-0.1.1/test/test_image_size.rb +0 -71
- data/vendor/imagesize-0.1.1/test/tiff.tiff +0 -0
- data/vendor/imagesize-0.1.1/test/tokyo_tower.jpg +0 -0
- data/vendor/imagesize-0.1.1/test/tower_e.gif.psd +0 -0
- data/vendor/rdtool-0.6.38/COPYING.txt +0 -339
- data/vendor/rdtool-0.6.38/Gemfile +0 -3
- data/vendor/rdtool-0.6.38/HISTORY +0 -318
- data/vendor/rdtool-0.6.38/LGPL-2.1 +0 -502
- data/vendor/rdtool-0.6.38/LICENSE.txt +0 -58
- data/vendor/rdtool-0.6.38/README.html +0 -66
- data/vendor/rdtool-0.6.38/README.ja.html +0 -73
- data/vendor/rdtool-0.6.38/README.rd +0 -76
- data/vendor/rdtool-0.6.38/README.rd.ja +0 -85
- data/vendor/rdtool-0.6.38/Rakefile +0 -152
- data/vendor/rdtool-0.6.38/TODO +0 -22
- data/vendor/rdtool-0.6.38/bin/rd2 +0 -283
- data/vendor/rdtool-0.6.38/bin/rdswap.rb +0 -207
- data/vendor/rdtool-0.6.38/doc/rd-draft.html +0 -456
- data/vendor/rdtool-0.6.38/doc/rd-draft.ja.html +0 -466
- data/vendor/rdtool-0.6.38/doc/rd-draft.rd +0 -479
- data/vendor/rdtool-0.6.38/doc/rd-draft.rd.ja +0 -487
- data/vendor/rdtool-0.6.38/lib/rd/block-element.rb +0 -114
- data/vendor/rdtool-0.6.38/lib/rd/complex-list-item.rb +0 -65
- data/vendor/rdtool-0.6.38/lib/rd/desclist.rb +0 -55
- data/vendor/rdtool-0.6.38/lib/rd/document-struct.rb +0 -46
- data/vendor/rdtool-0.6.38/lib/rd/dot.rd2rc +0 -18
- data/vendor/rdtool-0.6.38/lib/rd/element.rb +0 -160
- data/vendor/rdtool-0.6.38/lib/rd/filter.rb +0 -255
- data/vendor/rdtool-0.6.38/lib/rd/head-filter.rb +0 -14
- data/vendor/rdtool-0.6.38/lib/rd/inline-element.rb +0 -233
- data/vendor/rdtool-0.6.38/lib/rd/labeled-element.rb +0 -14
- data/vendor/rdtool-0.6.38/lib/rd/list.rb +0 -57
- data/vendor/rdtool-0.6.38/lib/rd/loose-struct.rb +0 -11
- data/vendor/rdtool-0.6.38/lib/rd/methodlist.rb +0 -57
- data/vendor/rdtool-0.6.38/lib/rd/output-format-visitor.rb +0 -30
- data/vendor/rdtool-0.6.38/lib/rd/package.rb +0 -4
- data/vendor/rdtool-0.6.38/lib/rd/parser-util.rb +0 -14
- data/vendor/rdtool-0.6.38/lib/rd/post-install +0 -1
- data/vendor/rdtool-0.6.38/lib/rd/pre-setup.rb +0 -18
- data/vendor/rdtool-0.6.38/lib/rd/rbl-file.rb +0 -69
- data/vendor/rdtool-0.6.38/lib/rd/rbl-suite.rb +0 -37
- data/vendor/rdtool-0.6.38/lib/rd/rd-struct.rb +0 -86
- data/vendor/rdtool-0.6.38/lib/rd/rd2html-ext-lib.rb +0 -266
- data/vendor/rdtool-0.6.38/lib/rd/rd2html-ext-opt.rb +0 -34
- data/vendor/rdtool-0.6.38/lib/rd/rd2html-lib.rb +0 -490
- data/vendor/rdtool-0.6.38/lib/rd/rd2html-opt.rb +0 -67
- data/vendor/rdtool-0.6.38/lib/rd/rd2man-lib.rb +0 -251
- data/vendor/rdtool-0.6.38/lib/rd/rd2rdo-lib.rb +0 -19
- data/vendor/rdtool-0.6.38/lib/rd/rd2rmi-lib.rb +0 -32
- data/vendor/rdtool-0.6.38/lib/rd/rdblockparser.ry +0 -518
- data/vendor/rdtool-0.6.38/lib/rd/rdblockparser.tab.rb +0 -1061
- data/vendor/rdtool-0.6.38/lib/rd/rdfmt.rb +0 -15
- data/vendor/rdtool-0.6.38/lib/rd/rdinlineparser.ry +0 -503
- data/vendor/rdtool-0.6.38/lib/rd/rdinlineparser.tab.rb +0 -1243
- data/vendor/rdtool-0.6.38/lib/rd/rdvisitor.rb +0 -214
- data/vendor/rdtool-0.6.38/lib/rd/reference-resolver.rb +0 -114
- data/vendor/rdtool-0.6.38/lib/rd/search-file.rb +0 -14
- data/vendor/rdtool-0.6.38/lib/rd/tree.rb +0 -103
- data/vendor/rdtool-0.6.38/lib/rd/version.rb +0 -41
- data/vendor/rdtool-0.6.38/lib/rd/visitor.rb +0 -86
- data/vendor/rdtool-0.6.38/rdtool.gemspec +0 -125
- data/vendor/rdtool-0.6.38/setup.rb +0 -1596
- data/vendor/rdtool-0.6.38/test/data/includee1.html +0 -1
- data/vendor/rdtool-0.6.38/test/data/includee2.html +0 -1
- data/vendor/rdtool-0.6.38/test/data/includee3.nothtml +0 -1
- data/vendor/rdtool-0.6.38/test/data/includee4.xhtml +0 -0
- data/vendor/rdtool-0.6.38/test/data/label.rbl +0 -2
- data/vendor/rdtool-0.6.38/test/data/label2.rbl +0 -2
- data/vendor/rdtool-0.6.38/test/data/sub/includee2.html +0 -1
- data/vendor/rdtool-0.6.38/test/data/sub/includee4.html +0 -0
- data/vendor/rdtool-0.6.38/test/dummy-observer.rb +0 -6
- data/vendor/rdtool-0.6.38/test/dummy.rb +0 -33
- data/vendor/rdtool-0.6.38/test/temp-dir.rb +0 -19
- data/vendor/rdtool-0.6.38/test/test-block-parser.rb +0 -46
- data/vendor/rdtool-0.6.38/test/test-desclist-item.rb +0 -219
- data/vendor/rdtool-0.6.38/test/test-document-element.rb +0 -46
- data/vendor/rdtool-0.6.38/test/test-document-struct.rb +0 -66
- data/vendor/rdtool-0.6.38/test/test-element.rb +0 -46
- data/vendor/rdtool-0.6.38/test/test-headline.rb +0 -80
- data/vendor/rdtool-0.6.38/test/test-inline-parser.rb +0 -46
- data/vendor/rdtool-0.6.38/test/test-list-item.rb +0 -54
- data/vendor/rdtool-0.6.38/test/test-list.rb +0 -53
- data/vendor/rdtool-0.6.38/test/test-methodlist-item.rb +0 -73
- data/vendor/rdtool-0.6.38/test/test-nonterminal-element.rb +0 -170
- data/vendor/rdtool-0.6.38/test/test-nonterminal-inline.rb +0 -33
- data/vendor/rdtool-0.6.38/test/test-output-format-visitor.rb +0 -48
- data/vendor/rdtool-0.6.38/test/test-parser-util.rb +0 -41
- data/vendor/rdtool-0.6.38/test/test-rbl-file.rb +0 -156
- data/vendor/rdtool-0.6.38/test/test-rbl-suite.rb +0 -43
- data/vendor/rdtool-0.6.38/test/test-rd2html-lib.rb +0 -496
- data/vendor/rdtool-0.6.38/test/test-rdtree.rb +0 -17
- data/vendor/rdtool-0.6.38/test/test-rdvisitor.rb +0 -29
- data/vendor/rdtool-0.6.38/test/test-reference-resolver.rb +0 -202
- data/vendor/rdtool-0.6.38/test/test-reference.rb +0 -132
- data/vendor/rdtool-0.6.38/test/test-search-file.rb +0 -22
- data/vendor/rdtool-0.6.38/test/test-terminal-inline.rb +0 -41
- data/vendor/rdtool-0.6.38/test/test-textblock.rb +0 -44
- data/vendor/rdtool-0.6.38/test/test-tree.rb +0 -82
- data/vendor/rdtool-0.6.38/test/test-version.rb +0 -57
- data/vendor/rdtool-0.6.38/test/test-visitor.rb +0 -230
- data/vendor/rdtool-0.6.38/utils/rd-mode.el +0 -464
@@ -1,214 +0,0 @@
|
|
1
|
-
require 'rd/output-format-visitor'
|
2
|
-
require 'rd/reference-resolver'
|
3
|
-
require 'rd/rbl-file'
|
4
|
-
require 'forwardable'
|
5
|
-
|
6
|
-
module RD
|
7
|
-
# for Backward compatibility
|
8
|
-
class RDVisitor < OutputFormatVisitor
|
9
|
-
extend Forwardable
|
10
|
-
|
11
|
-
def apply_to_DescListItemTerm(element, contents)
|
12
|
-
contents
|
13
|
-
end
|
14
|
-
|
15
|
-
def apply_to_MethodListItemTerm(element)
|
16
|
-
apply_to_String(element.content)
|
17
|
-
end
|
18
|
-
|
19
|
-
def_delegator(:@reference_resolver, :labels, :__labels__)
|
20
|
-
def_delegator(:@reference_resolver, :label_prefix, :__label_prefix__)
|
21
|
-
def_delegator(:@reference_resolver, :rbl_suite)
|
22
|
-
|
23
|
-
def prepare_labels(tree, prefix = "label:")
|
24
|
-
@reference_resolver = ReferenceResolver.new(tree, prefix)
|
25
|
-
end
|
26
|
-
|
27
|
-
def_delegator(:@reference_resolver, :refer)
|
28
|
-
def_delegator(:@reference_resolver, :get_anchor)
|
29
|
-
def_delegator(:@reference_resolver, :make_rbl_file)
|
30
|
-
|
31
|
-
def refer_external(label)
|
32
|
-
label = @reference_resolver.refer_external_file(label)
|
33
|
-
return nil unless label
|
34
|
-
label[1]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
module AutoLabel
|
39
|
-
def parse_rmi(src)
|
40
|
-
labels = {}
|
41
|
-
$method_index = []
|
42
|
-
eval(src)
|
43
|
-
$method_index.each do |c, k, m, f, l|
|
44
|
-
labels[c + k + m] = l
|
45
|
-
end
|
46
|
-
labels
|
47
|
-
end
|
48
|
-
private :parse_rmi
|
49
|
-
end # AutoLabel
|
50
|
-
|
51
|
-
=begin
|
52
|
-
== module RD::MethodParse
|
53
|
-
this module provide several functions for MehotList.
|
54
|
-
=end
|
55
|
-
|
56
|
-
module MethodParse
|
57
|
-
|
58
|
-
def analize_method(method)
|
59
|
-
klass = nil
|
60
|
-
args = nil
|
61
|
-
kind = nil
|
62
|
-
if /[^{(\s]+/ =~ method
|
63
|
-
method = $&
|
64
|
-
args = $' # '
|
65
|
-
end
|
66
|
-
|
67
|
-
if /^(.*)(#|::|\.)/ =~ method
|
68
|
-
klass = $1
|
69
|
-
kind = str2kind($2)
|
70
|
-
method = $' # '
|
71
|
-
end
|
72
|
-
|
73
|
-
if klass == "function" and kind == :instance_method
|
74
|
-
kind = :function
|
75
|
-
end
|
76
|
-
|
77
|
-
[klass, kind, method, args]
|
78
|
-
end
|
79
|
-
module_function :analize_method
|
80
|
-
|
81
|
-
def str2kind(str)
|
82
|
-
case str
|
83
|
-
when '#'
|
84
|
-
:instance_method
|
85
|
-
when '.'
|
86
|
-
:class_method
|
87
|
-
when '::'
|
88
|
-
:constant
|
89
|
-
end
|
90
|
-
end
|
91
|
-
module_function :str2kind
|
92
|
-
|
93
|
-
def kind2str(int)
|
94
|
-
case int
|
95
|
-
when :instance_method, :function
|
96
|
-
'#'
|
97
|
-
when :class_method
|
98
|
-
'.'
|
99
|
-
when :constant
|
100
|
-
'::'
|
101
|
-
end
|
102
|
-
end
|
103
|
-
module_function :kind2str
|
104
|
-
|
105
|
-
KIND2NUM = {:constant => 0, :class_method => 1, :instance_method => 2, :function => 2}
|
106
|
-
def kind2num(str)
|
107
|
-
KIND2NUM[str]
|
108
|
-
end
|
109
|
-
module_function :kind2num
|
110
|
-
|
111
|
-
def make_mindex_label(element)
|
112
|
-
klass, kind, method = analize_method(element.label)
|
113
|
-
case kind
|
114
|
-
when :class_method
|
115
|
-
klass + "_S_" + tr_method(method)
|
116
|
-
when :instance_method
|
117
|
-
klass + "_" + tr_method(method)
|
118
|
-
when :constant
|
119
|
-
klass + "_" + method
|
120
|
-
when :function
|
121
|
-
"function_" + tr_method(method)
|
122
|
-
else
|
123
|
-
element.label
|
124
|
-
end
|
125
|
-
end
|
126
|
-
module_function :make_mindex_label
|
127
|
-
|
128
|
-
def tr_method(method)
|
129
|
-
case method
|
130
|
-
when "[]"
|
131
|
-
"ref_"
|
132
|
-
when "[]="
|
133
|
-
"set_"
|
134
|
-
when "+"
|
135
|
-
"plus_"
|
136
|
-
when "+@"
|
137
|
-
"uplus_"
|
138
|
-
when "-"
|
139
|
-
"minus_"
|
140
|
-
when "-@"
|
141
|
-
"uminus_"
|
142
|
-
when "*"
|
143
|
-
"mul_"
|
144
|
-
when "/"
|
145
|
-
"div_"
|
146
|
-
when "%"
|
147
|
-
"mod_"
|
148
|
-
when "**"
|
149
|
-
"power_"
|
150
|
-
when "~"
|
151
|
-
"inv_"
|
152
|
-
when "=="
|
153
|
-
"eq_"
|
154
|
-
when "==="
|
155
|
-
"eqq_"
|
156
|
-
when "=~"
|
157
|
-
"match_"
|
158
|
-
when "&"
|
159
|
-
"and_"
|
160
|
-
when "|"
|
161
|
-
"or_"
|
162
|
-
when "<<"
|
163
|
-
"lshift_"
|
164
|
-
when ">>"
|
165
|
-
"rshift_"
|
166
|
-
when "<=>"
|
167
|
-
"cmp_"
|
168
|
-
when "<"
|
169
|
-
"lt_"
|
170
|
-
when "<="
|
171
|
-
"le_"
|
172
|
-
when ">"
|
173
|
-
"gt_"
|
174
|
-
when ">="
|
175
|
-
"ge_"
|
176
|
-
when "^"
|
177
|
-
"xor_"
|
178
|
-
when "`"
|
179
|
-
"backquote_"
|
180
|
-
when /!$/
|
181
|
-
$` + "_bang" # `
|
182
|
-
when /\?$/
|
183
|
-
$` + "_p" # `
|
184
|
-
when /=$/
|
185
|
-
$` + "_eq" # `
|
186
|
-
else
|
187
|
-
method
|
188
|
-
end
|
189
|
-
end
|
190
|
-
module_function :tr_method
|
191
|
-
|
192
|
-
def make_method_index(tree)
|
193
|
-
indexes = []
|
194
|
-
tree.each do |i|
|
195
|
-
if i.is_a?(MethodListItem)
|
196
|
-
klass, kind, method, args = analize_method(i.term.content)
|
197
|
-
indexes.push([klass, kind2num(kind), method, kind]) if kind
|
198
|
-
end
|
199
|
-
end
|
200
|
-
indexes.uniq!
|
201
|
-
indexes.sort.each {|i| i[1] = i.pop}
|
202
|
-
end
|
203
|
-
module_function :make_method_index
|
204
|
-
|
205
|
-
end # MethodParse
|
206
|
-
end # RD
|
207
|
-
|
208
|
-
=begin
|
209
|
-
== script info.
|
210
|
-
abstruct class for visitor of RDTree.
|
211
|
-
$Id: rdvisitor.rb,v 1.46 2003/02/18 16:20:25 tosh Exp $
|
212
|
-
|
213
|
-
=end
|
214
|
-
|
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'rd/rbl-suite'
|
2
|
-
require 'rd/labeled-element'
|
3
|
-
|
4
|
-
require 'forwardable'
|
5
|
-
|
6
|
-
module RD
|
7
|
-
class ReferenceResolver
|
8
|
-
extend Forwardable
|
9
|
-
include Enumerable
|
10
|
-
|
11
|
-
attr_reader :labels
|
12
|
-
attr_reader :label_prefix
|
13
|
-
attr_reader :rbl_suite
|
14
|
-
|
15
|
-
def initialize(tree, prefix = "label:")
|
16
|
-
init_labels(tree)
|
17
|
-
@label_prefix = prefix
|
18
|
-
@rbl_suite = RBLSuite.new(tree.include_path)
|
19
|
-
end
|
20
|
-
|
21
|
-
def init_labels(tree)
|
22
|
-
@labels = {}
|
23
|
-
ary = (tree.find_all do |i|
|
24
|
-
i.is_a? LabeledElement
|
25
|
-
end)
|
26
|
-
num = 0
|
27
|
-
ary.each do |i|
|
28
|
-
push_to_labels(i.to_label, [i, num])
|
29
|
-
num += 1
|
30
|
-
end
|
31
|
-
end
|
32
|
-
private :init_labels
|
33
|
-
|
34
|
-
def push_to_labels(key, value)
|
35
|
-
if labels[key]
|
36
|
-
labels[key].push(value)
|
37
|
-
else
|
38
|
-
labels[key] = [value]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
private :push_to_labels
|
42
|
-
|
43
|
-
def each_label
|
44
|
-
tmp = []
|
45
|
-
labels.each_value do |i|
|
46
|
-
i.each do |j|
|
47
|
-
tmp.push(j)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
tmp.sort{|i,j| i[1] <=> j[1]}.each do |i|
|
51
|
-
yield(i[0])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
alias each each_label
|
55
|
-
|
56
|
-
def referent_of_label(label)
|
57
|
-
label = label.label if label.is_a? Reference
|
58
|
-
if label.filename
|
59
|
-
refer_external_file(label)
|
60
|
-
else
|
61
|
-
anchor = refer(label)
|
62
|
-
return nil unless anchor
|
63
|
-
[nil, anchor]
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def refer(label)
|
68
|
-
matched = labels[label2str(label)]
|
69
|
-
return nil unless matched
|
70
|
-
num2anchor(matched[0][1])
|
71
|
-
end
|
72
|
-
|
73
|
-
def refer_element(label)
|
74
|
-
labels.fetch(label2str(label), []).collect{|i| i[0] }
|
75
|
-
end
|
76
|
-
|
77
|
-
def refer_external_file(label)
|
78
|
-
label = label.label if label.is_a? Reference
|
79
|
-
rbl_suite.refer(label.element_label, label.filename)
|
80
|
-
end
|
81
|
-
|
82
|
-
def get_label_num(element)
|
83
|
-
entry = labels[element.to_label].find{|i| i[0] == element }
|
84
|
-
return nil unless entry
|
85
|
-
entry[1]
|
86
|
-
end
|
87
|
-
|
88
|
-
def get_anchor(element)
|
89
|
-
if num = get_label_num(element)
|
90
|
-
num2anchor(num)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def num2anchor(num)
|
95
|
-
label_prefix + num.to_s
|
96
|
-
end
|
97
|
-
private :num2anchor
|
98
|
-
|
99
|
-
def label2str(label)
|
100
|
-
case label
|
101
|
-
when String
|
102
|
-
label
|
103
|
-
when Element, Reference::RDLabel
|
104
|
-
label.to_label
|
105
|
-
else
|
106
|
-
raise ArgumentError, "can't extract Label from #{label}."
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def make_rbl_file(filename)
|
111
|
-
RBLFile.create_rbl_file(filename, self)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require "rd/rdblockparser.tab"
|
2
|
-
require "rd/filter"
|
3
|
-
require "rd/document-struct"
|
4
|
-
require "rd/version"
|
5
|
-
|
6
|
-
module RD
|
7
|
-
|
8
|
-
# document tree
|
9
|
-
class Tree
|
10
|
-
include Enumerable
|
11
|
-
|
12
|
-
SYSTEM_NAME = "RDtool Framework -- Document Tree"
|
13
|
-
SYSTEM_VERSION = "$Version: "+RD::VERSION+"$"
|
14
|
-
VERSION = Version.new_from_version_string(SYSTEM_NAME, SYSTEM_VERSION)
|
15
|
-
|
16
|
-
def Tree.version
|
17
|
-
VERSION
|
18
|
-
end
|
19
|
-
|
20
|
-
TMP_DIR = "/tmp"
|
21
|
-
|
22
|
-
def Tree.tmp_dir
|
23
|
-
TMP_DIR
|
24
|
-
end
|
25
|
-
|
26
|
-
attr_reader :root
|
27
|
-
attr_reader :document_struct
|
28
|
-
attr_accessor :include_paths
|
29
|
-
alias include_path include_paths
|
30
|
-
alias include_path= include_paths=
|
31
|
-
attr_reader :filters
|
32
|
-
alias filter filters
|
33
|
-
attr_accessor :tmp_dir
|
34
|
-
|
35
|
-
def Tree.new_with_document_struct(document_struct, include_paths = [])
|
36
|
-
Tree.new(document_struct, nil, include_paths)
|
37
|
-
end
|
38
|
-
|
39
|
-
def initialize(document_struct, src_str = nil, include_paths = [])
|
40
|
-
@src = src_str
|
41
|
-
@document_struct = document_struct
|
42
|
-
@include_paths = include_paths
|
43
|
-
@filters = Hash.new()
|
44
|
-
@tmp_dir = TMP_DIR
|
45
|
-
@root = nil
|
46
|
-
end
|
47
|
-
|
48
|
-
def parse
|
49
|
-
parser = RDParser.new
|
50
|
-
src = @src.respond_to?(:to_a) ? @src.to_a : @src.split(/^/)
|
51
|
-
set_root(parser.parse(src, self))
|
52
|
-
end
|
53
|
-
|
54
|
-
def set_root(element)
|
55
|
-
raise ArgumentError, "#{element.class} can't be root." unless
|
56
|
-
@document_struct.is_valid?(self, element)
|
57
|
-
@root = element
|
58
|
-
element.parent = self
|
59
|
-
end
|
60
|
-
alias root= set_root
|
61
|
-
|
62
|
-
def make_root(&block)
|
63
|
-
child = DocumentElement.new
|
64
|
-
set_root(child)
|
65
|
-
child.build(&block) if block_given?
|
66
|
-
child
|
67
|
-
end
|
68
|
-
|
69
|
-
def check_valid
|
70
|
-
each_element do |i|
|
71
|
-
raise RuntimeError,
|
72
|
-
"mismatched document structure, #{i.parent} <-/- #{i}." unless
|
73
|
-
@document_struct.is_valid?(i.parent, i)
|
74
|
-
end
|
75
|
-
true
|
76
|
-
end
|
77
|
-
|
78
|
-
def accept(visitor)
|
79
|
-
@root.accept(visitor)
|
80
|
-
end
|
81
|
-
|
82
|
-
def each_element(&block)
|
83
|
-
return nil unless @root
|
84
|
-
@root.each(&block)
|
85
|
-
end
|
86
|
-
alias each each_element
|
87
|
-
|
88
|
-
def tree
|
89
|
-
self
|
90
|
-
end
|
91
|
-
|
92
|
-
def Tree.new_from_rdo(*rdos) # rdos: IOs
|
93
|
-
tree = Tree.new("", [], nil)
|
94
|
-
tree_content = []
|
95
|
-
rdos.each do |i|
|
96
|
-
subtree = Marshal.load(i)
|
97
|
-
tree_content.concat(subtree.root.blocks)
|
98
|
-
end
|
99
|
-
tree.root = DocumentElement.new(tree_content)
|
100
|
-
tree
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|