meteor 0.9.15 → 0.9.17
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 +8 -0
- data/Gemfile.lock +1 -1
- data/demo/html.rb +2 -2
- data/demo/html4.rb +4 -4
- data/demo/xhtml.rb +2 -2
- data/demo/xhtml4.rb +2 -2
- data/demo/xml.rb +2 -2
- data/lib/meteor/core/kernel.rb +0 -5
- data/lib/meteor/{element_factory.rb → elements.rb} +26 -12
- data/lib/meteor/ml/html4/parser_impl.rb +6 -8
- data/lib/meteor/ml/xhtml4/parser_impl.rb +4 -6
- data/lib/meteor/ml/xml/parser_impl.rb +4 -6
- data/lib/meteor/{parser_factory.rb → parsers.rb} +65 -142
- data/lib/meteor.rb +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a115fb12155d38898790a30ed917abe7e22fdac5ce8d4bc76e732e0eb2c4b64
|
|
4
|
+
data.tar.gz: f673cc5f72f4a3c9c8253d8fee3cb44365894911f9ad4863eb29693d10fe36b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2fe5a34dc71d3f5f889300653179b98d9c81b87652c1658e95c091b89079f97eeb4e1e8489a4cc037eda6dc935dc6f4d0a8fa56e2b0c04cb26e3dd6780bfda0c
|
|
7
|
+
data.tar.gz: 2b578499df7e05f249f493ee6646f026655f3eeb6b819e01b0822a8f83256cc6d39410907f0ecb28f62f0a4dedca2bcf9da6b46b9b121cdf496d2232cc4aac70
|
data/ChangeLog
CHANGED
data/Gemfile.lock
CHANGED
data/demo/html.rb
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::
|
|
9
|
-
root = Meteor::
|
|
8
|
+
Meteor::Elements.add(:html, "ml/sample_html.html", "UTF-8")
|
|
9
|
+
root = Meteor::Elements.get("/ml/sample_html")
|
|
10
10
|
|
|
11
11
|
start_time = Time.new.to_f
|
|
12
12
|
|
data/demo/html4.rb
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
# Meteor::
|
|
9
|
-
Meteor::
|
|
10
|
-
Meteor::
|
|
8
|
+
# Meteor::Elements.add(:html4,'ml/sample_4.html', 'UTF-8')
|
|
9
|
+
Meteor::Elements.options = {type: :html4}
|
|
10
|
+
Meteor::Elements.add("ml/sample_html4.html")
|
|
11
11
|
|
|
12
|
-
root = Meteor::
|
|
12
|
+
root = Meteor::Elements.get("/ml/sample_html4")
|
|
13
13
|
|
|
14
14
|
start_time = Time.new.to_f
|
|
15
15
|
|
data/demo/xhtml.rb
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::
|
|
9
|
-
root = Meteor::
|
|
8
|
+
Meteor::Elements.add(:xhtml, "ml/sample_xhtml.html", "UTF-8")
|
|
9
|
+
root = Meteor::Elements.get("/ml/sample_xhtml")
|
|
10
10
|
|
|
11
11
|
startTime = Time.new.to_f
|
|
12
12
|
|
data/demo/xhtml4.rb
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::
|
|
9
|
-
root = Meteor::
|
|
8
|
+
Meteor::Elements.add(:xhtml4, "ml/sample_xhtml4.html", "UTF-8")
|
|
9
|
+
root = Meteor::Elements.get("/ml/sample_xhtml4")
|
|
10
10
|
|
|
11
11
|
startTime = Time.new.to_f
|
|
12
12
|
|
data/demo/xml.rb
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::
|
|
9
|
-
root = Meteor::
|
|
8
|
+
Meteor::Elements.add(Meteor::XML, "ml/sample.xml", "UTF-8")
|
|
9
|
+
root = Meteor::Elements.get("/ml/sample")
|
|
10
10
|
|
|
11
11
|
start_time = Time.new.to_f
|
|
12
12
|
|
data/lib/meteor/core/kernel.rb
CHANGED
|
@@ -463,7 +463,6 @@ module Meteor
|
|
|
463
463
|
@elm_.empty = true
|
|
464
464
|
|
|
465
465
|
@elm_.parser = self
|
|
466
|
-
|
|
467
466
|
when FIVE
|
|
468
467
|
# element (要素)
|
|
469
468
|
@elm_ = Meteor::Element.new(name)
|
|
@@ -596,7 +595,6 @@ module Meteor
|
|
|
596
595
|
# @return [Meteor::Element] element (要素)
|
|
597
596
|
#
|
|
598
597
|
def element_2(attr_name, attr_value)
|
|
599
|
-
|
|
600
598
|
quote_attribute(attr_name, attr_value)
|
|
601
599
|
|
|
602
600
|
element_pattern_2
|
|
@@ -613,7 +611,6 @@ module Meteor
|
|
|
613
611
|
|
|
614
612
|
@elm_ = nil
|
|
615
613
|
end
|
|
616
|
-
#=end
|
|
617
614
|
|
|
618
615
|
=begin
|
|
619
616
|
@pattern_cc_1 = "<([^<>\"]*)(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)\\/>|<([^<>\"]*)(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)>(((?!(\\3[^<>]*>)).)*)<\\/\\3>"
|
|
@@ -1056,7 +1053,6 @@ module Meteor
|
|
|
1056
1053
|
# @return [Meteor::Element] element (要素)
|
|
1057
1054
|
#
|
|
1058
1055
|
def element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1059
|
-
|
|
1060
1056
|
quote_element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1061
1057
|
|
|
1062
1058
|
element_pattern_4
|
|
@@ -1792,7 +1788,6 @@ module Meteor
|
|
|
1792
1788
|
# @return [Meteor::Element] element (要素)
|
|
1793
1789
|
#
|
|
1794
1790
|
def set_content_3(elm, content, entity_ref = true)
|
|
1795
|
-
|
|
1796
1791
|
if entity_ref || !elm.raw_content
|
|
1797
1792
|
escape_content(content, elm)
|
|
1798
1793
|
end
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
module Meteor
|
|
5
5
|
#
|
|
6
|
-
#
|
|
6
|
+
# Elements Class (要素ファクトリ クラス)
|
|
7
7
|
#
|
|
8
|
-
class
|
|
9
|
-
@@pf = Meteor::
|
|
8
|
+
class Elements
|
|
9
|
+
@@pf = Meteor::Parsers.new
|
|
10
10
|
|
|
11
11
|
#
|
|
12
12
|
# set options (オプションをセットする)
|
|
@@ -23,37 +23,42 @@ module Meteor
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
#
|
|
26
|
-
#@overload
|
|
26
|
+
#@overload add(type,relative_path,enc)
|
|
27
27
|
# generate parser (パーサを作成する)
|
|
28
28
|
# @param [Fixnum] type type of parser (パーサ・タイプ)
|
|
29
29
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
30
30
|
# @param [String] enc character encoding (エンコーディング)
|
|
31
31
|
# @return [Meteor::Parser] parser (パーサ)
|
|
32
|
-
#@overload
|
|
32
|
+
#@overload add(type,relative_path)
|
|
33
33
|
# generate parser (パーサを作成する)
|
|
34
34
|
# @param [Fixnum] type type of parser (パーサ・タイプ)
|
|
35
35
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
36
36
|
# @return [Meteor::Parser] parser (パーサ)
|
|
37
37
|
#
|
|
38
|
-
def self.
|
|
39
|
-
@@pf.
|
|
38
|
+
def self.add(*args)
|
|
39
|
+
@@pf.add(*args)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
#
|
|
43
|
-
# @overload
|
|
43
|
+
# @overload add_str(type, relative_url, doc)
|
|
44
44
|
# generate parser (パーサを作成する)
|
|
45
45
|
# @param [Fixnum] type type of parser (パーサ・タイプ)
|
|
46
46
|
# @param [String] relative_url relative URL (相対URL)
|
|
47
47
|
# @param [String] doc document (ドキュメント)
|
|
48
48
|
# @return [Meteor::Parser] parser (パーサ)
|
|
49
|
-
# @overload
|
|
49
|
+
# @overload add_str(relative_url, doc)
|
|
50
50
|
# generate parser (パーサを作成する)
|
|
51
51
|
# @param [String] relative_url relative URL (相対URL)
|
|
52
52
|
# @param [String] doc document (ドキュメント)
|
|
53
53
|
# @return [Meteor::Parser] parser (パーサ)
|
|
54
54
|
#
|
|
55
|
-
def self.
|
|
56
|
-
@@pf.
|
|
55
|
+
def self.add_str(*args)
|
|
56
|
+
@@pf.add_str(args)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class << self
|
|
60
|
+
alias_method :link, :add
|
|
61
|
+
alias_method :link_str, :add_str
|
|
57
62
|
end
|
|
58
63
|
|
|
59
64
|
#
|
|
@@ -61,8 +66,17 @@ module Meteor
|
|
|
61
66
|
# @param [String,Symbol] key identifier (キー)
|
|
62
67
|
# @return [Meteor::RootElement] root element (ルート要素)
|
|
63
68
|
#
|
|
64
|
-
def self.
|
|
69
|
+
def self.get(key)
|
|
65
70
|
@@pf.element(key)
|
|
66
71
|
end
|
|
72
|
+
|
|
73
|
+
class << self
|
|
74
|
+
alias_method :element, :get
|
|
75
|
+
end
|
|
67
76
|
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# Elements Class (要素ファクトリ クラス)
|
|
80
|
+
#
|
|
81
|
+
Elements = Elements
|
|
68
82
|
end
|
|
@@ -52,7 +52,7 @@ module Meteor
|
|
|
52
52
|
# @@pattern_true = Regexp.new("true")
|
|
53
53
|
# @@pattern_false = Regexp.new("false")
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
GET_ATTRS_MAP2 = "\\s(disabled|readonly|checked|selected|multiple)"
|
|
57
57
|
|
|
58
58
|
@@pattern_selected_m = Regexp.new(SELECTED_M)
|
|
@@ -66,7 +66,6 @@ module Meteor
|
|
|
66
66
|
@@pattern_multiple_m = Regexp.new(MULTIPLE_M)
|
|
67
67
|
@@pattern_multiple_r = Regexp.new(MULTIPLE_R)
|
|
68
68
|
|
|
69
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
70
69
|
@@pattern_get_attrs_map2 = Regexp.new(GET_ATTRS_MAP2)
|
|
71
70
|
|
|
72
71
|
# @@pattern_match_tag = Regexp.new(@@match_tag)
|
|
@@ -95,9 +94,11 @@ module Meteor
|
|
|
95
94
|
|
|
96
95
|
PATTERN_ESCAPE = "[&\"'<> ]"
|
|
97
96
|
PATTERN_ESCAPE_CONTENT = "[&\"'<> \\n]"
|
|
98
|
-
|
|
99
97
|
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
|
100
98
|
@@pattern_escape_content = Regexp.new(PATTERN_ESCAPE_CONTENT)
|
|
99
|
+
|
|
100
|
+
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt|nbsp);"
|
|
101
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
101
102
|
@@pattern_br_2 = Regexp.new(BR)
|
|
102
103
|
|
|
103
104
|
#
|
|
@@ -350,7 +351,6 @@ module Meteor
|
|
|
350
351
|
# @return [Meteor::Element] element (要素)
|
|
351
352
|
#
|
|
352
353
|
def element_2(attr_name, attr_value)
|
|
353
|
-
|
|
354
354
|
quote_attribute(attr_name, attr_value)
|
|
355
355
|
|
|
356
356
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value
|
|
@@ -385,7 +385,6 @@ module Meteor
|
|
|
385
385
|
# @return [Meteor::Element] element (要素)
|
|
386
386
|
#
|
|
387
387
|
def element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
388
|
-
|
|
389
388
|
quote_element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
390
389
|
|
|
391
390
|
# 空要素の場合(<->内容あり要素の場合)
|
|
@@ -578,7 +577,6 @@ module Meteor
|
|
|
578
577
|
private :get_type
|
|
579
578
|
|
|
580
579
|
def get_attr_value_r(elm, match_p)
|
|
581
|
-
|
|
582
580
|
@res = match_p.match(elm.attributes)
|
|
583
581
|
|
|
584
582
|
if @res
|
|
@@ -650,14 +648,14 @@ module Meteor
|
|
|
650
648
|
private :remove_attrs_
|
|
651
649
|
|
|
652
650
|
def escape(content)
|
|
653
|
-
# 特殊文字の置換
|
|
651
|
+
# replace special character (特殊文字の置換)
|
|
654
652
|
content = content.gsub(@@pattern_escape, TABLE_FOR_ESCAPE_)
|
|
655
653
|
|
|
656
654
|
content
|
|
657
655
|
end
|
|
658
656
|
|
|
659
657
|
def escape_content(content, elm)
|
|
660
|
-
# 特殊文字の置換
|
|
658
|
+
# replace special character (特殊文字の置換)
|
|
661
659
|
content = content.gsub(@@pattern_escape_content, TABLE_FOR_ESCAPE_CONTENT_)
|
|
662
660
|
|
|
663
661
|
content
|
|
@@ -48,8 +48,6 @@ module Meteor
|
|
|
48
48
|
MULTIPLE_R = "multiple=\"[^\"]*\""
|
|
49
49
|
MULTIPLE_U = "multiple=\"multiple\""
|
|
50
50
|
|
|
51
|
-
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt|nbsp);"
|
|
52
|
-
|
|
53
51
|
@@pattern_selected_m = Regexp.new(SELECTED_M)
|
|
54
52
|
@@pattern_selected_m1 = Regexp.new(SELECTED_M1)
|
|
55
53
|
@@pattern_selected_r = Regexp.new(SELECTED_R)
|
|
@@ -66,10 +64,6 @@ module Meteor
|
|
|
66
64
|
@@pattern_multiple_m1 = Regexp.new(MULTIPLE_M1)
|
|
67
65
|
@@pattern_multiple_r = Regexp.new(MULTIPLE_R)
|
|
68
66
|
|
|
69
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
70
|
-
|
|
71
|
-
@@pattern_br_2 = Regexp.new("<br\\/>")
|
|
72
|
-
|
|
73
67
|
# @@pattern_match_tag = Regexp.new(@@match_tag)
|
|
74
68
|
# @@pattern_match_tag2 = Regexp.new(@@match_tag_2)
|
|
75
69
|
|
|
@@ -99,6 +93,10 @@ module Meteor
|
|
|
99
93
|
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
|
100
94
|
@@pattern_escape_content = Regexp.new(PATTERN_ESCAPE_CONTENT)
|
|
101
95
|
|
|
96
|
+
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt|nbsp);"
|
|
97
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
98
|
+
@@pattern_br_2 = Regexp.new("<br\\/>")
|
|
99
|
+
|
|
102
100
|
#
|
|
103
101
|
# initializer (イニシャライザ)
|
|
104
102
|
# @overload initialize
|
|
@@ -11,10 +11,6 @@ module Meteor
|
|
|
11
11
|
# KAIGYO_CODE = "\r?\n|\r"
|
|
12
12
|
KAIGYO_CODE = ["\r\n", "\n", "\r"]
|
|
13
13
|
|
|
14
|
-
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt);"
|
|
15
|
-
|
|
16
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
17
|
-
|
|
18
14
|
TABLE_FOR_ESCAPE_ = {
|
|
19
15
|
"&" => "&",
|
|
20
16
|
"\"" => """,
|
|
@@ -22,9 +18,13 @@ module Meteor
|
|
|
22
18
|
"<" => "<",
|
|
23
19
|
">" => ">"
|
|
24
20
|
}
|
|
21
|
+
|
|
25
22
|
PATTERN_ESCAPE = "[&\\\"'<>]"
|
|
26
23
|
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
|
27
24
|
|
|
25
|
+
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt);"
|
|
26
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
27
|
+
|
|
28
28
|
#
|
|
29
29
|
# initializer (イニシャライザ)
|
|
30
30
|
# @overload initialize
|
|
@@ -51,8 +51,6 @@ module Meteor
|
|
|
51
51
|
# end
|
|
52
52
|
#
|
|
53
53
|
# private :initialize_0
|
|
54
|
-
#
|
|
55
|
-
# private :initialize_0
|
|
56
54
|
|
|
57
55
|
#
|
|
58
56
|
# initializer (イニシャライザ)
|
|
@@ -12,7 +12,7 @@ module Meteor
|
|
|
12
12
|
# @!attribute [rw] enc
|
|
13
13
|
# @return [String] default character encoding (デフォルトエンコーディング)
|
|
14
14
|
#
|
|
15
|
-
class
|
|
15
|
+
class Parsers
|
|
16
16
|
attr_accessor :type
|
|
17
17
|
attr_accessor :root
|
|
18
18
|
attr_accessor :enc
|
|
@@ -59,9 +59,7 @@ module Meteor
|
|
|
59
59
|
# initializer (イニシャライザ)
|
|
60
60
|
#
|
|
61
61
|
def initialize_0
|
|
62
|
-
|
|
63
|
-
@root = "."
|
|
64
|
-
@enc = "UTF-8"
|
|
62
|
+
initialize_2
|
|
65
63
|
end
|
|
66
64
|
|
|
67
65
|
private :initialize_0
|
|
@@ -71,9 +69,7 @@ module Meteor
|
|
|
71
69
|
# @param [String] root root directory (基準ディレクトリ)
|
|
72
70
|
#
|
|
73
71
|
def initialize_1(root)
|
|
74
|
-
|
|
75
|
-
@root = root
|
|
76
|
-
@enc = "UTF-8"
|
|
72
|
+
initialize_2(root)
|
|
77
73
|
end
|
|
78
74
|
|
|
79
75
|
private :initialize_1
|
|
@@ -83,7 +79,7 @@ module Meteor
|
|
|
83
79
|
# @param [String] root root directory (基準ディレクトリ)
|
|
84
80
|
# @param [String] enc default character encoding (デフォルト文字エンコーディング)
|
|
85
81
|
#
|
|
86
|
-
def initialize_2(root, enc)
|
|
82
|
+
def initialize_2(root = ".", enc = "UTF-8")
|
|
87
83
|
@cache = Hash.new
|
|
88
84
|
@root = root
|
|
89
85
|
@enc = enc
|
|
@@ -97,7 +93,7 @@ module Meteor
|
|
|
97
93
|
# @param [String] root root directory (基準ディレクトリ)
|
|
98
94
|
# @param [String] enc default character encoding (デフォルト文字エンコーディング)
|
|
99
95
|
#
|
|
100
|
-
def initialize_3(type, root, enc)
|
|
96
|
+
def initialize_3(type, root=".", enc = "UTF-8")
|
|
101
97
|
@cache = Hash.new
|
|
102
98
|
@type = type
|
|
103
99
|
@root = root
|
|
@@ -141,47 +137,48 @@ module Meteor
|
|
|
141
137
|
end
|
|
142
138
|
|
|
143
139
|
#
|
|
144
|
-
#@overload
|
|
140
|
+
#@overload add(relative_path,enc)
|
|
145
141
|
# generate parser (パーサを作成する)
|
|
146
142
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
147
143
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
148
144
|
# @return [Meteor::Parser] parser (パーサ)
|
|
149
|
-
#@overload
|
|
145
|
+
#@overload add(relative_path)
|
|
150
146
|
# generate parser (パーサを作成する)
|
|
151
147
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
152
148
|
# @return [Meteor::Parser] parser (パーサ)
|
|
153
|
-
#@overload
|
|
149
|
+
#@overload add(type,relative_path,enc)
|
|
154
150
|
# generate parser (パーサを作成する)
|
|
155
151
|
# @param [Fixnum,Symbol] type type of parser (パーサ・タイプ)
|
|
156
152
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
157
153
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
158
154
|
# @return [Meteor::Parser] parser (パーサ)
|
|
159
|
-
#@overload
|
|
155
|
+
#@overload add(type,relative_path)
|
|
160
156
|
# generate parser (パーサを作成する)
|
|
161
157
|
# @param [Fixnum,Symbol] type type of parser (パーサ・タイプ)
|
|
162
158
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
163
159
|
# @return [Meteor::Parser] parser (パーサ)
|
|
164
160
|
#
|
|
165
|
-
def
|
|
161
|
+
def add(*args)
|
|
166
162
|
case args.length
|
|
167
163
|
when 1
|
|
168
|
-
|
|
164
|
+
add_1(args[0])
|
|
169
165
|
when 2
|
|
170
166
|
if args[0].kind_of?(Fixnum) || args[0].kind_of?(Symbol)
|
|
171
|
-
|
|
167
|
+
add_2_n(args[0], args[1])
|
|
172
168
|
elsif args[0].kind_of?(String)
|
|
173
|
-
|
|
169
|
+
add_2_s(args[0], args[1])
|
|
174
170
|
else
|
|
175
171
|
raise ArgumentError
|
|
176
172
|
end
|
|
177
|
-
|
|
178
173
|
when 3
|
|
179
|
-
|
|
174
|
+
add_3(args[0], args[1], args[2])
|
|
180
175
|
else
|
|
181
176
|
raise ArgumentError
|
|
182
177
|
end
|
|
183
178
|
end
|
|
184
179
|
|
|
180
|
+
alias_method :link, :add
|
|
181
|
+
|
|
185
182
|
#
|
|
186
183
|
# change relative path to relative url (相対パスを相対URLにする)
|
|
187
184
|
# @param [String] path relative path (相対パス)
|
|
@@ -213,35 +210,15 @@ module Meteor
|
|
|
213
210
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
214
211
|
# @return [Meteor::Parser] parser(パーサ)
|
|
215
212
|
#
|
|
216
|
-
def
|
|
213
|
+
def add_3(type, relative_path, enc = "UTF-8")
|
|
214
|
+
ps = new_parser(type)
|
|
215
|
+
ps.read(File.expand_path(relative_path, @root), enc)
|
|
217
216
|
|
|
218
217
|
relative_url = path_to_url(relative_path)
|
|
219
|
-
|
|
220
|
-
case type
|
|
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
|
|
241
|
-
end
|
|
218
|
+
@cache[relative_url] = ps
|
|
242
219
|
end
|
|
243
220
|
|
|
244
|
-
private :
|
|
221
|
+
private :add_3
|
|
245
222
|
|
|
246
223
|
#
|
|
247
224
|
# generate parser (パーサを作成する)
|
|
@@ -249,28 +226,11 @@ module Meteor
|
|
|
249
226
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
250
227
|
# @return [Meteor::Parser] parser (パーサ)
|
|
251
228
|
#
|
|
252
|
-
def
|
|
253
|
-
|
|
254
|
-
relative_url = path_to_url(relative_path)
|
|
255
|
-
|
|
256
|
-
case type
|
|
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
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
ps.read(File.expand_path(relative_path, @root), @enc)
|
|
270
|
-
@cache[relative_url] = ps
|
|
229
|
+
def add_2_n(type, relative_path)
|
|
230
|
+
add_3(type, relative_path, @enc)
|
|
271
231
|
end
|
|
272
232
|
|
|
273
|
-
private :
|
|
233
|
+
private :add_2_n
|
|
274
234
|
|
|
275
235
|
#
|
|
276
236
|
# generate parser (パーサを作成する)
|
|
@@ -278,58 +238,22 @@ module Meteor
|
|
|
278
238
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
279
239
|
# @return [Meteor::Parser] parser (パーサ)
|
|
280
240
|
#
|
|
281
|
-
def
|
|
282
|
-
|
|
283
|
-
relative_url = path_to_url(relative_path)
|
|
284
|
-
|
|
285
|
-
case @type
|
|
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
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
ps.read(File.expand_path(relative_path, @root), enc)
|
|
299
|
-
@cache[relative_url] = ps
|
|
241
|
+
def add_2_s(relative_path, enc)
|
|
242
|
+
add_3(@type, relative_path, enc)
|
|
300
243
|
end
|
|
301
244
|
|
|
302
|
-
private :
|
|
245
|
+
private :add_2_s
|
|
303
246
|
|
|
304
247
|
#
|
|
305
248
|
# generate parser (パーサを作成する)
|
|
306
249
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
307
250
|
# @return [Meteor::Parser] parser (パーサ)
|
|
308
251
|
#
|
|
309
|
-
def
|
|
310
|
-
|
|
311
|
-
relative_url = path_to_url(relative_path)
|
|
312
|
-
|
|
313
|
-
case @type
|
|
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
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
ps.read(File.expand_path(relative_path, @root), @enc)
|
|
329
|
-
@cache[relative_url] = ps
|
|
252
|
+
def add_1(relative_path)
|
|
253
|
+
add_3(@type, relative_path, @enc)
|
|
330
254
|
end
|
|
331
255
|
|
|
332
|
-
private :
|
|
256
|
+
private :add_1
|
|
333
257
|
|
|
334
258
|
#
|
|
335
259
|
#@overload parser(key)
|
|
@@ -354,7 +278,7 @@ module Meteor
|
|
|
354
278
|
when 1
|
|
355
279
|
parser_1(args[0])
|
|
356
280
|
when 2, 3
|
|
357
|
-
|
|
281
|
+
add(args)
|
|
358
282
|
end
|
|
359
283
|
# parser_1(key)
|
|
360
284
|
end
|
|
@@ -392,24 +316,24 @@ module Meteor
|
|
|
392
316
|
end
|
|
393
317
|
|
|
394
318
|
#
|
|
395
|
-
# @overload
|
|
319
|
+
# @overload add_str(type, relative_url, doc)
|
|
396
320
|
# generate parser (パーサを作成する)
|
|
397
321
|
# @param [Fixnum] type type of parser (パーサ・タイプ)
|
|
398
322
|
# @param [String] relative_url relative URL (相対URL)
|
|
399
323
|
# @param [String] doc document (ドキュメント)
|
|
400
324
|
# @return [Meteor::Parser] parser (パーサ)
|
|
401
|
-
# @overload
|
|
325
|
+
# @overload add_str(relative_url, doc)
|
|
402
326
|
# generate parser (パーサを作成する)
|
|
403
327
|
# @param [String] relative_url relative URL (相対URL)
|
|
404
328
|
# @param [String] doc document (ドキュメント)
|
|
405
329
|
# @return [Meteor::Parser] parser (パーサ)
|
|
406
330
|
#
|
|
407
|
-
def
|
|
331
|
+
def add_str(*args)
|
|
408
332
|
case args.length
|
|
409
333
|
when 2
|
|
410
|
-
|
|
334
|
+
add_str_2(args[0], args[1])
|
|
411
335
|
when 3
|
|
412
|
-
|
|
336
|
+
add_str_3(args[0], args[1], args[2])
|
|
413
337
|
else
|
|
414
338
|
raise ArgumentError
|
|
415
339
|
end
|
|
@@ -422,26 +346,15 @@ module Meteor
|
|
|
422
346
|
# @param [String] doc document (ドキュメント)
|
|
423
347
|
# @return [Meteor::Parser] parser (パーサ)
|
|
424
348
|
#
|
|
425
|
-
def
|
|
426
|
-
|
|
427
|
-
|
|
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
|
-
end
|
|
438
|
-
|
|
439
|
-
ps.dcument = doc
|
|
349
|
+
def add_str_3(type, relative_url, doc)
|
|
350
|
+
ps = new_parser(type)
|
|
351
|
+
ps.document = doc
|
|
440
352
|
ps.parse
|
|
353
|
+
|
|
441
354
|
@cache[relative_url] = ps
|
|
442
355
|
end
|
|
443
356
|
|
|
444
|
-
private :
|
|
357
|
+
private :add_str_3
|
|
445
358
|
|
|
446
359
|
#
|
|
447
360
|
# generate parser (パーサを作成する)
|
|
@@ -449,28 +362,33 @@ module Meteor
|
|
|
449
362
|
# @param [String] doc document (ドキュメント)
|
|
450
363
|
# @return [Meteor::Parser] parser (パーサ)
|
|
451
364
|
#
|
|
452
|
-
def
|
|
453
|
-
|
|
365
|
+
def add_str_2(relative_url, doc)
|
|
366
|
+
add_str_3(@type, relative_url, doc)
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
private :add_str_2
|
|
370
|
+
|
|
371
|
+
alias_method :link_str, :add_str
|
|
372
|
+
alias_method :parser_str, :add_str
|
|
373
|
+
|
|
374
|
+
def new_parser(type)
|
|
375
|
+
case type
|
|
454
376
|
when Parser::HTML, :html
|
|
455
|
-
|
|
377
|
+
Meteor::Ml::Html::ParserImpl.new
|
|
456
378
|
when Parser::XML, :xml
|
|
457
|
-
|
|
379
|
+
Meteor::Ml::Xml::ParserImpl.new
|
|
458
380
|
when Parser::XHTML, :xhtml
|
|
459
|
-
|
|
381
|
+
Meteor::Ml::Xhtml::ParserImpl.new
|
|
460
382
|
when Parser::HTML4, :html4
|
|
461
|
-
|
|
383
|
+
Meteor::Ml::Html4::ParserImpl.new
|
|
462
384
|
when Parser::XHTML4, :xhtml4
|
|
463
|
-
|
|
385
|
+
Meteor::Ml::Xhtml4::ParserImpl.new
|
|
386
|
+
else
|
|
387
|
+
raise ArgumentError
|
|
464
388
|
end
|
|
465
|
-
|
|
466
|
-
ps.document = doc
|
|
467
|
-
ps.parse
|
|
468
|
-
@cache[relative_url] = ps
|
|
469
389
|
end
|
|
470
390
|
|
|
471
|
-
private :
|
|
472
|
-
|
|
473
|
-
alias :paraser_str :link_str
|
|
391
|
+
private :new_parser
|
|
474
392
|
|
|
475
393
|
#
|
|
476
394
|
# set parser (パーサをセットする)
|
|
@@ -490,4 +408,9 @@ module Meteor
|
|
|
490
408
|
self.parser(key)
|
|
491
409
|
end
|
|
492
410
|
end
|
|
411
|
+
|
|
412
|
+
#
|
|
413
|
+
# Parser Factory Class (パーサ・ファクトリ クラス)
|
|
414
|
+
#
|
|
415
|
+
ParserFactory = Parsers
|
|
493
416
|
end
|
data/lib/meteor.rb
CHANGED
|
@@ -6,8 +6,8 @@ require "meteor/root_element"
|
|
|
6
6
|
require "meteor/attribute"
|
|
7
7
|
require "meteor/attribute_map"
|
|
8
8
|
require "meteor/parser"
|
|
9
|
-
require "meteor/
|
|
10
|
-
require "meteor/
|
|
9
|
+
require "meteor/parsers"
|
|
10
|
+
require "meteor/elements"
|
|
11
11
|
require "meteor/exception/no_such_element_exception"
|
|
12
12
|
require "meteor/core/kernel"
|
|
13
13
|
require "meteor/core/util/pattern_cache"
|
|
@@ -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.17
|
|
40
40
|
#
|
|
41
41
|
|
|
42
42
|
module Meteor
|
|
43
|
-
VERSION = "0.9.
|
|
43
|
+
VERSION = "0.9.17"
|
|
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.17
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yasumasa Ashida
|
|
@@ -51,7 +51,7 @@ files:
|
|
|
51
51
|
- lib/meteor/core/kernel.rb
|
|
52
52
|
- lib/meteor/core/util/pattern_cache.rb
|
|
53
53
|
- lib/meteor/element.rb
|
|
54
|
-
- lib/meteor/
|
|
54
|
+
- lib/meteor/elements.rb
|
|
55
55
|
- lib/meteor/exception/no_such_element_exception.rb
|
|
56
56
|
- lib/meteor/ml/html/parser_impl.rb
|
|
57
57
|
- lib/meteor/ml/html4/parser_impl.rb
|
|
@@ -59,7 +59,7 @@ files:
|
|
|
59
59
|
- lib/meteor/ml/xhtml4/parser_impl.rb
|
|
60
60
|
- lib/meteor/ml/xml/parser_impl.rb
|
|
61
61
|
- lib/meteor/parser.rb
|
|
62
|
-
- lib/meteor/
|
|
62
|
+
- lib/meteor/parsers.rb
|
|
63
63
|
- lib/meteor/root_element.rb
|
|
64
64
|
- meteor.gemspec
|
|
65
65
|
- test/meteor_test.rb
|