meteor 0.9.31 → 0.9.32
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 +1 -1
- data/demo/xhtml.rb +3 -3
- data/demo/xhtml4.rb +3 -3
- data/lib/meteor/attribute_map.rb +6 -6
- data/lib/meteor/core/kernel.rb +150 -150
- data/lib/meteor/core/util/pattern_cache.rb +6 -6
- data/lib/meteor/element.rb +10 -10
- data/lib/meteor/exception/no_such_element_exception.rb +15 -15
- data/lib/meteor/ml/html/parser_impl.rb +14 -14
- data/lib/meteor/ml/html4/parser_impl.rb +49 -49
- data/lib/meteor/ml/xhtml/parser_impl.rb +14 -14
- data/lib/meteor/ml/xhtml4/parser_impl.rb +15 -15
- data/lib/meteor/ml/xml/parser_impl.rb +6 -6
- data/lib/meteor/parsers.rb +43 -43
- data/lib/meteor.rb +2 -2
- metadata +1 -1
|
@@ -29,9 +29,9 @@ module Meteor
|
|
|
29
29
|
def self.get(*args)
|
|
30
30
|
case args.length
|
|
31
31
|
when ONE
|
|
32
|
-
|
|
32
|
+
get_one(args[0])
|
|
33
33
|
when TWO
|
|
34
|
-
|
|
34
|
+
get_two(args[0], args[1])
|
|
35
35
|
else
|
|
36
36
|
raise ArgumentError
|
|
37
37
|
end
|
|
@@ -42,7 +42,7 @@ module Meteor
|
|
|
42
42
|
# @param [String] regex regular expression (正規表現)
|
|
43
43
|
# @return [Regexp] pattern (パターン)
|
|
44
44
|
#
|
|
45
|
-
def self.
|
|
45
|
+
def self.get_one(regex)
|
|
46
46
|
if @@regex_cache[regex.to_sym]
|
|
47
47
|
@@regex_cache[regex.to_sym]
|
|
48
48
|
else
|
|
@@ -56,7 +56,7 @@ module Meteor
|
|
|
56
56
|
# @param [Integer] option (オプション)
|
|
57
57
|
# @return [Regexp] psttern (パターン)
|
|
58
58
|
#
|
|
59
|
-
def self.
|
|
59
|
+
def self.get_two(regex, option)
|
|
60
60
|
if @@regex_cache[regex.to_sym]
|
|
61
61
|
@@regex_cache[regex.to_sym]
|
|
62
62
|
else
|
|
@@ -65,8 +65,8 @@ module Meteor
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
class << self
|
|
68
|
-
private :
|
|
69
|
-
private :
|
|
68
|
+
private :get_one
|
|
69
|
+
private :get_two
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
end
|
data/lib/meteor/element.rb
CHANGED
|
@@ -67,7 +67,7 @@ module Meteor
|
|
|
67
67
|
raise ArgumentError
|
|
68
68
|
end
|
|
69
69
|
when Meteor::TWO
|
|
70
|
-
|
|
70
|
+
initialize_two(args[0], args[1])
|
|
71
71
|
when Meteor::ZERO
|
|
72
72
|
else
|
|
73
73
|
raise ArgumentError
|
|
@@ -99,13 +99,13 @@ module Meteor
|
|
|
99
99
|
# @param [Meteor::Element] elm element (要素)
|
|
100
100
|
#
|
|
101
101
|
def initialize_e(elm)
|
|
102
|
-
|
|
102
|
+
initialize_two(elm, elm.parser)
|
|
103
103
|
@usable = true
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
private :initialize_e
|
|
107
107
|
|
|
108
|
-
def
|
|
108
|
+
def initialize_two(elm, ps)
|
|
109
109
|
@parser = ps
|
|
110
110
|
if normal
|
|
111
111
|
ps.element(elm)
|
|
@@ -125,7 +125,7 @@ module Meteor
|
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
private :
|
|
128
|
+
private :initialize_two
|
|
129
129
|
|
|
130
130
|
#
|
|
131
131
|
# clone (複製する)
|
|
@@ -138,9 +138,9 @@ module Meteor
|
|
|
138
138
|
def clone(*args)
|
|
139
139
|
case args.length
|
|
140
140
|
when Meteor::ZERO
|
|
141
|
-
|
|
141
|
+
clone_zero
|
|
142
142
|
when Meteor::ONE
|
|
143
|
-
|
|
143
|
+
clone_one(args[0])
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
|
|
@@ -148,7 +148,7 @@ module Meteor
|
|
|
148
148
|
# clone (複製する)
|
|
149
149
|
# @return [Meteor::Element] element (要素)
|
|
150
150
|
#
|
|
151
|
-
def
|
|
151
|
+
def clone_zero
|
|
152
152
|
obj = parser.element_cache[object_id]
|
|
153
153
|
if obj
|
|
154
154
|
obj.attributes = String.new(attributes)
|
|
@@ -163,14 +163,14 @@ module Meteor
|
|
|
163
163
|
obj
|
|
164
164
|
end
|
|
165
165
|
|
|
166
|
-
private :
|
|
166
|
+
private :clone_zero
|
|
167
167
|
|
|
168
168
|
#
|
|
169
169
|
# clone (複製する)
|
|
170
170
|
# @param [Meteor::Parser] ps parser (パーサ)
|
|
171
171
|
# @return [Meteor::Element] element (要素)
|
|
172
172
|
#
|
|
173
|
-
def
|
|
173
|
+
def clone_one(ps)
|
|
174
174
|
obj = ps.element_hook
|
|
175
175
|
if obj
|
|
176
176
|
obj.attributes = String.new(attributes)
|
|
@@ -184,7 +184,7 @@ module Meteor
|
|
|
184
184
|
obj
|
|
185
185
|
end
|
|
186
186
|
|
|
187
|
-
private :
|
|
187
|
+
private :clone_one
|
|
188
188
|
|
|
189
189
|
#
|
|
190
190
|
# set document (ドキュメントをセットする)
|
|
@@ -38,47 +38,47 @@ module Meteor
|
|
|
38
38
|
def initialize(*args)
|
|
39
39
|
case args.length
|
|
40
40
|
when ONE
|
|
41
|
-
|
|
41
|
+
initialize_one(args[0])
|
|
42
42
|
when TWO
|
|
43
|
-
|
|
43
|
+
initialize_two(args[0], args[1])
|
|
44
44
|
when THREE
|
|
45
|
-
|
|
45
|
+
initialize_three(args[0], args[1], args[2])
|
|
46
46
|
when FOUR
|
|
47
|
-
|
|
47
|
+
initialize_four(args[0], args[1], args[2], args[3])
|
|
48
48
|
when FIVE
|
|
49
|
-
|
|
49
|
+
initialize_five(args[0], args[1], args[2], args[3], args[4])
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
def
|
|
53
|
+
def initialize_one(name)
|
|
54
54
|
self.message = "element not found : #{name}"
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
private :
|
|
57
|
+
private :initialize_one
|
|
58
58
|
|
|
59
|
-
def
|
|
59
|
+
def initialize_two(attr_name, attr_value)
|
|
60
60
|
self.message = "element not found : [#{attr_name}=#{attr_value}]"
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
private :
|
|
63
|
+
private :initialize_two
|
|
64
64
|
|
|
65
|
-
def
|
|
65
|
+
def initialize_three(name, attr_name, attr_value)
|
|
66
66
|
self.message = "element not found : #{name}[#{attr_name}=#{attr_value}]"
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
private :
|
|
69
|
+
private :initialize_three
|
|
70
70
|
|
|
71
|
-
def
|
|
71
|
+
def initialize_four(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
72
72
|
self.message = "element not found : [#{attr_name1}=#{attr_value1}][#{attr_name2}=#{attr_value2}]"
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
private :
|
|
75
|
+
private :initialize_four
|
|
76
76
|
|
|
77
|
-
def
|
|
77
|
+
def initialize_five(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
78
78
|
self.message = "element not found : #{name}[#{attr_name1}=#{attr_value1}][#{attr_name2}=#{attr_value2}]"
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
private :
|
|
81
|
+
private :initialize_five
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -62,9 +62,9 @@ module Meteor
|
|
|
62
62
|
@doc_type = Parser::HTML
|
|
63
63
|
case args.length
|
|
64
64
|
when ZERO
|
|
65
|
-
#
|
|
65
|
+
# initialize_zero
|
|
66
66
|
when ONE
|
|
67
|
-
|
|
67
|
+
initialize_one(args[0])
|
|
68
68
|
else
|
|
69
69
|
raise ArgumentError
|
|
70
70
|
end
|
|
@@ -73,16 +73,16 @@ module Meteor
|
|
|
73
73
|
#
|
|
74
74
|
# initializer (イニシャライザ)
|
|
75
75
|
#
|
|
76
|
-
# def
|
|
76
|
+
# def initialize_zero
|
|
77
77
|
# end
|
|
78
78
|
#
|
|
79
|
-
# private :
|
|
79
|
+
# private :initialize_zero
|
|
80
80
|
|
|
81
81
|
#
|
|
82
82
|
# initializer (イニシャライザ)
|
|
83
83
|
# @param [Meteor::Parser] ps parser (パーサ)
|
|
84
84
|
#
|
|
85
|
-
def
|
|
85
|
+
def initialize_one(ps)
|
|
86
86
|
@root.document = String.new(ps.document)
|
|
87
87
|
self.document_hook = String.new(ps.document_hook)
|
|
88
88
|
@root.content_type = String.new(ps.root_element.content_type)
|
|
@@ -90,7 +90,7 @@ module Meteor
|
|
|
90
90
|
@root.newline = ps.root_element.newline
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
private :
|
|
93
|
+
private :initialize_one
|
|
94
94
|
|
|
95
95
|
#
|
|
96
96
|
# analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
|
|
@@ -98,9 +98,9 @@ module Meteor
|
|
|
98
98
|
def analyze_content_type
|
|
99
99
|
@error_check = false
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
element_three('meta', 'charset', '[a-zA-Z-]+', false)
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
element_three('meta', 'charset', '[a-zA-Z-]+', false) unless @elm_
|
|
104
104
|
|
|
105
105
|
@error_check = true
|
|
106
106
|
|
|
@@ -118,19 +118,19 @@ module Meteor
|
|
|
118
118
|
|
|
119
119
|
def edit_attrs_(elm, attr_name, attr_value)
|
|
120
120
|
if is_match('selected', attr_name) && is_match('option', elm.name)
|
|
121
|
-
|
|
121
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_selected_m, @@pattern_selected_r)
|
|
122
122
|
elsif is_match('multiple', attr_name) && is_match('select', elm.name)
|
|
123
|
-
|
|
123
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_multiple_m, @@pattern_multiple_r)
|
|
124
124
|
elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
|
|
125
|
-
|
|
125
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_disabled_m, @@pattern_disabled_r)
|
|
126
126
|
elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
|
|
127
|
-
|
|
127
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_checked_m, @@pattern_checked_r)
|
|
128
128
|
elsif is_match('readonly', attr_name) &&
|
|
129
129
|
(is_match('textarea',
|
|
130
130
|
elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
|
|
131
|
-
|
|
131
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_readonly_m, @@pattern_readonly_r)
|
|
132
132
|
elsif is_match('required', attr_name) && is_match(REQUIRE_ELEMENT, elm.name)
|
|
133
|
-
|
|
133
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_required_m, @@pattern_required_r)
|
|
134
134
|
else
|
|
135
135
|
super(elm, attr_name, attr_value)
|
|
136
136
|
end
|
|
@@ -82,9 +82,9 @@ module Meteor
|
|
|
82
82
|
@doc_type = Parser::HTML4
|
|
83
83
|
case args.length
|
|
84
84
|
when ZERO
|
|
85
|
-
#
|
|
85
|
+
# initialize_zero
|
|
86
86
|
when ONE
|
|
87
|
-
|
|
87
|
+
initialize_one(args[0])
|
|
88
88
|
else
|
|
89
89
|
raise ArgumentError
|
|
90
90
|
end
|
|
@@ -93,16 +93,16 @@ module Meteor
|
|
|
93
93
|
#
|
|
94
94
|
# initializer (イニシャライザ)
|
|
95
95
|
#
|
|
96
|
-
# def
|
|
96
|
+
# def initialize_zero
|
|
97
97
|
# end
|
|
98
98
|
#
|
|
99
|
-
# private :
|
|
99
|
+
# private :initialize_zero
|
|
100
100
|
|
|
101
101
|
#
|
|
102
102
|
# initializer (イニシャライザ)
|
|
103
103
|
# @param [Meteor::Parser] ps paser (パーサ)
|
|
104
104
|
#
|
|
105
|
-
def
|
|
105
|
+
def initialize_one(ps)
|
|
106
106
|
@root.document = String.new(ps.document)
|
|
107
107
|
self.document_hook = String.new(ps.document_hook)
|
|
108
108
|
@root.content_type = String.new(ps.root_element.content_type)
|
|
@@ -110,7 +110,7 @@ module Meteor
|
|
|
110
110
|
@root.newline = ps.root_element.newline
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
private :
|
|
113
|
+
private :initialize_one
|
|
114
114
|
|
|
115
115
|
#
|
|
116
116
|
# parse document (ドキュメントを解析する)
|
|
@@ -147,9 +147,9 @@ module Meteor
|
|
|
147
147
|
def analyze_content_type
|
|
148
148
|
@error_check = false
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
element_three('meta', 'http-equiv', 'Content-Type')
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
element_three('meta', 'http-equiv', 'Content-Type') unless @elm_
|
|
153
153
|
|
|
154
154
|
@error_check = true
|
|
155
155
|
|
|
@@ -184,7 +184,7 @@ module Meteor
|
|
|
184
184
|
# @param [String] name tag name (タグ名)
|
|
185
185
|
# @return [Meteor::Element] element (要素)
|
|
186
186
|
#
|
|
187
|
-
def
|
|
187
|
+
def element_one(name)
|
|
188
188
|
quote_name(name)
|
|
189
189
|
|
|
190
190
|
# case of void element (空要素の場合(<->内容あり要素の場合))
|
|
@@ -195,7 +195,7 @@ module Meteor
|
|
|
195
195
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
|
196
196
|
@res = @pattern.match(@root.document)
|
|
197
197
|
if @res
|
|
198
|
-
|
|
198
|
+
element_void_one(name)
|
|
199
199
|
else
|
|
200
200
|
puts(Meteor::Exception::NoSuchElementException.new(name).message) if @error_check
|
|
201
201
|
|
|
@@ -213,7 +213,7 @@ module Meteor
|
|
|
213
213
|
# case of normal element (内容あり要素の場合)
|
|
214
214
|
if @res
|
|
215
215
|
@on_search = true
|
|
216
|
-
|
|
216
|
+
element_normal_one(name)
|
|
217
217
|
else
|
|
218
218
|
puts(Meteor::Exception::NoSuchElementException.new(name).message) if @error_check
|
|
219
219
|
|
|
@@ -224,9 +224,9 @@ module Meteor
|
|
|
224
224
|
@elm_
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
-
private :
|
|
227
|
+
private :element_one
|
|
228
228
|
|
|
229
|
-
def
|
|
229
|
+
def element_void_one(name)
|
|
230
230
|
@elm_ = Meteor::Element.new(name)
|
|
231
231
|
# attribute (属性)
|
|
232
232
|
@elm_.attributes = @res[1]
|
|
@@ -238,7 +238,7 @@ module Meteor
|
|
|
238
238
|
@elm_.parser = self
|
|
239
239
|
end
|
|
240
240
|
|
|
241
|
-
private :
|
|
241
|
+
private :element_void_one
|
|
242
242
|
|
|
243
243
|
#
|
|
244
244
|
# get element using tag name and attribute(name="value") (要素のタグ名、属性(属性名="属性値")で検索し、要素を取得する)
|
|
@@ -248,9 +248,9 @@ module Meteor
|
|
|
248
248
|
# @param [true,false] quote quote flag (クオート・フラグ)
|
|
249
249
|
# @return [Meteor::Element] element (要素)
|
|
250
250
|
#
|
|
251
|
-
def
|
|
251
|
+
def element_three(name, attr_name, attr_value, quote = true)
|
|
252
252
|
if quote
|
|
253
|
-
|
|
253
|
+
quote_element_three(name, attr_name, attr_value)
|
|
254
254
|
else
|
|
255
255
|
quote_name(name)
|
|
256
256
|
end
|
|
@@ -266,7 +266,7 @@ module Meteor
|
|
|
266
266
|
# void element search (空要素検索)
|
|
267
267
|
@res = @pattern.match(@root.document)
|
|
268
268
|
if @res
|
|
269
|
-
|
|
269
|
+
element_void_three(name)
|
|
270
270
|
else
|
|
271
271
|
puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message) if @error_check
|
|
272
272
|
|
|
@@ -283,10 +283,10 @@ module Meteor
|
|
|
283
283
|
# search of normal element (内容あり要素検索)
|
|
284
284
|
@res = @pattern.match(@root.document)
|
|
285
285
|
|
|
286
|
-
@res =
|
|
286
|
+
@res = element_normal_three_two if !@res && !is_match(@@match_tag_nne, name)
|
|
287
287
|
|
|
288
288
|
if @res
|
|
289
|
-
|
|
289
|
+
element_normal_three_one(name)
|
|
290
290
|
else
|
|
291
291
|
puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message) if @error_check
|
|
292
292
|
|
|
@@ -297,13 +297,13 @@ module Meteor
|
|
|
297
297
|
@elm_
|
|
298
298
|
end
|
|
299
299
|
|
|
300
|
-
private :
|
|
300
|
+
private :element_three
|
|
301
301
|
|
|
302
|
-
def
|
|
303
|
-
|
|
302
|
+
def element_void_three(name)
|
|
303
|
+
element_void_three_one(name, '"[^<>]*)>')
|
|
304
304
|
end
|
|
305
305
|
|
|
306
|
-
private :
|
|
306
|
+
private :element_void_three
|
|
307
307
|
|
|
308
308
|
#
|
|
309
309
|
# get element using attribute(name="value") (属性(属性名="属性値")で検索し、要素を取得する)
|
|
@@ -311,7 +311,7 @@ module Meteor
|
|
|
311
311
|
# @param [String] attr_value attribute value (属性値)
|
|
312
312
|
# @return [Meteor::Element] element (要素)
|
|
313
313
|
#
|
|
314
|
-
def
|
|
314
|
+
def element_two(attr_name, attr_value)
|
|
315
315
|
quote_attribute(attr_name, attr_value)
|
|
316
316
|
|
|
317
317
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value
|
|
@@ -322,7 +322,7 @@ module Meteor
|
|
|
322
322
|
@res = @pattern.match(@root.document)
|
|
323
323
|
|
|
324
324
|
if @res
|
|
325
|
-
|
|
325
|
+
element_three(@res[1], attr_name, attr_value)
|
|
326
326
|
else
|
|
327
327
|
puts(Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message) if @error_check
|
|
328
328
|
|
|
@@ -332,7 +332,7 @@ module Meteor
|
|
|
332
332
|
@elm_
|
|
333
333
|
end
|
|
334
334
|
|
|
335
|
-
private :
|
|
335
|
+
private :element_two
|
|
336
336
|
|
|
337
337
|
#
|
|
338
338
|
# get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で検索し、要素を取得する)
|
|
@@ -343,8 +343,8 @@ module Meteor
|
|
|
343
343
|
# @param [String] attr_value2 attribute value2 (属性値2)
|
|
344
344
|
# @return [Meteor::Element] element (要素)
|
|
345
345
|
#
|
|
346
|
-
def
|
|
347
|
-
|
|
346
|
+
def element_five(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
347
|
+
quote_element_five(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
348
348
|
|
|
349
349
|
# case of void element (空要素の場合(<->内容あり要素の場合))
|
|
350
350
|
if is_match(@@match_tag, name)
|
|
@@ -361,7 +361,7 @@ module Meteor
|
|
|
361
361
|
@res = @pattern.match(@root.document)
|
|
362
362
|
|
|
363
363
|
if @res
|
|
364
|
-
|
|
364
|
+
element_void_five(name)
|
|
365
365
|
else
|
|
366
366
|
if @error_check
|
|
367
367
|
puts(
|
|
@@ -387,10 +387,10 @@ module Meteor
|
|
|
387
387
|
# search of normal element (内容あり要素検索)
|
|
388
388
|
@res = @pattern.match(@root.document)
|
|
389
389
|
|
|
390
|
-
@res =
|
|
390
|
+
@res = element_normal_five_two if !@res && !is_match(@@match_tag_nne, tag)
|
|
391
391
|
|
|
392
392
|
if @res
|
|
393
|
-
|
|
393
|
+
element_normal_five_one(name)
|
|
394
394
|
else
|
|
395
395
|
if @error_check
|
|
396
396
|
puts(
|
|
@@ -407,13 +407,13 @@ module Meteor
|
|
|
407
407
|
@elm_
|
|
408
408
|
end
|
|
409
409
|
|
|
410
|
-
private :
|
|
410
|
+
private :element_five
|
|
411
411
|
|
|
412
|
-
def
|
|
413
|
-
|
|
412
|
+
def element_void_five(name)
|
|
413
|
+
element_void_five_one(name, '")[^<>]*)>')
|
|
414
414
|
end
|
|
415
415
|
|
|
416
|
-
private :
|
|
416
|
+
private :element_void_five
|
|
417
417
|
|
|
418
418
|
#
|
|
419
419
|
# get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で検索し、要素を取得する)
|
|
@@ -424,8 +424,8 @@ module Meteor
|
|
|
424
424
|
# @param [String] attr_value2 attribute value2 (属性値2)
|
|
425
425
|
# @return [Meteor::Element] element (要素)
|
|
426
426
|
#
|
|
427
|
-
def
|
|
428
|
-
|
|
427
|
+
def element_four(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
428
|
+
quote_element_four(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
429
429
|
|
|
430
430
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s([^<>]*(' << @_attr_name1 << '="' << @_attr_value1
|
|
431
431
|
# @pattern_cc << '"[^<>]*' << @_attr_name2 << '="' << @_attr_value2
|
|
@@ -439,7 +439,7 @@ module Meteor
|
|
|
439
439
|
@res = @pattern.match(@root.document)
|
|
440
440
|
|
|
441
441
|
if @res
|
|
442
|
-
|
|
442
|
+
element_five(@res[1], attr_name1, attr_value1, attr_name2, attr_value2)
|
|
443
443
|
else
|
|
444
444
|
if @error_check
|
|
445
445
|
puts(
|
|
@@ -453,21 +453,21 @@ module Meteor
|
|
|
453
453
|
@elm_
|
|
454
454
|
end
|
|
455
455
|
|
|
456
|
-
private :
|
|
456
|
+
private :element_four
|
|
457
457
|
|
|
458
458
|
def edit_attrs_(elm, attr_name, attr_value)
|
|
459
459
|
if is_match('selected', attr_name) && is_match('option', elm.name)
|
|
460
|
-
|
|
460
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_selected_m, @@pattern_selected_r)
|
|
461
461
|
elsif is_match('multiple', attr_name) && is_match('select', elm.name)
|
|
462
|
-
|
|
462
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_multiple_m, @@pattern_multiple_r)
|
|
463
463
|
elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
|
|
464
|
-
|
|
464
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_disabled_m, @@pattern_disabled_r)
|
|
465
465
|
elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
|
|
466
|
-
|
|
466
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_checked_m, @@pattern_checked_r)
|
|
467
467
|
elsif is_match('readonly', attr_name) &&
|
|
468
468
|
(is_match('textarea',
|
|
469
469
|
elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
|
|
470
|
-
|
|
470
|
+
edit_attrs_five(elm, attr_name, attr_value, @@pattern_readonly_m, @@pattern_readonly_r)
|
|
471
471
|
else
|
|
472
472
|
super(elm, attr_name, attr_value)
|
|
473
473
|
end
|
|
@@ -475,7 +475,7 @@ module Meteor
|
|
|
475
475
|
|
|
476
476
|
private :edit_attrs_
|
|
477
477
|
|
|
478
|
-
def
|
|
478
|
+
def edit_attrs_five(elm, attr_name, attr_value, match_p, replace)
|
|
479
479
|
if true.equal?(attr_value) || is_match('true', attr_value)
|
|
480
480
|
@res = match_p.match(elm.attributes)
|
|
481
481
|
|
|
@@ -494,13 +494,13 @@ module Meteor
|
|
|
494
494
|
end
|
|
495
495
|
end
|
|
496
496
|
|
|
497
|
-
private :
|
|
497
|
+
private :edit_attrs_five
|
|
498
498
|
|
|
499
|
-
def
|
|
500
|
-
|
|
499
|
+
def edit_document_one(elm)
|
|
500
|
+
edit_document_two(elm, '>')
|
|
501
501
|
end
|
|
502
502
|
|
|
503
|
-
private :
|
|
503
|
+
private :edit_document_one
|
|
504
504
|
|
|
505
505
|
def get_attr_value_(elm, attr_name)
|
|
506
506
|
if is_match('selected', attr_name) && is_match('option', elm.name)
|
|
@@ -38,9 +38,9 @@ module Meteor
|
|
|
38
38
|
@doc_type = Parser::XHTML
|
|
39
39
|
case args.length
|
|
40
40
|
when ZERO
|
|
41
|
-
#
|
|
41
|
+
# initialize_zero
|
|
42
42
|
when ONE
|
|
43
|
-
|
|
43
|
+
initialize_one(args[0])
|
|
44
44
|
else
|
|
45
45
|
raise ArgumentError
|
|
46
46
|
end
|
|
@@ -49,16 +49,16 @@ module Meteor
|
|
|
49
49
|
#
|
|
50
50
|
# initializer (イニシャライザ)
|
|
51
51
|
#
|
|
52
|
-
# def
|
|
52
|
+
# def initialize_zero
|
|
53
53
|
# end
|
|
54
54
|
#
|
|
55
|
-
# private :
|
|
55
|
+
# private :initialize_zero
|
|
56
56
|
|
|
57
57
|
#
|
|
58
58
|
# initializer (イニシャライザ)
|
|
59
59
|
# @param [Meteor::Parser] ps parser (パーサ)
|
|
60
60
|
#
|
|
61
|
-
def
|
|
61
|
+
def initialize_one(ps)
|
|
62
62
|
@root.document = String.new(ps.document)
|
|
63
63
|
self.document_hook = String.new(ps.document_hook)
|
|
64
64
|
@root.content_type = String.new(ps.root_element.content_type)
|
|
@@ -66,7 +66,7 @@ module Meteor
|
|
|
66
66
|
@root.newline = ps.root_element.newline
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
private :
|
|
69
|
+
private :initialize_one
|
|
70
70
|
|
|
71
71
|
#
|
|
72
72
|
# analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
|
|
@@ -74,9 +74,9 @@ module Meteor
|
|
|
74
74
|
def analyze_content_type
|
|
75
75
|
@error_check = false
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
element_three('meta', 'charset', '[a-zA-Z-]+', false)
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
element_three('meta', 'charset', '[a-zA-Z-]+', false) unless @elm_
|
|
80
80
|
|
|
81
81
|
@error_check = true
|
|
82
82
|
|
|
@@ -94,19 +94,19 @@ module Meteor
|
|
|
94
94
|
|
|
95
95
|
def edit_attrs_(elm, attr_name, attr_value)
|
|
96
96
|
if is_match('selected', attr_name) && is_match('option', elm.name)
|
|
97
|
-
|
|
97
|
+
edit_attrs_five(elm, attr_value, @@pattern_selected_m, @@pattern_selected_r, SELECTED_U)
|
|
98
98
|
elsif is_match('multiple', attr_name) && is_match('select', elm.name)
|
|
99
|
-
|
|
99
|
+
edit_attrs_five(elm, attr_value, @@pattern_multiple_m, @@pattern_multiple_r, MULTIPLE_U)
|
|
100
100
|
elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
|
|
101
|
-
|
|
101
|
+
edit_attrs_five(elm, attr_value, @@pattern_disabled_m, @@pattern_disabled_r, DISABLED_U)
|
|
102
102
|
elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
|
|
103
|
-
|
|
103
|
+
edit_attrs_five(elm, attr_value, @@pattern_checked_m, @@pattern_checked_r, CHECKED_U)
|
|
104
104
|
elsif is_match('readonly', attr_name) &&
|
|
105
105
|
(is_match('textarea',
|
|
106
106
|
elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
|
|
107
|
-
|
|
107
|
+
edit_attrs_five(elm, attr_value, @@pattern_readonly_m, @@pattern_readonly_r, READONLY_U)
|
|
108
108
|
elsif is_match('required', attr_name) && is_match(REQUIRE_ELEMENT, elm.name)
|
|
109
|
-
|
|
109
|
+
edit_attrs_five(elm, attr_value, @@pattern_required_m, @@pattern_required_r, REQUIRED_U)
|
|
110
110
|
else
|
|
111
111
|
super(elm, attr_name, attr_value)
|
|
112
112
|
end
|