meteor 0.9.13 → 0.9.14
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 +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +3 -3
- data/demo/html.rb +49 -39
- data/demo/html4.rb +40 -33
- data/demo/ml/sample.xml +36 -38
- data/demo/ml/sample_html.html +7 -2
- data/demo/ml/sample_html4.html +9 -2
- data/demo/ml/sample_xhtml.html +7 -2
- data/demo/ml/sample_xhtml4.html +10 -3
- data/demo/xhtml.rb +41 -30
- data/demo/xhtml4.rb +35 -26
- data/demo/xml.rb +25 -20
- data/lib/meteor/attribute_map.rb +8 -6
- data/lib/meteor/core/kernel.rb +288 -260
- data/lib/meteor/core/util/pattern_cache.rb +16 -15
- data/lib/meteor/element.rb +65 -63
- data/lib/meteor/exception/no_such_element_exception.rb +15 -15
- data/lib/meteor/ml/html/parser_impl.rb +58 -33
- data/lib/meteor/ml/html4/parser_impl.rb +118 -90
- data/lib/meteor/ml/xhtml/parser_impl.rb +33 -29
- data/lib/meteor/ml/xhtml4/parser_impl.rb +98 -90
- data/lib/meteor/ml/xml/parser_impl.rb +35 -25
- data/lib/meteor/parser_factory.rb +125 -125
- data/lib/meteor.rb +2 -2
- metadata +2 -2
|
@@ -42,16 +42,16 @@ module Meteor
|
|
|
42
42
|
#
|
|
43
43
|
def initialize(*args)
|
|
44
44
|
case args.length
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
when 0
|
|
46
|
+
initialize_0
|
|
47
|
+
when 1
|
|
48
|
+
initialize_1(args[0])
|
|
49
|
+
when 2
|
|
50
|
+
initialize_2(args[0], args[1])
|
|
51
|
+
when 3
|
|
52
|
+
initialize_3(args[0], args[1], args[2])
|
|
53
|
+
else
|
|
54
|
+
raise ArgumentError
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -97,7 +97,7 @@ module Meteor
|
|
|
97
97
|
# @param [String] root root directory (基準ディレクトリ)
|
|
98
98
|
# @param [String] enc default character encoding (デフォルト文字エンコーディング)
|
|
99
99
|
#
|
|
100
|
-
def initialize_3(type
|
|
100
|
+
def initialize_3(type, root, enc)
|
|
101
101
|
@cache = Hash.new
|
|
102
102
|
@type = type
|
|
103
103
|
@root = root
|
|
@@ -123,11 +123,13 @@ module Meteor
|
|
|
123
123
|
elsif opts.include?(:base_dir)
|
|
124
124
|
@root = opts[:base_dir]
|
|
125
125
|
end
|
|
126
|
+
|
|
126
127
|
if opts.include?(:enc)
|
|
127
128
|
@enc = opts[:enc]
|
|
128
129
|
elsif opts.include?(:base_enc)
|
|
129
130
|
@enc = opts[:base_enc]
|
|
130
131
|
end
|
|
132
|
+
|
|
131
133
|
if opts.include?(:type)
|
|
132
134
|
@type = opts[:type]
|
|
133
135
|
elsif opts.include?(:base_type)
|
|
@@ -162,20 +164,21 @@ module Meteor
|
|
|
162
164
|
#
|
|
163
165
|
def link(*args)
|
|
164
166
|
case args.length
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
else
|
|
173
|
-
raise ArgumentError
|
|
174
|
-
end
|
|
175
|
-
when 3
|
|
176
|
-
link_3(args[0], args[1], args[2])
|
|
167
|
+
when 1
|
|
168
|
+
link_1(args[0])
|
|
169
|
+
when 2
|
|
170
|
+
if args[0].kind_of?(Fixnum) || args[0].kind_of?(Symbol)
|
|
171
|
+
link_2_n(args[0], args[1])
|
|
172
|
+
elsif args[0].kind_of?(String)
|
|
173
|
+
link_2_s(args[0], args[1])
|
|
177
174
|
else
|
|
178
175
|
raise ArgumentError
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
when 3
|
|
179
|
+
link_3(args[0], args[1], args[2])
|
|
180
|
+
else
|
|
181
|
+
raise ArgumentError
|
|
179
182
|
end
|
|
180
183
|
end
|
|
181
184
|
|
|
@@ -188,15 +191,15 @@ module Meteor
|
|
|
188
191
|
paths = File.split(path)
|
|
189
192
|
|
|
190
193
|
if paths.length == 1
|
|
191
|
-
return File.basename(paths[0],
|
|
194
|
+
return File.basename(paths[0], ".*")
|
|
192
195
|
else
|
|
193
196
|
if ".".eql?(paths[0])
|
|
194
|
-
paths.delete_at
|
|
195
|
-
paths[paths.length - 1] = File.basename(paths[paths.length - 1],
|
|
196
|
-
return String.new(
|
|
197
|
+
paths.delete_at(0)
|
|
198
|
+
paths[paths.length - 1] = File.basename(paths[paths.length - 1], ".*")
|
|
199
|
+
return String.new("") << "/" << paths.join("/")
|
|
197
200
|
else
|
|
198
|
-
paths[paths.length - 1] = File.basename(paths[paths.length - 1],
|
|
199
|
-
return String.new(
|
|
201
|
+
paths[paths.length - 1] = File.basename(paths[paths.length - 1], ".*")
|
|
202
|
+
return String.new("") << "/" << paths.join("/")
|
|
200
203
|
end
|
|
201
204
|
end
|
|
202
205
|
end
|
|
@@ -215,26 +218,26 @@ module Meteor
|
|
|
215
218
|
relative_url = path_to_url(relative_path)
|
|
216
219
|
|
|
217
220
|
case type
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
221
|
+
when Parser::HTML, :html, :html5
|
|
222
|
+
html = Meteor::Ml::Html::ParserImpl.new
|
|
223
|
+
html.read(File.expand_path(relative_path, @root), enc)
|
|
224
|
+
@cache[relative_url] = html
|
|
225
|
+
when Parser::XML, :xml
|
|
226
|
+
xml = Meteor::Ml::Xml::ParserImpl.new
|
|
227
|
+
xml.read(File.expand_path(relative_path, @root), enc)
|
|
228
|
+
@cache[relative_url] = xml
|
|
229
|
+
when Parser::XHTML, :xhtml, :xhtml5
|
|
230
|
+
xhtml = Meteor::Ml::Xhtml::ParserImpl.new
|
|
231
|
+
xhtml.read(File.expand_path(relative_path, @root), enc)
|
|
232
|
+
@cache[relative_url] = xhtml
|
|
233
|
+
when Parser::HTML4, :html4
|
|
234
|
+
html4 = Meteor::Ml::Html4::ParserImpl.new
|
|
235
|
+
html.read(File.expand_path(relative_path, @root), enc)
|
|
236
|
+
@cache[relative_url] = html4
|
|
237
|
+
when Parser::XHTML4, :xhtml4
|
|
238
|
+
xhtml4 = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
239
|
+
xhtml4.read(File.expand_path(relative_path, @root), enc)
|
|
240
|
+
@cache[relative_url] = xhtml4
|
|
238
241
|
end
|
|
239
242
|
end
|
|
240
243
|
|
|
@@ -251,21 +254,20 @@ module Meteor
|
|
|
251
254
|
relative_url = path_to_url(relative_path)
|
|
252
255
|
|
|
253
256
|
case type
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
257
|
+
when Parser::HTML, :html, :html5
|
|
258
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
259
|
+
when Parser::XML, :xml
|
|
260
|
+
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
261
|
+
when Parser::XHTML, :xhtml, :xhtml5
|
|
262
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
263
|
+
when Parser::HTML4, :html4
|
|
264
|
+
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
265
|
+
when Parser::XHTML4, :xhtml4
|
|
266
|
+
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
264
267
|
end
|
|
265
268
|
|
|
266
269
|
ps.read(File.expand_path(relative_path, @root), @enc)
|
|
267
270
|
@cache[relative_url] = ps
|
|
268
|
-
|
|
269
271
|
end
|
|
270
272
|
|
|
271
273
|
private :link_2_n
|
|
@@ -276,26 +278,25 @@ module Meteor
|
|
|
276
278
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
277
279
|
# @return [Meteor::Parser] parser (パーサ)
|
|
278
280
|
#
|
|
279
|
-
def link_2_s(relative_path,enc)
|
|
281
|
+
def link_2_s(relative_path, enc)
|
|
280
282
|
|
|
281
283
|
relative_url = path_to_url(relative_path)
|
|
282
284
|
|
|
283
285
|
case @type
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
286
|
+
when Parser::HTML, :html
|
|
287
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
288
|
+
when Parser::XML, :xml
|
|
289
|
+
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
290
|
+
when Parser::XHTML, :xhtml
|
|
291
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
292
|
+
when Parser::HTML4, :html4
|
|
293
|
+
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
294
|
+
when Parser::XHTML4, :xhtml4
|
|
295
|
+
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
294
296
|
end
|
|
295
297
|
|
|
296
298
|
ps.read(File.expand_path(relative_path, @root), enc)
|
|
297
299
|
@cache[relative_url] = ps
|
|
298
|
-
|
|
299
300
|
end
|
|
300
301
|
|
|
301
302
|
private :link_2_s
|
|
@@ -310,23 +311,22 @@ module Meteor
|
|
|
310
311
|
relative_url = path_to_url(relative_path)
|
|
311
312
|
|
|
312
313
|
case @type
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
314
|
+
when Parser::HTML, :html
|
|
315
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
316
|
+
when Parser::XML, :xml
|
|
317
|
+
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
318
|
+
when Parser::XHTML, :xhtml
|
|
319
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
320
|
+
when Parser::HTML4, :html4
|
|
321
|
+
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
322
|
+
when Parser::XHTML4, :xhtml4
|
|
323
|
+
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
324
|
+
else
|
|
325
|
+
raise ArgumentError
|
|
325
326
|
end
|
|
326
327
|
|
|
327
328
|
ps.read(File.expand_path(relative_path, @root), @enc)
|
|
328
329
|
@cache[relative_url] = ps
|
|
329
|
-
|
|
330
330
|
end
|
|
331
331
|
|
|
332
332
|
private :link_1
|
|
@@ -351,10 +351,10 @@ module Meteor
|
|
|
351
351
|
# @deprecated
|
|
352
352
|
def parser(*args)
|
|
353
353
|
case args.length
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
354
|
+
when 1
|
|
355
|
+
parser_1(args[0])
|
|
356
|
+
when 2, 3
|
|
357
|
+
link(args)
|
|
358
358
|
end
|
|
359
359
|
# parser_1(key)
|
|
360
360
|
end
|
|
@@ -367,16 +367,16 @@ module Meteor
|
|
|
367
367
|
def parser_1(key)
|
|
368
368
|
@pif = @cache[key.to_s]
|
|
369
369
|
case @pif.doc_type
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
370
|
+
when Meteor::Parser::HTML
|
|
371
|
+
Meteor::Ml::Html::ParserImpl.new(@pif)
|
|
372
|
+
when Meteor::Parser::XML
|
|
373
|
+
Meteor::Ml::Xml::ParserImpl.new(@pif)
|
|
374
|
+
when Meteor::Parser::XHTML
|
|
375
|
+
Meteor::Ml::Xhtml::ParserImpl.new(@pif)
|
|
376
|
+
when Meteor::Parser::HTML4
|
|
377
|
+
Meteor::Ml::Html4::ParserImpl.new(@pif)
|
|
378
|
+
when Meteor::Parser::XHTML4
|
|
379
|
+
Meteor::Ml::Xhtml4::ParserImpl.new(@pif)
|
|
380
380
|
end
|
|
381
381
|
end
|
|
382
382
|
|
|
@@ -406,12 +406,12 @@ module Meteor
|
|
|
406
406
|
#
|
|
407
407
|
def link_str(*args)
|
|
408
408
|
case args.length
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
409
|
+
when 2
|
|
410
|
+
link_str_2(args[0], args[1])
|
|
411
|
+
when 3
|
|
412
|
+
link_str_3(args[0], args[1], args[2])
|
|
413
|
+
else
|
|
414
|
+
raise ArgumentError
|
|
415
415
|
end
|
|
416
416
|
end
|
|
417
417
|
|
|
@@ -424,16 +424,16 @@ module Meteor
|
|
|
424
424
|
#
|
|
425
425
|
def link_str_3(type, relative_url, doc)
|
|
426
426
|
case type
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
427
|
+
when Parser::HTML, :html
|
|
428
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
429
|
+
when Parser::XML, :xml
|
|
430
|
+
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
431
|
+
when Parser::XHTML, :xhtml
|
|
432
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
433
|
+
when Parser::HTML4, :html4
|
|
434
|
+
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
435
|
+
when Parser::XHTML4, :xhtml4
|
|
436
|
+
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
437
437
|
end
|
|
438
438
|
|
|
439
439
|
ps.dcument = doc
|
|
@@ -451,16 +451,16 @@ module Meteor
|
|
|
451
451
|
#
|
|
452
452
|
def link_str_2(relative_url, doc)
|
|
453
453
|
case @type
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
454
|
+
when Parser::HTML, :html
|
|
455
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
456
|
+
when Parser::XML, :xml
|
|
457
|
+
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
458
|
+
when Parser::XHTML, :xhtml
|
|
459
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
460
|
+
when Parser::HTML4, :html4
|
|
461
|
+
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
462
|
+
when Parser::XHTML4, :xhtml4
|
|
463
|
+
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
464
464
|
end
|
|
465
465
|
|
|
466
466
|
ps.document = doc
|
data/lib/meteor.rb
CHANGED
|
@@ -36,11 +36,11 @@ require "meteor/ml/xml/parser_impl"
|
|
|
36
36
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
37
37
|
#
|
|
38
38
|
# @author Yasumasa Ashida
|
|
39
|
-
# @version 0.9.
|
|
39
|
+
# @version 0.9.14
|
|
40
40
|
#
|
|
41
41
|
|
|
42
42
|
module Meteor
|
|
43
|
-
VERSION =
|
|
43
|
+
VERSION = "0.9.14"
|
|
44
44
|
|
|
45
45
|
# require 'fileutils'
|
|
46
46
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: meteor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yasumasa Ashida
|
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
82
82
|
- !ruby/object:Gem::Version
|
|
83
83
|
version: '0'
|
|
84
84
|
requirements: []
|
|
85
|
-
rubygems_version: 4.0.
|
|
85
|
+
rubygems_version: 4.0.13
|
|
86
86
|
specification_version: 4
|
|
87
87
|
summary: A lightweight (X)HTML & XML parser
|
|
88
88
|
test_files:
|