meteor 0.9.42 → 0.9.43
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 +6 -0
- data/Gemfile.lock +1 -1
- data/demo/xml.rb +2 -2
- data/lib/meteor/core/kernel.rb +34 -6
- data/lib/meteor/element.rb +5 -4
- data/lib/meteor/ml/html4/parser_impl.rb +2 -26
- data/lib/meteor/ml/xhtml4/parser_impl.rb +1 -23
- data/lib/meteor/ml/xml/parser_impl.rb +1 -25
- data/lib/meteor.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 825640494e7fedc75191acae932e5a48c480a8dfe487bbd5d1f5784e8a5695b5
|
|
4
|
+
data.tar.gz: b7a2cdbd87bcb11466f644e5f31e9f36b9ccaefec561c15bf69d0c8a25b61f69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb63be5f0155775ad90edf407d09aa637fa0557d62a41d3a386acfb337500e7dc1a4dde101c193941c205f070ff17f95a04d2f1cf95579e948f25d6315e115ba
|
|
7
|
+
data.tar.gz: '068c2caec3f5b93a71a773b9eb674f809d31709dd638dce51d01b8a1e96743f2a743d8d300fd7a111c585e71654eb1328964ad458b124d49816fb5a5de053557'
|
data/ChangeLog
CHANGED
data/Gemfile.lock
CHANGED
data/demo/xml.rb
CHANGED
|
@@ -32,7 +32,7 @@ elm7 = root.element('kobe')
|
|
|
32
32
|
# elm8 = root.element(manbo: "mango")
|
|
33
33
|
# elm8 = root.element(momo: "momo")
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
elm9 = root.element('hamachi', id: 'aa', id2: 'bb')
|
|
36
36
|
# elm_c1 = root.cxtag("cs")
|
|
37
37
|
|
|
38
38
|
# puts elm8.name
|
|
@@ -43,7 +43,7 @@ elm7 = root.element('kobe')
|
|
|
43
43
|
# elm1["id2"] = "cc"
|
|
44
44
|
|
|
45
45
|
# elm8['mango'] = "mangoo" # elm8.attr(manbo: "mangoo")
|
|
46
|
-
|
|
46
|
+
elm9.content = '\\1' # elm9.content("\\1")
|
|
47
47
|
|
|
48
48
|
# elm2.attr(id3: 'cc')
|
|
49
49
|
|
data/lib/meteor/core/kernel.rb
CHANGED
|
@@ -50,6 +50,9 @@ module Meteor
|
|
|
50
50
|
RE_CLEAN_ONE = Regexp.new('<!--\\s@[^<>]*\\s[^<>]*(\\s)*-->')
|
|
51
51
|
RE_CLEAN_TWO = Regexp.new('<!--\\s\\/@[^<>]*(\\s)*-->')
|
|
52
52
|
|
|
53
|
+
# NEWLINE = "\r?\n|\r"
|
|
54
|
+
NEWLINE = ["\r\n", "\n", "\r"].freeze
|
|
55
|
+
|
|
53
56
|
BR = '<br>'
|
|
54
57
|
BR_RE = BR
|
|
55
58
|
|
|
@@ -170,10 +173,32 @@ module Meteor
|
|
|
170
173
|
# parse document (ドキュメントを解析する)
|
|
171
174
|
# @param [String] document document (ドキュメント)
|
|
172
175
|
#
|
|
173
|
-
def parse
|
|
176
|
+
def parse
|
|
177
|
+
analyze_ml
|
|
178
|
+
end
|
|
174
179
|
|
|
175
180
|
protected :parse
|
|
176
181
|
|
|
182
|
+
#
|
|
183
|
+
# analyze document (ドキュメントをパースする)
|
|
184
|
+
#
|
|
185
|
+
def analyze_ml
|
|
186
|
+
analyze_newline
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
protected :analyze_ml
|
|
190
|
+
|
|
191
|
+
#
|
|
192
|
+
# analyze document , set newline (ドキュメントをパースし、改行コードをセットする)
|
|
193
|
+
#
|
|
194
|
+
def analyze_newline
|
|
195
|
+
NEWLINE.each do |a|
|
|
196
|
+
@root.newline = a if @root.document.include?(a)
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
private :analyze_newline
|
|
201
|
+
|
|
177
202
|
#
|
|
178
203
|
# get element (要素を取得する)
|
|
179
204
|
# @overload element(name)
|
|
@@ -669,7 +694,7 @@ module Meteor
|
|
|
669
694
|
# case @res.captures.length
|
|
670
695
|
# when FOUR
|
|
671
696
|
# @_name = @res[1]
|
|
672
|
-
# #
|
|
697
|
+
# # element (要素)
|
|
673
698
|
# @elm_ = Element.new(@_name)
|
|
674
699
|
# # attribute (属性)
|
|
675
700
|
# @elm_.attributes = @res[2]
|
|
@@ -854,10 +879,14 @@ module Meteor
|
|
|
854
879
|
private :quote_element_five
|
|
855
880
|
|
|
856
881
|
def element_normal_five_one(name) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
882
|
+
# @res.to_a.each_with_index do |capture, i|
|
|
883
|
+
# puts i
|
|
884
|
+
# puts capture
|
|
885
|
+
# end
|
|
857
886
|
# puts @res.captures.length
|
|
858
887
|
case @res.captures.length
|
|
859
888
|
when FOUR
|
|
860
|
-
#
|
|
889
|
+
# element (要素)
|
|
861
890
|
@elm_ = Meteor::Element.new(name)
|
|
862
891
|
# attribute (属性)
|
|
863
892
|
@elm_.attributes = @res[1]
|
|
@@ -966,7 +995,7 @@ module Meteor
|
|
|
966
995
|
# document (全体)
|
|
967
996
|
@elm_.document = @res[0]
|
|
968
997
|
# pattern (空要素検索用パターン)
|
|
969
|
-
@pattern_cc = "<#{@_name}(\\s[^<>]*(
|
|
998
|
+
@pattern_cc = "<#{@_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}#{closer}" # rubocop:disable Layout/LineLength
|
|
970
999
|
@elm_.pattern = @pattern_cc
|
|
971
1000
|
@elm_.parser = self
|
|
972
1001
|
|
|
@@ -1019,7 +1048,7 @@ module Meteor
|
|
|
1019
1048
|
private :quote_element_four
|
|
1020
1049
|
|
|
1021
1050
|
def element_pattern_four
|
|
1022
|
-
@pattern_cc = "<([^<>\"]*)\\s[^<>]*(
|
|
1051
|
+
@pattern_cc = "<([^<>\"]*)\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")" # rubocop:disable Layout/LineLength
|
|
1023
1052
|
end
|
|
1024
1053
|
|
|
1025
1054
|
private :element_pattern_four
|
|
@@ -1283,7 +1312,6 @@ module Meteor
|
|
|
1283
1312
|
else
|
|
1284
1313
|
element_void_one(@elm_.name)
|
|
1285
1314
|
end
|
|
1286
|
-
|
|
1287
1315
|
when TWO, THREE
|
|
1288
1316
|
if @elm_.normal
|
|
1289
1317
|
element_normal_three_one(@elm_.name)
|
data/lib/meteor/element.rb
CHANGED
|
@@ -219,21 +219,22 @@ module Meteor
|
|
|
219
219
|
def document # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
220
220
|
if @document_sync
|
|
221
221
|
@document_sync = false
|
|
222
|
+
@_mixed_content = @mixed_content ? Regexp.quote(@mixed_content) : ''
|
|
222
223
|
case @parser.doc_type
|
|
223
224
|
when Parser::HTML, Parser::HTML4
|
|
224
225
|
@document = if @cx
|
|
225
|
-
"<!-- @#{@name} #{@attributes} -->#{@
|
|
226
|
+
"<!-- @#{@name} #{@attributes} -->#{@_mixed_content}<!-- /@#{@name} -->"
|
|
226
227
|
elsif @normal
|
|
227
|
-
"<#{@name}#{@attributes}>#{@
|
|
228
|
+
"<#{@name}#{@attributes}>#{@_mixed_content}</#{@name}>"
|
|
228
229
|
else
|
|
229
230
|
String.new('') << '<' << @name << @attributes << '>'
|
|
230
231
|
# @document = "<#{@name}#{@attributes}>"
|
|
231
232
|
end
|
|
232
233
|
when Parser::XHTML, Parser::XHTML4, Parser::XML
|
|
233
234
|
@document = if @cx
|
|
234
|
-
"<!-- @#{@name} #{@attributes} -->#{@
|
|
235
|
+
"<!-- @#{@name} #{@attributes} -->#{@_mixed_content}<!-- /@#{@name} -->"
|
|
235
236
|
elsif @normal
|
|
236
|
-
"<#{@name}#{@attributes}>#{@
|
|
237
|
+
"<#{@name}#{@attributes}>#{@_mixed_content}</#{@name}>"
|
|
237
238
|
else
|
|
238
239
|
String.new('') << '<' << @name << @attributes << '/>'
|
|
239
240
|
# "<#{@name}#{@attributes}/>"
|
|
@@ -8,9 +8,6 @@ module Meteor
|
|
|
8
8
|
# HTML4 parser (HTMLパーサ)
|
|
9
9
|
#
|
|
10
10
|
class ParserImpl < Meteor::Core::Kernel # rubocop:disable Metrics/ClassLength
|
|
11
|
-
# NEWLINE = "\r?\n|\r"
|
|
12
|
-
# NEWLINE = "\r\n|\n|\r"
|
|
13
|
-
NEWLINE = ["\r\n", "\n", "\r"].freeze
|
|
14
11
|
BR = '<br>'
|
|
15
12
|
BR_RE = BR
|
|
16
13
|
|
|
@@ -117,22 +114,12 @@ module Meteor
|
|
|
117
114
|
|
|
118
115
|
private :initialize_one
|
|
119
116
|
|
|
120
|
-
#
|
|
121
|
-
# parse document (ドキュメントを解析する)
|
|
122
|
-
#
|
|
123
|
-
def parse
|
|
124
|
-
analyze_ml
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
protected :parse
|
|
128
|
-
|
|
129
117
|
#
|
|
130
118
|
# analyze document (ドキュメントをパースする)
|
|
131
119
|
#
|
|
132
120
|
def analyze_ml
|
|
121
|
+
super
|
|
133
122
|
analyze_content_type
|
|
134
|
-
analyze_newline
|
|
135
|
-
|
|
136
123
|
@res = nil
|
|
137
124
|
end
|
|
138
125
|
|
|
@@ -168,17 +155,6 @@ module Meteor
|
|
|
168
155
|
|
|
169
156
|
protected :analyze_content_type
|
|
170
157
|
|
|
171
|
-
#
|
|
172
|
-
# analuze document , set newline (ドキュメントをパースし、改行コードをセットする)
|
|
173
|
-
#
|
|
174
|
-
def analyze_newline
|
|
175
|
-
NEWLINE.each do |a|
|
|
176
|
-
@root.newline = a if @root.document.include?(a)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
protected :analyze_newline
|
|
181
|
-
|
|
182
158
|
#
|
|
183
159
|
# get element using tag name (要素のタグ名で検索し、要素を取得する)
|
|
184
160
|
# @param [String] name tag name (タグ名)
|
|
@@ -407,7 +383,7 @@ module Meteor
|
|
|
407
383
|
def element_four(attr_name1, attr_value1, attr_name2, attr_value2) # rubocop:disable Metrics/MethodLength
|
|
408
384
|
quote_element_four(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
409
385
|
|
|
410
|
-
@pattern_cc = "<([^<>\"]*)\\s([^<>]*(
|
|
386
|
+
@pattern_cc = "<([^<>\"]*)\\s([^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>" # rubocop:disable Layout/LineLength
|
|
411
387
|
|
|
412
388
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
|
413
389
|
|
|
@@ -8,8 +8,6 @@ module Meteor
|
|
|
8
8
|
# XHTML4 parser (XHTML4パーサ)
|
|
9
9
|
#
|
|
10
10
|
class ParserImpl < Meteor::Core::Kernel # rubocop:disable Metrics/ClassLength
|
|
11
|
-
# NEWLINE = "\r?\n|\r"
|
|
12
|
-
NEWLINE = ["\r\n", "\n", "\r"].freeze
|
|
13
11
|
BR = '<br/>'
|
|
14
12
|
BR_RE = '<br\\/>'
|
|
15
13
|
|
|
@@ -108,21 +106,12 @@ module Meteor
|
|
|
108
106
|
|
|
109
107
|
private :initialize_one
|
|
110
108
|
|
|
111
|
-
#
|
|
112
|
-
# parse document (ドキュメントを解析する)
|
|
113
|
-
#
|
|
114
|
-
def parse
|
|
115
|
-
analyze_ml
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
protected :parse
|
|
119
|
-
|
|
120
109
|
#
|
|
121
110
|
# analyze document (ドキュメントをパースする)
|
|
122
111
|
#
|
|
123
112
|
def analyze_ml
|
|
113
|
+
super
|
|
124
114
|
analyze_content_type
|
|
125
|
-
analyze_newline
|
|
126
115
|
@res = nil
|
|
127
116
|
end
|
|
128
117
|
|
|
@@ -160,17 +149,6 @@ module Meteor
|
|
|
160
149
|
|
|
161
150
|
private :analyze_content_type
|
|
162
151
|
|
|
163
|
-
#
|
|
164
|
-
# analyze document , set newline (ドキュメントをパースし、改行コードをセットする)
|
|
165
|
-
#
|
|
166
|
-
def analyze_newline
|
|
167
|
-
NEWLINE.each do |a|
|
|
168
|
-
@root.newline = a if @root.document.include?(a)
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
private :analyze_newline
|
|
173
|
-
|
|
174
152
|
def edit_attrs_(elm, attr_name, attr_value) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
175
153
|
if match?('selected', attr_name) && match?('option', elm.name)
|
|
176
154
|
edit_attrs_five(elm, attr_value, RE_SELECTED_M, RE_SELECTED_R, SELECTED_U)
|
|
@@ -8,9 +8,6 @@ module Meteor
|
|
|
8
8
|
# XML parser (XMLパーサ)
|
|
9
9
|
#
|
|
10
10
|
class ParserImpl < Meteor::Core::Kernel
|
|
11
|
-
# NEWLINE = "\r?\n|\r"
|
|
12
|
-
NEWLINE = ["\r\n", "\n", "\r"].freeze
|
|
13
|
-
|
|
14
11
|
TABLE_FOR_ESCAPE_ = {
|
|
15
12
|
'&' => '&',
|
|
16
13
|
'"' => '"',
|
|
@@ -66,22 +63,12 @@ module Meteor
|
|
|
66
63
|
|
|
67
64
|
private :initialize_one
|
|
68
65
|
|
|
69
|
-
#
|
|
70
|
-
# parse document (ドキュメントを解析する)
|
|
71
|
-
#
|
|
72
|
-
def parse
|
|
73
|
-
analyze_ml
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
protected :parse
|
|
77
|
-
|
|
78
66
|
#
|
|
79
67
|
# analyze document (ドキュメントをパースする)
|
|
80
68
|
#
|
|
81
69
|
def analyze_ml
|
|
82
|
-
|
|
70
|
+
super
|
|
83
71
|
analyze_content_type
|
|
84
|
-
|
|
85
72
|
@res = nil
|
|
86
73
|
end
|
|
87
74
|
|
|
@@ -95,17 +82,6 @@ module Meteor
|
|
|
95
82
|
@root.content_type
|
|
96
83
|
end
|
|
97
84
|
|
|
98
|
-
#
|
|
99
|
-
# analuze document , set newline (ドキュメントをパースし、改行コードをセットする)
|
|
100
|
-
#
|
|
101
|
-
def analyze_newline
|
|
102
|
-
NEWLINE.each do |a|
|
|
103
|
-
@root.newline = a if @root.document.include?(a)
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
private :analyze_newline
|
|
108
|
-
|
|
109
85
|
#
|
|
110
86
|
# analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
|
|
111
87
|
#
|
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.43
|
|
41
41
|
#
|
|
42
42
|
|
|
43
43
|
module Meteor
|
|
44
|
-
VERSION = '0.9.
|
|
44
|
+
VERSION = '0.9.43'
|
|
45
45
|
|
|
46
46
|
# require 'fileutils'
|
|
47
47
|
|