meteor 0.9.16 → 0.9.18
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 +9 -0
- data/Gemfile.lock +1 -1
- data/demo/html.rb +3 -3
- data/demo/html4.rb +11 -11
- data/demo/xhtml.rb +4 -4
- data/demo/xhtml4.rb +3 -3
- data/demo/xml.rb +4 -4
- data/lib/meteor/core/kernel.rb +3 -22
- data/lib/meteor/core/util/pattern_cache.rb +2 -2
- data/lib/meteor/element.rb +0 -2
- data/lib/meteor/{element_factory.rb → elements.rb} +29 -15
- data/lib/meteor/ml/html4/parser_impl.rb +0 -3
- data/lib/meteor/ml/xml/parser_impl.rb +0 -2
- data/lib/meteor/{parser_factory.rb → parsers.rb} +55 -64
- data/lib/meteor.rb +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ea632b32536a814320a44110909a51a869dc09a9546d55307c8ca6e22e1e12ec
|
|
4
|
+
data.tar.gz: 2e5be17d0c3654208400db5731f389cb67fe9b616c1004965f820757c8d9a03b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 573c2429e3de96abd5551c92cbd14ebf15ebf5b87a9edf86559c3905d1701dc9a094ab86c2a72af52ab1ff17f367c57832560df2a53e9a4a5e15166113cebe13
|
|
7
|
+
data.tar.gz: 32874256cd55783e984614448088ecc8abd05fbc638cd718ca2e9a8114a453dec708f3f03dfd915f4157142a266f76ab88ff9a0f9c4bf37b8c2da021e8065965
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
0.9.18 / 2026-06-20 Yasumasa Ashida <ys.ashida@gmail.com>
|
|
2
|
+
|
|
3
|
+
* Fixnum → Integer
|
|
4
|
+
* Refactoring
|
|
5
|
+
|
|
6
|
+
== 0.9.17 / 2026-06-19 Yasumasa Ashida <ys.ashida@gmail.com>
|
|
7
|
+
|
|
8
|
+
* Refactoring
|
|
9
|
+
|
|
1
10
|
== 0.9.16 / 2026-06-18 Yasumasa Ashida <ys.ashida@gmail.com>
|
|
2
11
|
|
|
3
12
|
* Refactoring
|
data/Gemfile.lock
CHANGED
data/demo/html.rb
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::
|
|
9
|
-
root = Meteor::
|
|
8
|
+
Meteor::Elements.add(:html, "ml/sample_html.html")
|
|
9
|
+
root = Meteor::Elements.get("/ml/sample_html")
|
|
10
10
|
|
|
11
11
|
start_time = Time.new.to_f
|
|
12
12
|
|
|
13
13
|
elm_hello = root.element(id: "hello")
|
|
14
14
|
# elm_hello.attr(class: 'red')
|
|
15
15
|
elm_hello["class"] = "red"
|
|
16
|
-
# elm_hello['class'] = nil
|
|
16
|
+
# elm_hello['class'] = nil # elm_hello.remove_attr('class')
|
|
17
17
|
|
|
18
18
|
elm_hello2 = root.element(id: "hello2")
|
|
19
19
|
# elm_hello2.content('Hello,Tester')
|
data/demo/html4.rb
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
# Meteor::
|
|
9
|
-
Meteor::
|
|
10
|
-
Meteor::
|
|
8
|
+
# Meteor::Elements.add(:html4,'ml/sample_4.html', 'UTF-8')
|
|
9
|
+
Meteor::Elements.options = { type: :html4 }
|
|
10
|
+
Meteor::Elements.add("ml/sample_html4.html")
|
|
11
11
|
|
|
12
|
-
root = Meteor::
|
|
12
|
+
root = Meteor::Elements.get("/ml/sample_html4")
|
|
13
13
|
|
|
14
14
|
start_time = Time.new.to_f
|
|
15
15
|
|
|
@@ -31,12 +31,12 @@ elm_hello2.content = "Hello,Tester"
|
|
|
31
31
|
# puts elm_hello3.mixed_content
|
|
32
32
|
|
|
33
33
|
elm_text1 = root.element("input", id: "text1")
|
|
34
|
-
# elm_text1['value'] = 'めも'
|
|
35
|
-
# elm_text1.attr = {value: 'メモ'}
|
|
36
|
-
# elm_text1['disabled'] = true
|
|
37
|
-
elm_text1.attrs = {value: "メモ", disabled: true, readonly: true}
|
|
34
|
+
# elm_text1['value'] = 'めも' # elm_text1.attr(value: 'めも')
|
|
35
|
+
# elm_text1.attr = { value: 'メモ' }
|
|
36
|
+
# elm_text1['disabled'] = true. # elm_text1.attr(disabled: true)
|
|
37
|
+
elm_text1.attrs = { value: "メモ", disabled: true, readonly: true }
|
|
38
38
|
# puts elm_text1.attrs
|
|
39
|
-
# elm_text1['disabled'] = nil
|
|
39
|
+
# elm_text1['disabled'] = nil # elm_text1.remove_attr('disabled')
|
|
40
40
|
# map = elm_text1.attr_map
|
|
41
41
|
# map.names.each { |item|
|
|
42
42
|
# puts item
|
|
@@ -46,9 +46,9 @@ elm_text1.attrs = {value: "メモ", disabled: true, readonly: true}
|
|
|
46
46
|
# elm_radio1 = root.element('input', id: 'radio1', type: 'radio')
|
|
47
47
|
## elm_radio1 = root.css('input[id=radio1][type=radio]')
|
|
48
48
|
## elm_radio1 = root.css('# radio1') # elm_radio1 = root.css('input# radio1')
|
|
49
|
-
## elm_radio1 = root.css('.test')
|
|
49
|
+
## elm_radio1 = root.css('.test') # elm_radio1 = root.css('input.test')
|
|
50
50
|
## elm_radio1 = root.css('[id=radio1][type=radio]')
|
|
51
|
-
# elm_radio1['checked'] = true
|
|
51
|
+
# elm_radio1['checked'] = true # elm_radio1.attr(checked: true)
|
|
52
52
|
# puts elm_radio1.document
|
|
53
53
|
|
|
54
54
|
# elm_select1 = root.element('select', id: 'select1')
|
data/demo/xhtml.rb
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::
|
|
9
|
-
root = Meteor::
|
|
8
|
+
Meteor::Elements.add(:xhtml, "ml/sample_xhtml.html")
|
|
9
|
+
root = Meteor::Elements.get("/ml/sample_xhtml")
|
|
10
10
|
|
|
11
11
|
startTime = Time.new.to_f
|
|
12
12
|
|
|
13
13
|
elm_hello = root.element(id: "hello")
|
|
14
14
|
# elm_hello.attr(class: "red")
|
|
15
15
|
elm_hello["class"] = "red"
|
|
16
|
-
# elm_hello['class'] = nil
|
|
16
|
+
# elm_hello['class'] = nil # elm_hello.remove_attr('class')
|
|
17
17
|
# elm_hello.attr(class: nil)
|
|
18
18
|
|
|
19
19
|
elm_hello2 = root.element(id: "hello2")
|
|
@@ -40,7 +40,7 @@ elm_text1["required"] = true
|
|
|
40
40
|
# }
|
|
41
41
|
|
|
42
42
|
# elm_radio1 = root.element("input",id: "radio1", type: "radio")
|
|
43
|
-
# elm_radio1['checked'] = true
|
|
43
|
+
# elm_radio1['checked'] = true # elm_radio1.attr(checked: true)
|
|
44
44
|
|
|
45
45
|
# elm_select1 = root.element("select",id: "select1")
|
|
46
46
|
# elm_select1 = root.element("select")
|
data/demo/xhtml4.rb
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::
|
|
9
|
-
root = Meteor::
|
|
8
|
+
Meteor::Elements.add(:xhtml4, "ml/sample_xhtml4.html", "UTF-8")
|
|
9
|
+
root = Meteor::Elements.get("/ml/sample_xhtml4")
|
|
10
10
|
|
|
11
11
|
startTime = Time.new.to_f
|
|
12
12
|
|
|
13
13
|
elm_hello = root.element("id", "hello")
|
|
14
14
|
# elm_hello.attr(class: "red")
|
|
15
15
|
elm_hello["class"] = "red"
|
|
16
|
-
# elm_hello['class'] = nil
|
|
16
|
+
# elm_hello['class'] = nil # elm_hello.remove_attr('class')
|
|
17
17
|
|
|
18
18
|
elm_hello2 = root.element(id: "hello2")
|
|
19
19
|
# elm_hello2.content("Hello,Tester")
|
data/demo/xml.rb
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
# require 'rubygems'
|
|
6
6
|
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::
|
|
9
|
-
root = Meteor::
|
|
8
|
+
Meteor::Elements.add(Meteor::XML, "ml/sample.xml", "UTF-8")
|
|
9
|
+
root = Meteor::Elements.get("/ml/sample")
|
|
10
10
|
|
|
11
11
|
start_time = Time.new.to_f
|
|
12
12
|
|
|
@@ -90,8 +90,8 @@ elm_ = root.element(elm7)
|
|
|
90
90
|
# co_elm.content = i # co_elm.content(i)
|
|
91
91
|
# co_elm.flash
|
|
92
92
|
# }
|
|
93
|
-
|
|
94
|
-
# elm3['id3'] = 'dd'
|
|
93
|
+
#
|
|
94
|
+
# elm3['id3'] = 'dd' # elm3.attr(id3: 'dd')
|
|
95
95
|
|
|
96
96
|
root.flash
|
|
97
97
|
|
data/lib/meteor/core/kernel.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Meteor
|
|
|
8
8
|
# @!attribute [rw] element_cache
|
|
9
9
|
# @return [Hash] element cache (要素キャッシュ)
|
|
10
10
|
# @!attribute [rw] doc_type
|
|
11
|
-
# @return [
|
|
11
|
+
# @return [Integer] document type (ドキュメントタイプ)
|
|
12
12
|
# @!attribute [rw] document_hook
|
|
13
13
|
# @return [String] hook document (フック・ドキュメント)
|
|
14
14
|
# @!attribute [rw] element_hook
|
|
@@ -124,7 +124,6 @@ module Meteor
|
|
|
124
124
|
# @param [String] enc character encoding of input file (入力ファイルの文字コード)
|
|
125
125
|
#
|
|
126
126
|
def read(file_path, enc)
|
|
127
|
-
|
|
128
127
|
# try {
|
|
129
128
|
@character_encoding = enc
|
|
130
129
|
# open file (ファイルのオープン)
|
|
@@ -253,13 +252,11 @@ module Meteor
|
|
|
253
252
|
if @elm_
|
|
254
253
|
@element_cache.store(@elm_.object_id, @elm_)
|
|
255
254
|
end
|
|
256
|
-
|
|
257
255
|
when TWO
|
|
258
256
|
element_4(elm.to_s, attrs.to_s, args[0].to_s, args[1])
|
|
259
257
|
if @elm_
|
|
260
258
|
@element_cache.store(@elm_.object_id, @elm_)
|
|
261
259
|
end
|
|
262
|
-
|
|
263
260
|
when THREE
|
|
264
261
|
element_5(elm.to_s, attrs.to_s, args[0], args[1].to_s, args[2])
|
|
265
262
|
if @elm_
|
|
@@ -463,7 +460,6 @@ module Meteor
|
|
|
463
460
|
@elm_.empty = true
|
|
464
461
|
|
|
465
462
|
@elm_.parser = self
|
|
466
|
-
|
|
467
463
|
when FIVE
|
|
468
464
|
# element (要素)
|
|
469
465
|
@elm_ = Meteor::Element.new(name)
|
|
@@ -579,8 +575,8 @@ module Meteor
|
|
|
579
575
|
# document (全体)
|
|
580
576
|
@elm_.document = @res[0]
|
|
581
577
|
# pattern (空要素検索用パターン)
|
|
582
|
-
@pattern_cc = String.new("") << "<" << @_name << "(\\s[^<>]*" << @_attr_name << "=\"" << @_attr_value << closer
|
|
583
|
-
|
|
578
|
+
# @pattern_cc = String.new("") << "<" << @_name << "(\\s[^<>]*" << @_attr_name << "=\"" << @_attr_value << closer
|
|
579
|
+
@pattern_cc = "<#{@_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}#{closer}"
|
|
584
580
|
@elm_.pattern = @pattern_cc
|
|
585
581
|
@elm_.parser = self
|
|
586
582
|
|
|
@@ -596,7 +592,6 @@ module Meteor
|
|
|
596
592
|
# @return [Meteor::Element] element (要素)
|
|
597
593
|
#
|
|
598
594
|
def element_2(attr_name, attr_value)
|
|
599
|
-
|
|
600
595
|
quote_attribute(attr_name, attr_value)
|
|
601
596
|
|
|
602
597
|
element_pattern_2
|
|
@@ -613,7 +608,6 @@ module Meteor
|
|
|
613
608
|
|
|
614
609
|
@elm_ = nil
|
|
615
610
|
end
|
|
616
|
-
#=end
|
|
617
611
|
|
|
618
612
|
=begin
|
|
619
613
|
@pattern_cc_1 = "<([^<>\"]*)(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)\\/>|<([^<>\"]*)(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)>(((?!(\\3[^<>]*>)).)*)<\\/\\3>"
|
|
@@ -828,7 +822,6 @@ module Meteor
|
|
|
828
822
|
# @return [Meteor::Element] element (要素)
|
|
829
823
|
#
|
|
830
824
|
def element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
831
|
-
|
|
832
825
|
quote_element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
833
826
|
|
|
834
827
|
@pattern_cc_1 = "<#{@_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)\\/>|<#{@_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>(((?!(#{@_name}[^<>]*>)).)*)<\\/#{@_name}>"
|
|
@@ -962,7 +955,6 @@ module Meteor
|
|
|
962
955
|
private :element_with_5_1
|
|
963
956
|
|
|
964
957
|
def element_with_5_2
|
|
965
|
-
|
|
966
958
|
element_pattern_with_5_2
|
|
967
959
|
|
|
968
960
|
if @sbuf.length == ZERO || @cnt != ZERO
|
|
@@ -1056,7 +1048,6 @@ module Meteor
|
|
|
1056
1048
|
# @return [Meteor::Element] element (要素)
|
|
1057
1049
|
#
|
|
1058
1050
|
def element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1059
|
-
|
|
1060
1051
|
quote_element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1061
1052
|
|
|
1062
1053
|
element_pattern_4
|
|
@@ -1092,7 +1083,6 @@ module Meteor
|
|
|
1092
1083
|
private :quote_element_4
|
|
1093
1084
|
|
|
1094
1085
|
def element_pattern_4
|
|
1095
|
-
|
|
1096
1086
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s([^<>]*(' << @_attr_name1 << '="'
|
|
1097
1087
|
# @pattern_cc << @_attr_value1 << '"[^<>]*' << @_attr_name2 << '="'
|
|
1098
1088
|
# @pattern_cc << @_attr_value2 << '"|' << @_attr_name2 << '="'
|
|
@@ -1462,7 +1452,6 @@ module Meteor
|
|
|
1462
1452
|
nil
|
|
1463
1453
|
end
|
|
1464
1454
|
end
|
|
1465
|
-
|
|
1466
1455
|
when 2
|
|
1467
1456
|
if selector[0] == "["
|
|
1468
1457
|
if @res = @@pattern_find_4.match(selector)
|
|
@@ -1513,7 +1502,6 @@ module Meteor
|
|
|
1513
1502
|
remove_attr(elm, attr.to_s)
|
|
1514
1503
|
end
|
|
1515
1504
|
end
|
|
1516
|
-
|
|
1517
1505
|
elsif attr.kind_of?(Hash) && attr.size == 1
|
|
1518
1506
|
if attr.values[0] != nil
|
|
1519
1507
|
elm.document_sync = true
|
|
@@ -1551,7 +1539,6 @@ module Meteor
|
|
|
1551
1539
|
private :set_attribute_3
|
|
1552
1540
|
|
|
1553
1541
|
def edit_attrs_(elm, attr_name, attr_value)
|
|
1554
|
-
|
|
1555
1542
|
# attribute search (属性検索)
|
|
1556
1543
|
# @res = @pattern.match(elm.attributes)
|
|
1557
1544
|
|
|
@@ -1595,7 +1582,6 @@ module Meteor
|
|
|
1595
1582
|
private :get_attr_value
|
|
1596
1583
|
|
|
1597
1584
|
def get_attr_value_(elm, attr_name)
|
|
1598
|
-
|
|
1599
1585
|
# attribute search pattern (属性検索用パターン)
|
|
1600
1586
|
@pattern = Meteor::Core::Util::PatternCache.get(String.new("") << attr_name << "=\"([^\"]*)\"")
|
|
1601
1587
|
# @pattern = Meteor::Core::Util::PatternCache.get("#{attr_name}=\"([^\"]*)\"")
|
|
@@ -1792,7 +1778,6 @@ module Meteor
|
|
|
1792
1778
|
# @return [Meteor::Element] element (要素)
|
|
1793
1779
|
#
|
|
1794
1780
|
def set_content_3(elm, content, entity_ref = true)
|
|
1795
|
-
|
|
1796
1781
|
if entity_ref || !elm.raw_content
|
|
1797
1782
|
escape_content(content, elm)
|
|
1798
1783
|
end
|
|
@@ -1893,7 +1878,6 @@ module Meteor
|
|
|
1893
1878
|
if @elm_
|
|
1894
1879
|
@element_cache.store(@elm_.object_id, @elm_)
|
|
1895
1880
|
end
|
|
1896
|
-
|
|
1897
1881
|
when TWO
|
|
1898
1882
|
cxtag_2(args[0].to_s, args[1].to_s)
|
|
1899
1883
|
if @elm_
|
|
@@ -1956,7 +1940,6 @@ module Meteor
|
|
|
1956
1940
|
# @return [Meteor::Element] element (要素)
|
|
1957
1941
|
#
|
|
1958
1942
|
def cxtag_1(id)
|
|
1959
|
-
|
|
1960
1943
|
@_id = Regexp.quote(id)
|
|
1961
1944
|
|
|
1962
1945
|
@pattern_cc = String.new("") << "<!--\\s@([^<>]*)\\s[^<>]*id=\"" << @_id << "\""
|
|
@@ -2025,7 +2008,6 @@ module Meteor
|
|
|
2025
2008
|
private :edit_document_1
|
|
2026
2009
|
|
|
2027
2010
|
def edit_document_2(elm, closer)
|
|
2028
|
-
|
|
2029
2011
|
# replace tag (タグ置換)
|
|
2030
2012
|
@pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
|
|
2031
2013
|
@root.document.sub!(@pattern, elm.document)
|
|
@@ -2037,7 +2019,6 @@ module Meteor
|
|
|
2037
2019
|
# reflect (反映する)
|
|
2038
2020
|
#
|
|
2039
2021
|
def flash
|
|
2040
|
-
|
|
2041
2022
|
if self.element_hook
|
|
2042
2023
|
if self.element_hook.origin.mono
|
|
2043
2024
|
if self.element_hook.origin.cx
|
|
@@ -23,7 +23,7 @@ module Meteor
|
|
|
23
23
|
# @return [Regexp] pattern (パターン)
|
|
24
24
|
# @overload get(regex,option)
|
|
25
25
|
# @param [String] regex regular expression (正規表現)
|
|
26
|
-
# @param [
|
|
26
|
+
# @param [Integer] option option of Regex (オプション)
|
|
27
27
|
# @return [Regexp] pattern (パターン)
|
|
28
28
|
#
|
|
29
29
|
def self.get(*args)
|
|
@@ -78,7 +78,7 @@ module Meteor
|
|
|
78
78
|
##
|
|
79
79
|
## パターンを取得する
|
|
80
80
|
## @param [String] regex 正規表現
|
|
81
|
-
## @param [
|
|
81
|
+
## @param [Integer] option オプション
|
|
82
82
|
## @return [Regexp] パターン
|
|
83
83
|
##
|
|
84
84
|
# def self.get_2(regex, option)
|
data/lib/meteor/element.rb
CHANGED
|
@@ -76,7 +76,6 @@ module Meteor
|
|
|
76
76
|
else
|
|
77
77
|
raise ArgumentError
|
|
78
78
|
end
|
|
79
|
-
|
|
80
79
|
when Meteor::TWO
|
|
81
80
|
@name = args[0].name
|
|
82
81
|
@attributes = String.new(args[0].attributes)
|
|
@@ -214,7 +213,6 @@ module Meteor
|
|
|
214
213
|
# @document = "<#{@name}#{@attributes}>"
|
|
215
214
|
end
|
|
216
215
|
end
|
|
217
|
-
|
|
218
216
|
when Parser::XHTML, Parser::XHTML4, Parser::XML
|
|
219
217
|
if @cx
|
|
220
218
|
# @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->'
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
module Meteor
|
|
5
5
|
#
|
|
6
|
-
#
|
|
6
|
+
# Elements Class (要素ファクトリ クラス)
|
|
7
7
|
#
|
|
8
|
-
class
|
|
9
|
-
@@pf = Meteor::
|
|
8
|
+
class Elements
|
|
9
|
+
@@pf = Meteor::Parsers.new
|
|
10
10
|
|
|
11
11
|
#
|
|
12
12
|
# set options (オプションをセットする)
|
|
@@ -23,37 +23,42 @@ module Meteor
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
#
|
|
26
|
-
#@overload
|
|
26
|
+
#@overload add(type,relative_path,enc)
|
|
27
27
|
# generate parser (パーサを作成する)
|
|
28
|
-
# @param [
|
|
28
|
+
# @param [Integer] type type of parser (パーサ・タイプ)
|
|
29
29
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
30
30
|
# @param [String] enc character encoding (エンコーディング)
|
|
31
31
|
# @return [Meteor::Parser] parser (パーサ)
|
|
32
|
-
#@overload
|
|
32
|
+
#@overload add(type,relative_path)
|
|
33
33
|
# generate parser (パーサを作成する)
|
|
34
|
-
# @param [
|
|
34
|
+
# @param [Integer] type type of parser (パーサ・タイプ)
|
|
35
35
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
36
36
|
# @return [Meteor::Parser] parser (パーサ)
|
|
37
37
|
#
|
|
38
|
-
def self.
|
|
39
|
-
@@pf.
|
|
38
|
+
def self.add(*args)
|
|
39
|
+
@@pf.add(*args)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
#
|
|
43
|
-
# @overload
|
|
43
|
+
# @overload add_str(type, relative_url, doc)
|
|
44
44
|
# generate parser (パーサを作成する)
|
|
45
|
-
# @param [
|
|
45
|
+
# @param [Integer] type type of parser (パーサ・タイプ)
|
|
46
46
|
# @param [String] relative_url relative URL (相対URL)
|
|
47
47
|
# @param [String] doc document (ドキュメント)
|
|
48
48
|
# @return [Meteor::Parser] parser (パーサ)
|
|
49
|
-
# @overload
|
|
49
|
+
# @overload add_str(relative_url, doc)
|
|
50
50
|
# generate parser (パーサを作成する)
|
|
51
51
|
# @param [String] relative_url relative URL (相対URL)
|
|
52
52
|
# @param [String] doc document (ドキュメント)
|
|
53
53
|
# @return [Meteor::Parser] parser (パーサ)
|
|
54
54
|
#
|
|
55
|
-
def self.
|
|
56
|
-
@@pf.
|
|
55
|
+
def self.add_str(*args)
|
|
56
|
+
@@pf.add_str(args)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class << self
|
|
60
|
+
alias_method :link, :add
|
|
61
|
+
alias_method :link_str, :add_str
|
|
57
62
|
end
|
|
58
63
|
|
|
59
64
|
#
|
|
@@ -61,8 +66,17 @@ module Meteor
|
|
|
61
66
|
# @param [String,Symbol] key identifier (キー)
|
|
62
67
|
# @return [Meteor::RootElement] root element (ルート要素)
|
|
63
68
|
#
|
|
64
|
-
def self.
|
|
69
|
+
def self.get(key)
|
|
65
70
|
@@pf.element(key)
|
|
66
71
|
end
|
|
72
|
+
|
|
73
|
+
class << self
|
|
74
|
+
alias_method :element, :get
|
|
75
|
+
end
|
|
67
76
|
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# Elements Class (要素ファクトリ クラス)
|
|
80
|
+
#
|
|
81
|
+
Elements = Elements
|
|
68
82
|
end
|
|
@@ -351,7 +351,6 @@ module Meteor
|
|
|
351
351
|
# @return [Meteor::Element] element (要素)
|
|
352
352
|
#
|
|
353
353
|
def element_2(attr_name, attr_value)
|
|
354
|
-
|
|
355
354
|
quote_attribute(attr_name, attr_value)
|
|
356
355
|
|
|
357
356
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value
|
|
@@ -386,7 +385,6 @@ module Meteor
|
|
|
386
385
|
# @return [Meteor::Element] element (要素)
|
|
387
386
|
#
|
|
388
387
|
def element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
389
|
-
|
|
390
388
|
quote_element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
391
389
|
|
|
392
390
|
# 空要素の場合(<->内容あり要素の場合)
|
|
@@ -579,7 +577,6 @@ module Meteor
|
|
|
579
577
|
private :get_type
|
|
580
578
|
|
|
581
579
|
def get_attr_value_r(elm, match_p)
|
|
582
|
-
|
|
583
580
|
@res = match_p.match(elm.attributes)
|
|
584
581
|
|
|
585
582
|
if @res
|
|
@@ -12,7 +12,7 @@ module Meteor
|
|
|
12
12
|
# @!attribute [rw] enc
|
|
13
13
|
# @return [String] default character encoding (デフォルトエンコーディング)
|
|
14
14
|
#
|
|
15
|
-
class
|
|
15
|
+
class Parsers
|
|
16
16
|
attr_accessor :type
|
|
17
17
|
attr_accessor :root
|
|
18
18
|
attr_accessor :enc
|
|
@@ -137,47 +137,48 @@ module Meteor
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
#
|
|
140
|
-
#@overload
|
|
140
|
+
#@overload add(relative_path,enc)
|
|
141
141
|
# generate parser (パーサを作成する)
|
|
142
142
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
143
143
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
144
144
|
# @return [Meteor::Parser] parser (パーサ)
|
|
145
|
-
#@overload
|
|
145
|
+
#@overload add(relative_path)
|
|
146
146
|
# generate parser (パーサを作成する)
|
|
147
147
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
148
148
|
# @return [Meteor::Parser] parser (パーサ)
|
|
149
|
-
#@overload
|
|
149
|
+
#@overload add(type,relative_path,enc)
|
|
150
150
|
# generate parser (パーサを作成する)
|
|
151
|
-
# @param [
|
|
151
|
+
# @param [Integer,Symbol] type type of parser (パーサ・タイプ)
|
|
152
152
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
153
153
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
154
154
|
# @return [Meteor::Parser] parser (パーサ)
|
|
155
|
-
#@overload
|
|
155
|
+
#@overload add(type,relative_path)
|
|
156
156
|
# generate parser (パーサを作成する)
|
|
157
|
-
# @param [
|
|
157
|
+
# @param [Integer,Symbol] type type of parser (パーサ・タイプ)
|
|
158
158
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
159
159
|
# @return [Meteor::Parser] parser (パーサ)
|
|
160
160
|
#
|
|
161
|
-
def
|
|
161
|
+
def add(*args)
|
|
162
162
|
case args.length
|
|
163
163
|
when 1
|
|
164
|
-
|
|
164
|
+
add_1(args[0])
|
|
165
165
|
when 2
|
|
166
|
-
if args[0].kind_of?(
|
|
167
|
-
|
|
166
|
+
if args[0].kind_of?(Integer) || args[0].kind_of?(Symbol)
|
|
167
|
+
add_2_n(args[0], args[1])
|
|
168
168
|
elsif args[0].kind_of?(String)
|
|
169
|
-
|
|
169
|
+
add_2_s(args[0], args[1])
|
|
170
170
|
else
|
|
171
171
|
raise ArgumentError
|
|
172
172
|
end
|
|
173
|
-
|
|
174
173
|
when 3
|
|
175
|
-
|
|
174
|
+
add_3(args[0], args[1], args[2])
|
|
176
175
|
else
|
|
177
176
|
raise ArgumentError
|
|
178
177
|
end
|
|
179
178
|
end
|
|
180
179
|
|
|
180
|
+
alias_method :link, :add
|
|
181
|
+
|
|
181
182
|
#
|
|
182
183
|
# change relative path to relative url (相対パスを相対URLにする)
|
|
183
184
|
# @param [String] path relative path (相対パス)
|
|
@@ -204,36 +205,32 @@ module Meteor
|
|
|
204
205
|
|
|
205
206
|
#
|
|
206
207
|
# generate parser (パーサを作成する)
|
|
207
|
-
# @param [
|
|
208
|
+
# @param [Integer,Symbol] type type of parser (パーサ・タイプ)
|
|
208
209
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
209
210
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
210
211
|
# @return [Meteor::Parser] parser(パーサ)
|
|
211
212
|
#
|
|
212
|
-
def
|
|
213
|
-
relative_url = path_to_url(relative_path)
|
|
214
|
-
|
|
213
|
+
def add_3(type, relative_path, enc = "UTF-8")
|
|
215
214
|
ps = new_parser(type)
|
|
216
215
|
ps.read(File.expand_path(relative_path, @root), enc)
|
|
216
|
+
|
|
217
|
+
relative_url = path_to_url(relative_path)
|
|
217
218
|
@cache[relative_url] = ps
|
|
218
219
|
end
|
|
219
220
|
|
|
220
|
-
private :
|
|
221
|
+
private :add_3
|
|
221
222
|
|
|
222
223
|
#
|
|
223
224
|
# generate parser (パーサを作成する)
|
|
224
|
-
# @param [
|
|
225
|
+
# @param [Integer,Symbol] type type of parser(パーサ・タイプ)
|
|
225
226
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
226
227
|
# @return [Meteor::Parser] parser (パーサ)
|
|
227
228
|
#
|
|
228
|
-
def
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
ps = new_parser(type)
|
|
232
|
-
ps.read(File.expand_path(relative_path, @root), @enc)
|
|
233
|
-
@cache[relative_url] = ps
|
|
229
|
+
def add_2_n(type, relative_path)
|
|
230
|
+
add_3(type, relative_path, @enc)
|
|
234
231
|
end
|
|
235
232
|
|
|
236
|
-
private :
|
|
233
|
+
private :add_2_n
|
|
237
234
|
|
|
238
235
|
#
|
|
239
236
|
# generate parser (パーサを作成する)
|
|
@@ -241,30 +238,22 @@ module Meteor
|
|
|
241
238
|
# @param [String] enc character encoding (文字エンコーディング)
|
|
242
239
|
# @return [Meteor::Parser] parser (パーサ)
|
|
243
240
|
#
|
|
244
|
-
def
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
ps = new_parser(@type)
|
|
248
|
-
ps.read(File.expand_path(relative_path, @root), enc)
|
|
249
|
-
@cache[relative_url] = ps
|
|
241
|
+
def add_2_s(relative_path, enc)
|
|
242
|
+
add_3(@type, relative_path, enc)
|
|
250
243
|
end
|
|
251
244
|
|
|
252
|
-
private :
|
|
245
|
+
private :add_2_s
|
|
253
246
|
|
|
254
247
|
#
|
|
255
248
|
# generate parser (パーサを作成する)
|
|
256
249
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
257
250
|
# @return [Meteor::Parser] parser (パーサ)
|
|
258
251
|
#
|
|
259
|
-
def
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
ps = new_parser(@type)
|
|
263
|
-
ps.read(File.expand_path(relative_path, @root), @enc)
|
|
264
|
-
@cache[relative_url] = ps
|
|
252
|
+
def add_1(relative_path)
|
|
253
|
+
add_3(@type, relative_path, @enc)
|
|
265
254
|
end
|
|
266
255
|
|
|
267
|
-
private :
|
|
256
|
+
private :add_1
|
|
268
257
|
|
|
269
258
|
#
|
|
270
259
|
#@overload parser(key)
|
|
@@ -273,14 +262,14 @@ module Meteor
|
|
|
273
262
|
# @return [Meteor::Parser] parser (パーサ)
|
|
274
263
|
#@overload parser(type,relative_path,enc)
|
|
275
264
|
# generate parser (パーサを作成する)
|
|
276
|
-
# @param [
|
|
265
|
+
# @param [Integer] type type of parser (パーサ・タイプ)
|
|
277
266
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
278
267
|
# @param [String] enc character encoding (エンコーディング)
|
|
279
268
|
# @return [Meteor::Parser] parser (パーサ)
|
|
280
269
|
# @deprecated
|
|
281
270
|
#@overload parser(type,relative_path)
|
|
282
271
|
# generate parser (パーサを作成する)
|
|
283
|
-
# @param [
|
|
272
|
+
# @param [Integer] type type of parser (パーサ・タイプ)
|
|
284
273
|
# @param [String] relative_path relative file path (相対ファイルパス)
|
|
285
274
|
# @return [Meteor::Parser] parser (パーサ)
|
|
286
275
|
# @deprecated
|
|
@@ -289,7 +278,7 @@ module Meteor
|
|
|
289
278
|
when 1
|
|
290
279
|
parser_1(args[0])
|
|
291
280
|
when 2, 3
|
|
292
|
-
|
|
281
|
+
add(args)
|
|
293
282
|
end
|
|
294
283
|
# parser_1(key)
|
|
295
284
|
end
|
|
@@ -327,24 +316,24 @@ module Meteor
|
|
|
327
316
|
end
|
|
328
317
|
|
|
329
318
|
#
|
|
330
|
-
# @overload
|
|
319
|
+
# @overload add_str(type, relative_url, doc)
|
|
331
320
|
# generate parser (パーサを作成する)
|
|
332
|
-
# @param [
|
|
321
|
+
# @param [Integer] type type of parser (パーサ・タイプ)
|
|
333
322
|
# @param [String] relative_url relative URL (相対URL)
|
|
334
323
|
# @param [String] doc document (ドキュメント)
|
|
335
324
|
# @return [Meteor::Parser] parser (パーサ)
|
|
336
|
-
# @overload
|
|
325
|
+
# @overload add_str(relative_url, doc)
|
|
337
326
|
# generate parser (パーサを作成する)
|
|
338
327
|
# @param [String] relative_url relative URL (相対URL)
|
|
339
328
|
# @param [String] doc document (ドキュメント)
|
|
340
329
|
# @return [Meteor::Parser] parser (パーサ)
|
|
341
330
|
#
|
|
342
|
-
def
|
|
331
|
+
def add_str(*args)
|
|
343
332
|
case args.length
|
|
344
333
|
when 2
|
|
345
|
-
|
|
334
|
+
add_str_2(args[0], args[1])
|
|
346
335
|
when 3
|
|
347
|
-
|
|
336
|
+
add_str_3(args[0], args[1], args[2])
|
|
348
337
|
else
|
|
349
338
|
raise ArgumentError
|
|
350
339
|
end
|
|
@@ -352,20 +341,20 @@ module Meteor
|
|
|
352
341
|
|
|
353
342
|
#
|
|
354
343
|
# generate parser (パーサを作成する)
|
|
355
|
-
# @param [
|
|
344
|
+
# @param [Integer,Symbol] type type of parser (パーサ・タイプ)
|
|
356
345
|
# @param [String] relative_url relative URL (相対URL)
|
|
357
346
|
# @param [String] doc document (ドキュメント)
|
|
358
347
|
# @return [Meteor::Parser] parser (パーサ)
|
|
359
348
|
#
|
|
360
|
-
def
|
|
361
|
-
ps = new_parser(
|
|
362
|
-
|
|
363
|
-
ps.dcument = doc
|
|
349
|
+
def add_str_3(type, relative_url, doc)
|
|
350
|
+
ps = new_parser(type)
|
|
351
|
+
ps.document = doc
|
|
364
352
|
ps.parse
|
|
353
|
+
|
|
365
354
|
@cache[relative_url] = ps
|
|
366
355
|
end
|
|
367
356
|
|
|
368
|
-
private :
|
|
357
|
+
private :add_str_3
|
|
369
358
|
|
|
370
359
|
#
|
|
371
360
|
# generate parser (パーサを作成する)
|
|
@@ -373,17 +362,14 @@ module Meteor
|
|
|
373
362
|
# @param [String] doc document (ドキュメント)
|
|
374
363
|
# @return [Meteor::Parser] parser (パーサ)
|
|
375
364
|
#
|
|
376
|
-
def
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
ps.document = doc
|
|
380
|
-
ps.parse
|
|
381
|
-
@cache[relative_url] = ps
|
|
365
|
+
def add_str_2(relative_url, doc)
|
|
366
|
+
add_str_3(@type, relative_url, doc)
|
|
382
367
|
end
|
|
383
368
|
|
|
384
|
-
private :
|
|
369
|
+
private :add_str_2
|
|
385
370
|
|
|
386
|
-
|
|
371
|
+
alias_method :link_str, :add_str
|
|
372
|
+
alias_method :parser_str, :add_str
|
|
387
373
|
|
|
388
374
|
def new_parser(type)
|
|
389
375
|
case type
|
|
@@ -422,4 +408,9 @@ module Meteor
|
|
|
422
408
|
self.parser(key)
|
|
423
409
|
end
|
|
424
410
|
end
|
|
411
|
+
|
|
412
|
+
#
|
|
413
|
+
# Parser Factory Class (パーサ・ファクトリ クラス)
|
|
414
|
+
#
|
|
415
|
+
ParserFactory = Parsers
|
|
425
416
|
end
|
data/lib/meteor.rb
CHANGED
|
@@ -6,8 +6,8 @@ require "meteor/root_element"
|
|
|
6
6
|
require "meteor/attribute"
|
|
7
7
|
require "meteor/attribute_map"
|
|
8
8
|
require "meteor/parser"
|
|
9
|
-
require "meteor/
|
|
10
|
-
require "meteor/
|
|
9
|
+
require "meteor/parsers"
|
|
10
|
+
require "meteor/elements"
|
|
11
11
|
require "meteor/exception/no_such_element_exception"
|
|
12
12
|
require "meteor/core/kernel"
|
|
13
13
|
require "meteor/core/util/pattern_cache"
|
|
@@ -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.
|
|
39
|
+
# @version 0.9.18
|
|
40
40
|
#
|
|
41
41
|
|
|
42
42
|
module Meteor
|
|
43
|
-
VERSION = "0.9.
|
|
43
|
+
VERSION = "0.9.18"
|
|
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.
|
|
4
|
+
version: 0.9.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yasumasa Ashida
|
|
@@ -51,7 +51,7 @@ files:
|
|
|
51
51
|
- lib/meteor/core/kernel.rb
|
|
52
52
|
- lib/meteor/core/util/pattern_cache.rb
|
|
53
53
|
- lib/meteor/element.rb
|
|
54
|
-
- lib/meteor/
|
|
54
|
+
- lib/meteor/elements.rb
|
|
55
55
|
- lib/meteor/exception/no_such_element_exception.rb
|
|
56
56
|
- lib/meteor/ml/html/parser_impl.rb
|
|
57
57
|
- lib/meteor/ml/html4/parser_impl.rb
|
|
@@ -59,7 +59,7 @@ files:
|
|
|
59
59
|
- lib/meteor/ml/xhtml4/parser_impl.rb
|
|
60
60
|
- lib/meteor/ml/xml/parser_impl.rb
|
|
61
61
|
- lib/meteor/parser.rb
|
|
62
|
-
- lib/meteor/
|
|
62
|
+
- lib/meteor/parsers.rb
|
|
63
63
|
- lib/meteor/root_element.rb
|
|
64
64
|
- meteor.gemspec
|
|
65
65
|
- test/meteor_test.rb
|