meteor 0.9.41 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46eb97e00adae645d7675426b601a1f1d90ef372aad0c4106d169b86bbb72b46
4
- data.tar.gz: efa01e2a273c17a070986389581b032cbfc1cd64e47164cf247f675fcdde5554
3
+ metadata.gz: 825640494e7fedc75191acae932e5a48c480a8dfe487bbd5d1f5784e8a5695b5
4
+ data.tar.gz: b7a2cdbd87bcb11466f644e5f31e9f36b9ccaefec561c15bf69d0c8a25b61f69
5
5
  SHA512:
6
- metadata.gz: d7d915e4808fe38ce59fb1d127b534cb18a2c1c627742031185bb20f6ba32aeb67dec856dfdb042854ce9a0b6775111191ea2c031463a2cf8c7f75f2cf6a3de9
7
- data.tar.gz: 9a030a41653d7c0c69ad35c37355ef8acfdd406f7679e36c7fcf7d039326c21b32e86ed9ed173b588d37c430e776c9647c0aff253361ce97344f17b128da65bd
6
+ metadata.gz: cb63be5f0155775ad90edf407d09aa637fa0557d62a41d3a386acfb337500e7dc1a4dde101c193941c205f070ff17f95a04d2f1cf95579e948f25d6315e115ba
7
+ data.tar.gz: '068c2caec3f5b93a71a773b9eb674f809d31709dd638dce51d01b8a1e96743f2a743d8d300fd7a111c585e71654eb1328964ad458b124d49816fb5a5de053557'
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.9.43 / 2026-07-22 Yasumasa Ashida <ys.ashida@gmail.com>
2
+
3
+ * Refactor Meteor::Core::Kernel
4
+ * Fix Meteor::Element#document
5
+ * Refactor Meteor::Element#element
6
+
7
+ == 0.9.42 / 2026-07-21 Yasumasa Ashida <ys.ashida@gmail.com>
8
+
9
+ * Refactor Meteor::Element
10
+
1
11
  == 0.9.41 / 2026-07-14 Yasumasa Ashida <ys.ashida@gmail.com>
2
12
 
3
13
  * Remove unnecessary comments
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- meteor (0.9.41)
4
+ meteor (0.9.43)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- # elm9 = root.element("hamachi",id: "aa",id2: 'bb')
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
- # elm9.content = "\\1" # elm9.content("\\1")
46
+ elm9.content = '\\1' # elm9.content("\\1")
47
47
 
48
48
  # elm2.attr(id3: 'cc')
49
49
 
@@ -45,13 +45,14 @@ module Meteor
45
45
  RE_FIND_FOUR = Regexp.new(PATTERN_FIND_FOUR)
46
46
  RE_FIND_FIVE = Regexp.new(PATTERN_FIND_FIVE)
47
47
 
48
- RE_CHILDLESS = Regexp.new('\\A[^<>]*\\Z')
49
-
50
48
  RE_GET_ATTRS_MAP = Regexp.new('([^\\s]*)="([^\"]*)"')
51
49
 
52
50
  RE_CLEAN_ONE = Regexp.new('<!--\\s@[^<>]*\\s[^<>]*(\\s)*-->')
53
51
  RE_CLEAN_TWO = Regexp.new('<!--\\s\\/@[^<>]*(\\s)*-->')
54
52
 
53
+ # NEWLINE = "\r?\n|\r"
54
+ NEWLINE = ["\r\n", "\n", "\r"].freeze
55
+
55
56
  BR = '<br>'
56
57
  BR_RE = BR
57
58
 
@@ -172,10 +173,32 @@ module Meteor
172
173
  # parse document (ドキュメントを解析する)
173
174
  # @param [String] document document (ドキュメント)
174
175
  #
175
- def parse; end
176
+ def parse
177
+ analyze_ml
178
+ end
176
179
 
177
180
  protected :parse
178
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
+
179
202
  #
180
203
  # get element (要素を取得する)
181
204
  # @overload element(name)
@@ -671,7 +694,7 @@ module Meteor
671
694
  # case @res.captures.length
672
695
  # when FOUR
673
696
  # @_name = @res[1]
674
- # # eleement (要素)
697
+ # # element (要素)
675
698
  # @elm_ = Element.new(@_name)
676
699
  # # attribute (属性)
677
700
  # @elm_.attributes = @res[2]
@@ -856,10 +879,14 @@ module Meteor
856
879
  private :quote_element_five
857
880
 
858
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
859
886
  # puts @res.captures.length
860
887
  case @res.captures.length
861
888
  when FOUR
862
- # eleemnt (要素)
889
+ # element (要素)
863
890
  @elm_ = Meteor::Element.new(name)
864
891
  # attribute (属性)
865
892
  @elm_.attributes = @res[1]
@@ -968,7 +995,7 @@ module Meteor
968
995
  # document (全体)
969
996
  @elm_.document = @res[0]
970
997
  # pattern (空要素検索用パターン)
971
- @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
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
972
999
  @elm_.pattern = @pattern_cc
973
1000
  @elm_.parser = self
974
1001
 
@@ -1021,7 +1048,7 @@ module Meteor
1021
1048
  private :quote_element_four
1022
1049
 
1023
1050
  def element_pattern_four
1024
- @pattern_cc = "<([^<>\"]*)\\s[^<>]*(#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")" # rubocop:disable Layout/LineLength
1051
+ @pattern_cc = "<([^<>\"]*)\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")" # rubocop:disable Layout/LineLength
1025
1052
  end
1026
1053
 
1027
1054
  private :element_pattern_four
@@ -1285,7 +1312,6 @@ module Meteor
1285
1312
  else
1286
1313
  element_void_one(@elm_.name)
1287
1314
  end
1288
-
1289
1315
  when TWO, THREE
1290
1316
  if @elm_.normal
1291
1317
  element_normal_three_one(@elm_.name)
@@ -1947,12 +1973,9 @@ module Meteor
1947
1973
  # @param [Meteor::Element] elm element (要素)
1948
1974
  # @return [Meteor::Element] element (要素)
1949
1975
  #
1950
- def shadow(elm) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
1976
+ def shadow(elm) # rubocop:disable Metrics/AbcSize
1951
1977
  return unless elm.normal
1952
1978
 
1953
- # case of normal element (内容あり要素の場合)
1954
- self.childless = elm
1955
-
1956
1979
  pif2 = self.class.new(self)
1957
1980
 
1958
1981
  @elm_ = elm.clone(pif2)
@@ -1970,14 +1993,6 @@ module Meteor
1970
1993
 
1971
1994
  # private :shadow
1972
1995
 
1973
- def childless=(elm)
1974
- @res = RE_CHILDLESS.match(elm.mixed_content)
1975
-
1976
- elm.childless = true if @res
1977
- end
1978
-
1979
- private :childless=
1980
-
1981
1996
  def match?(regex, str)
1982
1997
  case regex
1983
1998
  when Regexp
@@ -21,8 +21,6 @@ module Meteor
21
21
  # @return [true,false] content normal flag (内容存在フラグ)
22
22
  # @!attribute [rw] cx
23
23
  # @return [true,false] comment extension tag flag (コメント拡張タグフラグ)
24
- # @!attribute [rw] childless
25
- # @return [true,false] child childless flag (子要素なしフラグ)
26
24
  # @!attribute [rw] parser
27
25
  # @return [Meteor::Parser] parser(パーサ)
28
26
  # @!attribute [rw] type_value
@@ -37,7 +35,7 @@ module Meteor
37
35
  # @return [true,false] deletion flag (削除フラグ)
38
36
  #
39
37
  class Element # rubocop:disable Metrics/ClassLength
40
- attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :childless,
38
+ attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx,
41
39
  :parser, :type_value, :usable, :origin, :copy, :removed
42
40
 
43
41
  alias tag name
@@ -46,8 +44,7 @@ module Meteor
46
44
  alias empty normal
47
45
  alias empty= normal=
48
46
 
49
- alias mono childless
50
- alias mono= childless=
47
+ RE_CHILDLESS = Regexp.new('\\A[^<>]*\\Z')
51
48
 
52
49
  #
53
50
  # initializer (イニシャライザ)
@@ -90,7 +87,6 @@ module Meteor
90
87
  # @parser=nil
91
88
  # @normal = false
92
89
  # @cx = false
93
- # @childless = false
94
90
  # @parent = false
95
91
  @usable = true
96
92
  end
@@ -108,7 +104,7 @@ module Meteor
108
104
 
109
105
  private :initialize_e
110
106
 
111
- def initialize_two(elm, ps) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Naming/MethodParameterName
107
+ def initialize_two(elm, ps) # rubocop:disable Metrics/MethodLength,Naming/MethodParameterName
112
108
  @parser = ps
113
109
  if normal
114
110
  ps.element(elm)
@@ -121,7 +117,6 @@ module Meteor
121
117
  @document = String.new(elm.document)
122
118
  @normal = elm.normal
123
119
  @cx = elm.cx
124
- @childless = elm.childless
125
120
  @origin = elm
126
121
  # @usable = false
127
122
  elm.copy = self
@@ -189,6 +184,25 @@ module Meteor
189
184
 
190
185
  private :clone_one
191
186
 
187
+ #
188
+ # get childless flag (子要素なしフラグを取得する)
189
+ # @return [true,false] childless flag (子要素なしフラグ)
190
+ #
191
+ def childless
192
+ if @childless.nil?
193
+ @res = RE_CHILDLESS.match(mixed_content)
194
+
195
+ @childless = if @res
196
+ true
197
+ else
198
+ false
199
+ end
200
+ end
201
+ @childless
202
+ end
203
+
204
+ alias mono childless
205
+
192
206
  #
193
207
  # set document (ドキュメントをセットする)
194
208
  # @param [String] doc document (ドキュメント)
@@ -205,21 +219,22 @@ module Meteor
205
219
  def document # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
206
220
  if @document_sync
207
221
  @document_sync = false
222
+ @_mixed_content = @mixed_content ? Regexp.quote(@mixed_content) : ''
208
223
  case @parser.doc_type
209
224
  when Parser::HTML, Parser::HTML4
210
225
  @document = if @cx
211
- "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->"
226
+ "<!-- @#{@name} #{@attributes} -->#{@_mixed_content}<!-- /@#{@name} -->"
212
227
  elsif @normal
213
- "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>"
228
+ "<#{@name}#{@attributes}>#{@_mixed_content}</#{@name}>"
214
229
  else
215
230
  String.new('') << '<' << @name << @attributes << '>'
216
231
  # @document = "<#{@name}#{@attributes}>"
217
232
  end
218
233
  when Parser::XHTML, Parser::XHTML4, Parser::XML
219
234
  @document = if @cx
220
- "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->"
235
+ "<!-- @#{@name} #{@attributes} -->#{@_mixed_content}<!-- /@#{@name} -->"
221
236
  elsif @normal
222
- "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>"
237
+ "<#{@name}#{@attributes}>#{@_mixed_content}</#{@name}>"
223
238
  else
224
239
  String.new('') << '<' << @name << @attributes << '/>'
225
240
  # "<#{@name}#{@attributes}/>"
@@ -77,7 +77,7 @@ module Meteor
77
77
  end
78
78
 
79
79
  #
80
- # Elements Class (要素ファクトリ クラス)
80
+ # Elements Factory Class (要素ファクトリ クラス)
81
81
  #
82
82
  ElementFactory = Elements
83
83
  end
@@ -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([^<>]*(#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>" # rubocop:disable Layout/LineLength
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
  '&' => '&amp;',
16
13
  '"' => '&quot;',
@@ -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
- analyze_newline
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.41
40
+ # @version 0.9.43
41
41
  #
42
42
 
43
43
  module Meteor
44
- VERSION = '0.9.41'
44
+ VERSION = '0.9.43'
45
45
 
46
46
  # require 'fileutils'
47
47
 
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.41
4
+ version: 0.9.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasumasa Ashida