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
|
@@ -78,9 +78,9 @@ module Meteor
|
|
|
78
78
|
@doc_type = Parser::XHTML4
|
|
79
79
|
case args.length
|
|
80
80
|
when ZERO
|
|
81
|
-
#
|
|
81
|
+
# initialize_zero
|
|
82
82
|
when ONE
|
|
83
|
-
|
|
83
|
+
initialize_one(args[0])
|
|
84
84
|
else
|
|
85
85
|
raise ArgumentError
|
|
86
86
|
end
|
|
@@ -89,16 +89,16 @@ module Meteor
|
|
|
89
89
|
#
|
|
90
90
|
# initializer (イニシャライザ)
|
|
91
91
|
#
|
|
92
|
-
# def
|
|
92
|
+
# def initialize_zero
|
|
93
93
|
# end
|
|
94
94
|
#
|
|
95
|
-
# private :
|
|
95
|
+
# private :initialize_zero
|
|
96
96
|
|
|
97
97
|
#
|
|
98
98
|
# initializer (イニシャライザ)
|
|
99
99
|
# @param [Meteor::Parser] ps parser (パーサ)
|
|
100
100
|
#
|
|
101
|
-
def
|
|
101
|
+
def initialize_one(ps)
|
|
102
102
|
@root.document = String.new(ps.document)
|
|
103
103
|
self.document_hook = String.new(ps.document_hook)
|
|
104
104
|
@root.content_type = String.new(ps.root_element.content_type)
|
|
@@ -106,7 +106,7 @@ module Meteor
|
|
|
106
106
|
@root.newline = ps.root_element.newline
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
private :
|
|
109
|
+
private :initialize_one
|
|
110
110
|
|
|
111
111
|
#
|
|
112
112
|
# parse document (ドキュメントを解析する)
|
|
@@ -142,9 +142,9 @@ module Meteor
|
|
|
142
142
|
def analyze_content_type
|
|
143
143
|
@error_check = false
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
element_three('meta', 'http-equiv', 'Content-Type')
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
element_three('meta', 'http-equiv', 'Content-Type') unless @elm_
|
|
148
148
|
|
|
149
149
|
@error_check = true
|
|
150
150
|
|
|
@@ -173,17 +173,17 @@ module Meteor
|
|
|
173
173
|
|
|
174
174
|
def edit_attrs_(elm, attr_name, attr_value)
|
|
175
175
|
if is_match('selected', attr_name) && is_match('option', elm.name)
|
|
176
|
-
|
|
176
|
+
edit_attrs_five(elm, attr_value, @@pattern_selected_m, @@pattern_selected_r, SELECTED_U)
|
|
177
177
|
elsif is_match('multiple', attr_name) && is_match('select', elm.name)
|
|
178
|
-
|
|
178
|
+
edit_attrs_five(elm, attr_value, @@pattern_multiple_m, @@pattern_multiple_r, MULTIPLE_U)
|
|
179
179
|
elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
|
|
180
|
-
|
|
180
|
+
edit_attrs_five(elm, attr_value, @@pattern_disabled_m, @@pattern_disabled_r, DISABLED_U)
|
|
181
181
|
elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
|
|
182
|
-
|
|
182
|
+
edit_attrs_five(elm, attr_value, @@pattern_checked_m, @@pattern_checked_r, CHECKED_U)
|
|
183
183
|
elsif is_match('readonly', attr_name) &&
|
|
184
184
|
(is_match('textarea',
|
|
185
185
|
elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
|
|
186
|
-
|
|
186
|
+
edit_attrs_five(elm, attr_value, @@pattern_readonly_m, @@pattern_readonly_r, READONLY_U)
|
|
187
187
|
else
|
|
188
188
|
super(elm, attr_name, attr_value)
|
|
189
189
|
end
|
|
@@ -191,7 +191,7 @@ module Meteor
|
|
|
191
191
|
|
|
192
192
|
private :edit_attrs_
|
|
193
193
|
|
|
194
|
-
def
|
|
194
|
+
def edit_attrs_five(elm, attr_value, match_p, replace_regex, replace_update)
|
|
195
195
|
# attr_value = escape(attr_value)
|
|
196
196
|
|
|
197
197
|
if true.equal?(attr_value) || is_match('true', attr_value)
|
|
@@ -216,7 +216,7 @@ module Meteor
|
|
|
216
216
|
end
|
|
217
217
|
end
|
|
218
218
|
|
|
219
|
-
private :
|
|
219
|
+
private :edit_attrs_five
|
|
220
220
|
|
|
221
221
|
def get_attr_value_(elm, attr_name)
|
|
222
222
|
if is_match('selected', attr_name) && is_match('option', elm.name)
|
|
@@ -36,9 +36,9 @@ module Meteor
|
|
|
36
36
|
@doc_type = Parser::XML
|
|
37
37
|
case args.length
|
|
38
38
|
when ZERO
|
|
39
|
-
#
|
|
39
|
+
# initialize_zero
|
|
40
40
|
when ONE
|
|
41
|
-
|
|
41
|
+
initialize_one(args[0])
|
|
42
42
|
else
|
|
43
43
|
raise ArgumentError
|
|
44
44
|
end
|
|
@@ -47,23 +47,23 @@ module Meteor
|
|
|
47
47
|
#
|
|
48
48
|
# initializer (イニシャライザ)
|
|
49
49
|
#
|
|
50
|
-
# def
|
|
50
|
+
# def initialize_zero
|
|
51
51
|
# end
|
|
52
52
|
#
|
|
53
|
-
# private :
|
|
53
|
+
# private :initialize_zero
|
|
54
54
|
|
|
55
55
|
#
|
|
56
56
|
# initializer (イニシャライザ)
|
|
57
57
|
# @param [Meteor::Parser] ps parser (パーサ)
|
|
58
58
|
#
|
|
59
|
-
def
|
|
59
|
+
def initialize_one(ps)
|
|
60
60
|
@root.document = String.new(ps.document)
|
|
61
61
|
ps.document_hook = String.new(ps.document_hook)
|
|
62
62
|
@root.content_type = String.new(ps.root_element.content_type)
|
|
63
63
|
@root.newline = ps.root_element.newline
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
private :
|
|
66
|
+
private :initialize_one
|
|
67
67
|
|
|
68
68
|
#
|
|
69
69
|
# parse document (ドキュメントを解析する)
|
data/lib/meteor/parsers.rb
CHANGED
|
@@ -41,13 +41,13 @@ module Meteor
|
|
|
41
41
|
def initialize(*args)
|
|
42
42
|
case args.length
|
|
43
43
|
when 0
|
|
44
|
-
|
|
44
|
+
initialize_zero
|
|
45
45
|
when 1
|
|
46
|
-
|
|
46
|
+
initialize_one(args[0])
|
|
47
47
|
when 2
|
|
48
|
-
|
|
48
|
+
initialize_two(args[0], args[1])
|
|
49
49
|
when 3
|
|
50
|
-
|
|
50
|
+
initialize_three(args[0], args[1], args[2])
|
|
51
51
|
else
|
|
52
52
|
raise ArgumentError
|
|
53
53
|
end
|
|
@@ -56,34 +56,34 @@ module Meteor
|
|
|
56
56
|
#
|
|
57
57
|
# initializer (イニシャライザ)
|
|
58
58
|
#
|
|
59
|
-
def
|
|
60
|
-
|
|
59
|
+
def initialize_zero
|
|
60
|
+
initialize_two
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
private :
|
|
63
|
+
private :initialize_zero
|
|
64
64
|
|
|
65
65
|
#
|
|
66
66
|
# initializer (イニシャライザ)
|
|
67
67
|
# @param [String] root root directory (基準ディレクトリ)
|
|
68
68
|
#
|
|
69
|
-
def
|
|
70
|
-
|
|
69
|
+
def initialize_one(root)
|
|
70
|
+
initialize_two(root)
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
private :
|
|
73
|
+
private :initialize_one
|
|
74
74
|
|
|
75
75
|
#
|
|
76
76
|
# initializer (イニシャライザ)
|
|
77
77
|
# @param [String] root root directory (基準ディレクトリ)
|
|
78
78
|
# @param [String] enc default character encoding (デフォルト文字エンコーディング)
|
|
79
79
|
#
|
|
80
|
-
def
|
|
80
|
+
def initialize_two(root = '.', enc = 'UTF-8')
|
|
81
81
|
@cache = {}
|
|
82
82
|
@root = root
|
|
83
83
|
@enc = enc
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
private :
|
|
86
|
+
private :initialize_two
|
|
87
87
|
|
|
88
88
|
#
|
|
89
89
|
# initializer (イニシャライザ)
|
|
@@ -91,14 +91,14 @@ module Meteor
|
|
|
91
91
|
# @param [String] root root directory (基準ディレクトリ)
|
|
92
92
|
# @param [String] enc default character encoding (デフォルト文字エンコーディング)
|
|
93
93
|
#
|
|
94
|
-
def
|
|
94
|
+
def initialize_three(type, root = '.', enc = 'UTF-8')
|
|
95
95
|
@cache = {}
|
|
96
96
|
@type = type
|
|
97
97
|
@root = root
|
|
98
98
|
@enc = enc
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
private :
|
|
101
|
+
private :initialize_three
|
|
102
102
|
|
|
103
103
|
#
|
|
104
104
|
# set options (オプションをセットする)
|
|
@@ -157,17 +157,17 @@ module Meteor
|
|
|
157
157
|
def add(*args)
|
|
158
158
|
case args.length
|
|
159
159
|
when 1
|
|
160
|
-
|
|
160
|
+
add_file_one(args[0])
|
|
161
161
|
when 2
|
|
162
162
|
if args[0].is_a?(Integer) || args[0].is_a?(Symbol)
|
|
163
|
-
|
|
163
|
+
add_file_two_n(args[0], args[1])
|
|
164
164
|
elsif args[0].is_a?(String)
|
|
165
|
-
|
|
165
|
+
add_file_two_s(args[0], args[1])
|
|
166
166
|
else
|
|
167
167
|
raise ArgumentError
|
|
168
168
|
end
|
|
169
169
|
when 3
|
|
170
|
-
|
|
170
|
+
add_file_three(args[0], args[1], args[2])
|
|
171
171
|
else
|
|
172
172
|
raise ArgumentError
|
|
173
173
|
end
|
|
@@ -204,14 +204,14 @@ module Meteor
|
|
|
204
204
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
205
205
|
# @return [Meteor::Parser] parser(パーサ)
|
|
206
206
|
#
|
|
207
|
-
def
|
|
207
|
+
def add_file_three(type, relative_path, enc = 'UTF-8')
|
|
208
208
|
relative_url = path_to_url(relative_path)
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
add_template_three(type, relative_url,
|
|
211
|
+
Meteor::Core::Util::FileReader.read(File.expand_path(relative_path, @root), enc))
|
|
212
212
|
end
|
|
213
213
|
|
|
214
|
-
private :
|
|
214
|
+
private :add_file_three
|
|
215
215
|
|
|
216
216
|
#
|
|
217
217
|
# add parser (パーサを追加する)
|
|
@@ -219,11 +219,11 @@ module Meteor
|
|
|
219
219
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
220
220
|
# @return [Meteor::Parser] parser (パーサ)
|
|
221
221
|
#
|
|
222
|
-
def
|
|
223
|
-
|
|
222
|
+
def add_file_two_n(type, relative_path)
|
|
223
|
+
add_file_three(type, relative_path, @enc)
|
|
224
224
|
end
|
|
225
225
|
|
|
226
|
-
private :
|
|
226
|
+
private :add_file_two_n
|
|
227
227
|
|
|
228
228
|
#
|
|
229
229
|
# add parser (パーサを追加する)
|
|
@@ -231,22 +231,22 @@ module Meteor
|
|
|
231
231
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
232
232
|
# @return [Meteor::Parser] parser (パーサ)
|
|
233
233
|
#
|
|
234
|
-
def
|
|
235
|
-
|
|
234
|
+
def add_file_two_s(relative_path, enc)
|
|
235
|
+
add_file_three(@type, relative_path, enc)
|
|
236
236
|
end
|
|
237
237
|
|
|
238
|
-
private :
|
|
238
|
+
private :add_file_two_s
|
|
239
239
|
|
|
240
240
|
#
|
|
241
241
|
# add parser (パーサを追加する)
|
|
242
242
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
243
243
|
# @return [Meteor::Parser] parser (パーサ)
|
|
244
244
|
#
|
|
245
|
-
def
|
|
246
|
-
|
|
245
|
+
def add_file_one(relative_path)
|
|
246
|
+
add_file_three(@type, relative_path, @enc)
|
|
247
247
|
end
|
|
248
248
|
|
|
249
|
-
private :
|
|
249
|
+
private :add_file_one
|
|
250
250
|
|
|
251
251
|
#
|
|
252
252
|
# @overload add_template(type, relative_url, doc)
|
|
@@ -264,9 +264,9 @@ module Meteor
|
|
|
264
264
|
def add_template(*args)
|
|
265
265
|
case args.length
|
|
266
266
|
when 2
|
|
267
|
-
|
|
267
|
+
add_template_two(args[0], args[1])
|
|
268
268
|
when 3
|
|
269
|
-
|
|
269
|
+
add_template_three(args[0], args[1], args[2])
|
|
270
270
|
else
|
|
271
271
|
raise ArgumentError
|
|
272
272
|
end
|
|
@@ -279,14 +279,14 @@ module Meteor
|
|
|
279
279
|
# @param [String] doc document (ドキュメント)
|
|
280
280
|
# @return [Meteor::Parser] parser (パーサ)
|
|
281
281
|
#
|
|
282
|
-
def
|
|
282
|
+
def add_template_three(type, relative_url, doc)
|
|
283
283
|
ps = new_parser(type)
|
|
284
284
|
ps.document = doc
|
|
285
285
|
|
|
286
286
|
@cache[relative_url] = ps
|
|
287
287
|
end
|
|
288
288
|
|
|
289
|
-
private :
|
|
289
|
+
private :add_template_three
|
|
290
290
|
|
|
291
291
|
#
|
|
292
292
|
# add parser (パーサを追加する)
|
|
@@ -294,11 +294,11 @@ module Meteor
|
|
|
294
294
|
# @param [String] doc document (ドキュメント)
|
|
295
295
|
# @return [Meteor::Parser] parser (パーサ)
|
|
296
296
|
#
|
|
297
|
-
def
|
|
298
|
-
|
|
297
|
+
def add_template_two(relative_url, doc)
|
|
298
|
+
add_template_three(@type, relative_url, doc)
|
|
299
299
|
end
|
|
300
300
|
|
|
301
|
-
private :
|
|
301
|
+
private :add_template_two
|
|
302
302
|
|
|
303
303
|
alias link_str add_template
|
|
304
304
|
alias add_str add_template
|
|
@@ -325,11 +325,11 @@ module Meteor
|
|
|
325
325
|
def parser(*args)
|
|
326
326
|
case args.length
|
|
327
327
|
when 1
|
|
328
|
-
|
|
328
|
+
parser_one(args[0])
|
|
329
329
|
when 2, 3
|
|
330
330
|
add(args)
|
|
331
331
|
end
|
|
332
|
-
#
|
|
332
|
+
# parser_one(key)
|
|
333
333
|
end
|
|
334
334
|
|
|
335
335
|
#
|
|
@@ -337,7 +337,7 @@ module Meteor
|
|
|
337
337
|
# @param [String] key identifier (キー)
|
|
338
338
|
# @return [Meteor::Parser] parser (パーサ)
|
|
339
339
|
#
|
|
340
|
-
def
|
|
340
|
+
def parser_one(key)
|
|
341
341
|
@pif = @cache[key.to_s]
|
|
342
342
|
case @pif.doc_type
|
|
343
343
|
when Meteor::Parser::HTML
|
|
@@ -353,7 +353,7 @@ module Meteor
|
|
|
353
353
|
end
|
|
354
354
|
end
|
|
355
355
|
|
|
356
|
-
private :
|
|
356
|
+
private :parser_one
|
|
357
357
|
|
|
358
358
|
#
|
|
359
359
|
# get root element (ルート要素を取得する)
|
|
@@ -361,7 +361,7 @@ module Meteor
|
|
|
361
361
|
# @return [Meteor::RootElement] root element (ルート要素)
|
|
362
362
|
#
|
|
363
363
|
def element(key)
|
|
364
|
-
|
|
364
|
+
parser_one(key).root_element
|
|
365
365
|
end
|
|
366
366
|
|
|
367
367
|
def new_parser(type)
|
data/lib/meteor.rb
CHANGED
|
@@ -37,11 +37,11 @@ require 'meteor/ml/xml/parser_impl'
|
|
|
37
37
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
38
38
|
#
|
|
39
39
|
# @author Yasumasa Ashida
|
|
40
|
-
# @version 0.9.
|
|
40
|
+
# @version 0.9.32
|
|
41
41
|
#
|
|
42
42
|
|
|
43
43
|
module Meteor
|
|
44
|
-
VERSION = '0.9.
|
|
44
|
+
VERSION = '0.9.32'
|
|
45
45
|
|
|
46
46
|
# require 'fileutils'
|
|
47
47
|
|