meteor 0.9.15 → 0.9.16

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: d6586cbfb631f019d21e7c7b9e900452d2611b9afefcf0ac38bd9e7f004224f6
4
- data.tar.gz: 6a8872a716c23859f82070db908b1097cd8d0424b9ad5d8ce989896680eaf5e9
3
+ metadata.gz: f7d47ad0742865e6db6e46f77760be2e297d06801994d8946d5d214b62eabb2c
4
+ data.tar.gz: 9589c40343c33e537a172f2f7473eacb0c2e76cd68bc2718b8795c9400b7e1fa
5
5
  SHA512:
6
- metadata.gz: 660d690f2e3e458da8f945ce9fbe35e23f095c3144be4364a4cbcaae41f67e8a6e37f7ee81c2b9429349f945fc15d4b968d53c83f9418ea9518d17db8974a30b
7
- data.tar.gz: a39d22634dae13029428b91b10ff66016f3945b3ba37d3d484d11897bf43ad86c3c2e7fc4f0993c258a747a0b8475e170aadcabf655d98b482e3692825deb8c5
6
+ metadata.gz: 3499c0efa7aa62b76a5ad077855b1c8da0c715396ee0979a9c6103a3a8f7b85606558794be63b64c012864c53b915556ae165da6d282af616b6912342689fd0f
7
+ data.tar.gz: a4d2d9d1d8ec23285c94840934967c37ac7921813c951b8ec0c1e52ed3cb968cd678f080f646c0aa67676596b5abff91e24337820ef67ff10973364223042c4a
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.9.16 / 2026-06-18 Yasumasa Ashida <ys.ashida@gmail.com>
2
+
3
+ * Refactoring
4
+
1
5
  == 0.9.15 / 2026-06-18 Yasumasa Ashida <ys.ashida@gmail.com>
2
6
 
3
7
  * Fix ParserImpl#element
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- meteor (0.9.15)
4
+ meteor (0.9.16)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -52,7 +52,7 @@ module Meteor
52
52
  # @@pattern_true = Regexp.new("true")
53
53
  # @@pattern_false = Regexp.new("false")
54
54
 
55
- PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt|nbsp);"
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
  #
@@ -650,14 +651,14 @@ module Meteor
650
651
  private :remove_attrs_
651
652
 
652
653
  def escape(content)
653
- # 特殊文字の置換
654
+ # replace special character (特殊文字の置換)
654
655
  content = content.gsub(@@pattern_escape, TABLE_FOR_ESCAPE_)
655
656
 
656
657
  content
657
658
  end
658
659
 
659
660
  def escape_content(content, elm)
660
- # 特殊文字の置換
661
+ # replace special character (特殊文字の置換)
661
662
  content = content.gsub(@@pattern_escape_content, TABLE_FOR_ESCAPE_CONTENT_)
662
663
 
663
664
  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
  "&" => "&amp;",
20
16
  "\"" => "&quot;",
@@ -22,9 +18,13 @@ module Meteor
22
18
  "<" => "&lt;",
23
19
  ">" => "&gt;"
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
@@ -59,9 +59,7 @@ module Meteor
59
59
  # initializer (イニシャライザ)
60
60
  #
61
61
  def initialize_0
62
- @cache = Hash.new
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
- @cache = Hash.new
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
@@ -214,31 +210,11 @@ module Meteor
214
210
  # @return [Meteor::Parser] parser(パーサ)
215
211
  #
216
212
  def link_3(type, relative_path, enc)
217
-
218
213
  relative_url = path_to_url(relative_path)
219
214
 
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
215
+ ps = new_parser(type)
216
+ ps.read(File.expand_path(relative_path, @root), enc)
217
+ @cache[relative_url] = ps
242
218
  end
243
219
 
244
220
  private :link_3
@@ -250,22 +226,9 @@ module Meteor
250
226
  # @return [Meteor::Parser] parser (パーサ)
251
227
  #
252
228
  def link_2_n(type, relative_path)
253
-
254
229
  relative_url = path_to_url(relative_path)
255
230
 
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
-
231
+ ps = new_parser(type)
269
232
  ps.read(File.expand_path(relative_path, @root), @enc)
270
233
  @cache[relative_url] = ps
271
234
  end
@@ -279,22 +242,9 @@ module Meteor
279
242
  # @return [Meteor::Parser] parser (パーサ)
280
243
  #
281
244
  def link_2_s(relative_path, enc)
282
-
283
245
  relative_url = path_to_url(relative_path)
284
246
 
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
-
247
+ ps = new_parser(@type)
298
248
  ps.read(File.expand_path(relative_path, @root), enc)
299
249
  @cache[relative_url] = ps
300
250
  end
@@ -307,24 +257,9 @@ module Meteor
307
257
  # @return [Meteor::Parser] parser (パーサ)
308
258
  #
309
259
  def link_1(relative_path)
310
-
311
260
  relative_url = path_to_url(relative_path)
312
261
 
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
-
262
+ ps = new_parser(@type)
328
263
  ps.read(File.expand_path(relative_path, @root), @enc)
329
264
  @cache[relative_url] = ps
330
265
  end
@@ -423,18 +358,7 @@ module Meteor
423
358
  # @return [Meteor::Parser] parser (パーサ)
424
359
  #
425
360
  def link_str_3(type, relative_url, doc)
426
- case type
427
- when Parser::HTML, :html
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
361
+ ps = new_parser(@type)
438
362
 
439
363
  ps.dcument = doc
440
364
  ps.parse
@@ -450,18 +374,7 @@ module Meteor
450
374
  # @return [Meteor::Parser] parser (パーサ)
451
375
  #
452
376
  def link_str_2(relative_url, doc)
453
- case @type
454
- when Parser::HTML, :html
455
- ps = Meteor::Ml::Html::ParserImpl.new
456
- when Parser::XML, :xml
457
- ps = Meteor::Ml::Xml::ParserImpl.new
458
- when Parser::XHTML, :xhtml
459
- ps = Meteor::Ml::Xhtml::ParserImpl.new
460
- when Parser::HTML4, :html4
461
- ps = Meteor::Ml::Html4::ParserImpl.new
462
- when Parser::XHTML4, :xhtml4
463
- ps = Meteor::Ml::Xhtml4::ParserImpl.new
464
- end
377
+ ps = new_parser(@type)
465
378
 
466
379
  ps.document = doc
467
380
  ps.parse
@@ -472,6 +385,25 @@ module Meteor
472
385
 
473
386
  alias :paraser_str :link_str
474
387
 
388
+ def new_parser(type)
389
+ case type
390
+ when Parser::HTML, :html
391
+ Meteor::Ml::Html::ParserImpl.new
392
+ when Parser::XML, :xml
393
+ Meteor::Ml::Xml::ParserImpl.new
394
+ when Parser::XHTML, :xhtml
395
+ Meteor::Ml::Xhtml::ParserImpl.new
396
+ when Parser::HTML4, :html4
397
+ Meteor::Ml::Html4::ParserImpl.new
398
+ when Parser::XHTML4, :xhtml4
399
+ Meteor::Ml::Xhtml4::ParserImpl.new
400
+ else
401
+ raise ArgumentError
402
+ end
403
+ end
404
+
405
+ private :new_parser
406
+
475
407
  #
476
408
  # set parser (パーサをセットする)
477
409
  # @param [String,Symbol] key identifier (キー)
data/lib/meteor.rb CHANGED
@@ -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.15
39
+ # @version 0.9.16
40
40
  #
41
41
 
42
42
  module Meteor
43
- VERSION = "0.9.15"
43
+ VERSION = "0.9.16"
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.15
4
+ version: 0.9.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasumasa Ashida