meteor 0.9.13 → 0.9.14
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 +3 -3
- data/demo/html.rb +49 -39
- data/demo/html4.rb +40 -33
- data/demo/ml/sample.xml +36 -38
- data/demo/ml/sample_html.html +7 -2
- data/demo/ml/sample_html4.html +9 -2
- data/demo/ml/sample_xhtml.html +7 -2
- data/demo/ml/sample_xhtml4.html +10 -3
- data/demo/xhtml.rb +41 -30
- data/demo/xhtml4.rb +35 -26
- data/demo/xml.rb +25 -20
- data/lib/meteor/attribute_map.rb +8 -6
- data/lib/meteor/core/kernel.rb +288 -260
- data/lib/meteor/core/util/pattern_cache.rb +16 -15
- data/lib/meteor/element.rb +65 -63
- data/lib/meteor/exception/no_such_element_exception.rb +15 -15
- data/lib/meteor/ml/html/parser_impl.rb +58 -33
- data/lib/meteor/ml/html4/parser_impl.rb +118 -90
- data/lib/meteor/ml/xhtml/parser_impl.rb +33 -29
- data/lib/meteor/ml/xhtml4/parser_impl.rb +98 -90
- data/lib/meteor/ml/xml/parser_impl.rb +35 -25
- data/lib/meteor/parser_factory.rb +125 -125
- data/lib/meteor.rb +2 -2
- metadata +2 -2
data/demo/xhtml.rb
CHANGED
|
@@ -3,20 +3,22 @@
|
|
|
3
3
|
# frozen_string_literal: true
|
|
4
4
|
|
|
5
5
|
# require 'rubygems'
|
|
6
|
-
require
|
|
6
|
+
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::ElementFactory.link(:xhtml,
|
|
9
|
-
root = Meteor::ElementFactory.element(
|
|
8
|
+
Meteor::ElementFactory.link(:xhtml, "ml/sample_xhtml.html", "UTF-8")
|
|
9
|
+
root = Meteor::ElementFactory.element("/ml/sample_xhtml")
|
|
10
10
|
|
|
11
11
|
startTime = Time.new.to_f
|
|
12
12
|
|
|
13
|
-
elm_hello = root.element(id:
|
|
14
|
-
|
|
13
|
+
elm_hello = root.element(id: "hello")
|
|
14
|
+
# elm_hello.attr(class: "red")
|
|
15
|
+
elm_hello["class"] = "red"
|
|
15
16
|
# elm_hello['class'] = nil # elm_hello.remove_attr('class')
|
|
16
17
|
# elm_hello.attr(class: nil)
|
|
17
18
|
|
|
18
|
-
elm_hello2 = root.element(id:
|
|
19
|
-
|
|
19
|
+
elm_hello2 = root.element(id: "hello2")
|
|
20
|
+
# elm_hello2.content("Hello,Tester")
|
|
21
|
+
elm_hello2.content = "Hello,Tester"
|
|
20
22
|
# elm_hello2.remove
|
|
21
23
|
|
|
22
24
|
# elm_hello3 = root.cxtag("hello3")
|
|
@@ -24,10 +26,13 @@ elm_hello2.content = "Hello,Tester" # elm_hello2.content("Hello,Tester")
|
|
|
24
26
|
# puts elm_hello3.content
|
|
25
27
|
# puts elm_hello3.mixed_content
|
|
26
28
|
|
|
27
|
-
elm_text1 = root.element(id:
|
|
28
|
-
|
|
29
|
-
elm_text1[
|
|
30
|
-
|
|
29
|
+
elm_text1 = root.element(id: "text1")
|
|
30
|
+
# elm_text1.attr(value: 'めも')
|
|
31
|
+
elm_text1["value"] = "めも"
|
|
32
|
+
# elm_text1.attr(disabled: true)
|
|
33
|
+
elm_text1["disabled"] = true
|
|
34
|
+
# elm_text1.attr(required: true)
|
|
35
|
+
elm_text1["required"] = true
|
|
31
36
|
# map = elm_text1.attr_map
|
|
32
37
|
# map.names.each { |item|
|
|
33
38
|
# puts item
|
|
@@ -46,33 +51,39 @@ elm_text1['required'] = true # elm_text1.attr(required: true)
|
|
|
46
51
|
# puts elm_option1['selected'] # puts elm_option1.attr("selected")
|
|
47
52
|
# puts elm_text1['readonly'] # puts elm_text1.attr("readonly")
|
|
48
53
|
|
|
49
|
-
elm_select2 = root.element("select",id: "select2")
|
|
54
|
+
elm_select2 = root.element("select", id: "select2")
|
|
50
55
|
elm_select2["multiple"] = true
|
|
51
|
-
elm_option2 = elm_select2.element("option",id: "option2")
|
|
52
|
-
co_elm = elm_option2.element
|
|
56
|
+
elm_option2 = elm_select2.element("option", id: "option2")
|
|
57
|
+
co_elm = elm_option2.element
|
|
53
58
|
10.times { |i|
|
|
54
|
-
if i == 1
|
|
55
|
-
|
|
59
|
+
if i == 1
|
|
60
|
+
# co_elm.attr(selected: true)
|
|
61
|
+
co_elm["selected"] = true
|
|
56
62
|
else
|
|
57
|
-
|
|
63
|
+
# co_elm.attr(selected: false)
|
|
64
|
+
co_elm["selected"] = false
|
|
58
65
|
end
|
|
59
|
-
|
|
60
|
-
co_elm[
|
|
61
|
-
|
|
66
|
+
# co_elm.attr(value: i)
|
|
67
|
+
co_elm["value"] = i
|
|
68
|
+
# co_elm.remove_attr("id")
|
|
69
|
+
co_elm["id"] = nil
|
|
70
|
+
# co_elm.content(i)
|
|
71
|
+
co_elm.content = i
|
|
62
72
|
co_elm.flash
|
|
63
73
|
}
|
|
64
74
|
|
|
65
|
-
elm_tr1 = root.element(
|
|
75
|
+
elm_tr1 = root.element("tr", id: "loop")
|
|
66
76
|
elm_ = elm_tr1.element
|
|
67
|
-
elm_dt1_ = elm_.element(id:
|
|
68
|
-
elm_dt2_ = elm_.element(id:
|
|
69
|
-
elm_dt3_ = elm_.element(id:
|
|
77
|
+
elm_dt1_ = elm_.element(id: "aa")
|
|
78
|
+
elm_dt2_ = elm_.element(id: "bb")
|
|
79
|
+
elm_dt3_ = elm_.element(id: "cc")
|
|
70
80
|
10.times { |i|
|
|
71
|
-
elm_[
|
|
81
|
+
elm_["loop"] = i
|
|
72
82
|
elm_dt1 = elm_dt1_.clone
|
|
73
83
|
elm_dt2 = elm_dt2_.clone
|
|
74
84
|
elm_dt3 = elm_dt3_.clone
|
|
75
|
-
|
|
85
|
+
# elm_dt1.content("<>\"' \n" << i.to_s)
|
|
86
|
+
elm_dt1.content = i
|
|
76
87
|
elm_dt2.content = i
|
|
77
88
|
elm_dt3.content = i
|
|
78
89
|
elm_.flash
|
|
@@ -82,9 +93,9 @@ root.flash
|
|
|
82
93
|
|
|
83
94
|
endTime = Time.new.to_f
|
|
84
95
|
|
|
85
|
-
puts
|
|
96
|
+
puts(root.document)
|
|
86
97
|
|
|
87
|
-
puts
|
|
88
|
-
puts
|
|
98
|
+
puts("charset:#{root.charset}")
|
|
99
|
+
puts("content-type:#{root.content_type}")
|
|
89
100
|
|
|
90
|
-
puts
|
|
101
|
+
puts("" + (endTime - startTime).to_s + " sec")
|
data/demo/xhtml4.rb
CHANGED
|
@@ -3,19 +3,21 @@
|
|
|
3
3
|
# frozen_string_literal: true
|
|
4
4
|
|
|
5
5
|
# require 'rubygems'
|
|
6
|
-
require
|
|
6
|
+
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::ElementFactory.link(:xhtml4,
|
|
9
|
-
root = Meteor::ElementFactory.element(
|
|
8
|
+
Meteor::ElementFactory.link(:xhtml4, "ml/sample_xhtml4.html", "UTF-8")
|
|
9
|
+
root = Meteor::ElementFactory.element("/ml/sample_xhtml4")
|
|
10
10
|
|
|
11
11
|
startTime = Time.new.to_f
|
|
12
12
|
|
|
13
|
-
elm_hello = root.element("id","hello")
|
|
14
|
-
|
|
13
|
+
elm_hello = root.element("id", "hello")
|
|
14
|
+
# elm_hello.attr(class: "red")
|
|
15
|
+
elm_hello["class"] = "red"
|
|
15
16
|
# elm_hello['class'] = nil # elm_hello.remove_attr('class')
|
|
16
17
|
|
|
17
18
|
elm_hello2 = root.element(id: "hello2")
|
|
18
|
-
|
|
19
|
+
# elm_hello2.content("Hello,Tester")
|
|
20
|
+
elm_hello2.content = "Hello,Tester"
|
|
19
21
|
# elm_hello2.remove
|
|
20
22
|
|
|
21
23
|
# elm_hello3 = root.cxtag("hello3")
|
|
@@ -33,7 +35,8 @@ elm_hello2.content = "Hello,Tester" # elm_hello2.content("Hello,Tester")
|
|
|
33
35
|
# }
|
|
34
36
|
|
|
35
37
|
elm_radio1 = root.element("input", id: "radio1", type: "radio")
|
|
36
|
-
|
|
38
|
+
# elm_radio1.attribute(checked: true)
|
|
39
|
+
elm_radio1["checked"] = true
|
|
37
40
|
|
|
38
41
|
# elm_select1 = root.element("select",id: "select1")
|
|
39
42
|
# elm_select1 = root.element("select")
|
|
@@ -45,33 +48,39 @@ elm_radio1['checked'] = true # elm_radio1.attribute(checked: true)
|
|
|
45
48
|
# puts elm_option1['selected'] # puts elm_option1.attr("selected")
|
|
46
49
|
# puts elm_option1['readonly'] # puts elm_text1.attr("readonly")
|
|
47
50
|
|
|
48
|
-
elm_select2 = root.element("select",id: "select2")
|
|
51
|
+
elm_select2 = root.element("select", id: "select2")
|
|
49
52
|
elm_select2["multiple"] = true
|
|
50
|
-
elm_option2 = elm_select2.element("option",id: "option2")
|
|
51
|
-
co_elm = elm_option2.element
|
|
53
|
+
elm_option2 = elm_select2.element("option", id: "option2")
|
|
54
|
+
co_elm = elm_option2.element
|
|
52
55
|
10.times { |i|
|
|
53
|
-
if i == 1
|
|
54
|
-
|
|
56
|
+
if i == 1
|
|
57
|
+
# co_elm.attr(selected: true)
|
|
58
|
+
co_elm["selected"] = true
|
|
55
59
|
else
|
|
56
|
-
|
|
60
|
+
# co_elm.attr(selected: false)
|
|
61
|
+
co_elm["selected"] = false
|
|
57
62
|
end
|
|
58
|
-
|
|
59
|
-
co_elm[
|
|
60
|
-
|
|
63
|
+
# co_elm.attr(value: i)
|
|
64
|
+
co_elm["value"] = i
|
|
65
|
+
# co_elm.remove_attr("id")
|
|
66
|
+
co_elm["id"] = nil
|
|
67
|
+
# co_elm.content(i)
|
|
68
|
+
co_elm.content = i
|
|
61
69
|
co_elm.flash
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
elm_tr1 = root.element(
|
|
72
|
+
elm_tr1 = root.element("tr", id: "loop")
|
|
65
73
|
elm_ = elm_tr1.element
|
|
66
|
-
elm_dt1_ = elm_.element(id:
|
|
67
|
-
elm_dt2_ = elm_.element(id:
|
|
68
|
-
elm_dt3_ = elm_.element(id:
|
|
74
|
+
elm_dt1_ = elm_.element(id: "aa")
|
|
75
|
+
elm_dt2_ = elm_.element(id: "bb")
|
|
76
|
+
elm_dt3_ = elm_.element(id: "cc")
|
|
69
77
|
10.times { |i|
|
|
70
|
-
elm_[
|
|
78
|
+
elm_["loop"] = i
|
|
71
79
|
elm_dt1 = elm_dt1_.clone
|
|
72
80
|
elm_dt2 = elm_dt2_.clone
|
|
73
81
|
elm_dt3 = elm_dt3_.clone
|
|
74
|
-
|
|
82
|
+
# elm_dt1.content("<>\"' \n" << i.to_s)
|
|
83
|
+
elm_dt1.content = i
|
|
75
84
|
elm_dt2.content = i
|
|
76
85
|
elm_dt3.content = i
|
|
77
86
|
elm_.flash
|
|
@@ -81,9 +90,9 @@ root.flash
|
|
|
81
90
|
|
|
82
91
|
endTime = Time.new.to_f
|
|
83
92
|
|
|
84
|
-
puts
|
|
93
|
+
puts(root.document)
|
|
85
94
|
|
|
86
|
-
puts
|
|
87
|
-
puts
|
|
95
|
+
puts("charset:#{root.charset}")
|
|
96
|
+
puts("content-type:#{root.content_type}")
|
|
88
97
|
|
|
89
|
-
puts
|
|
98
|
+
puts("" + (endTime - startTime).to_s + " sec")
|
data/demo/xml.rb
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
# frozen_string_literal: true
|
|
4
4
|
|
|
5
5
|
# require 'rubygems'
|
|
6
|
-
require
|
|
6
|
+
require "meteor"
|
|
7
7
|
|
|
8
|
-
Meteor::ElementFactory.link(Meteor::XML,
|
|
9
|
-
root = Meteor::ElementFactory.element(
|
|
8
|
+
Meteor::ElementFactory.link(Meteor::XML, "ml/sample.xml", "UTF-8")
|
|
9
|
+
root = Meteor::ElementFactory.element("/ml/sample")
|
|
10
10
|
|
|
11
11
|
start_time = Time.new.to_f
|
|
12
12
|
|
|
@@ -21,7 +21,8 @@ start_time = Time.new.to_f
|
|
|
21
21
|
# puts elm_.attributes
|
|
22
22
|
# puts elm_.mixed_content
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
# elm1 = root.element(manbo: "manbo")
|
|
25
|
+
elm1 = root.element("test", manbo: "manbo")
|
|
25
26
|
# elm2 = root.element(id: "aa", id2: "bb") # elm2 = root.element(id: "aa")
|
|
26
27
|
# elm3 = root.element("potato", id: "aa")
|
|
27
28
|
# elm4 = root.element("potato", id: "aa", id2: "bb") # elm4 = root.element("potato", id2: "bb")
|
|
@@ -58,11 +59,11 @@ elm7 = root.element("kobe")
|
|
|
58
59
|
# }
|
|
59
60
|
|
|
60
61
|
elm_ = root.element(elm1)
|
|
61
|
-
elm5_ = elm_.element(
|
|
62
|
+
elm5_ = elm_.element("tech")
|
|
62
63
|
10.times do |i|
|
|
63
|
-
elm_[
|
|
64
|
+
elm_["manbo"] = i.to_s
|
|
64
65
|
elm5 = elm5_.clone
|
|
65
|
-
elm5[
|
|
66
|
+
elm5["mono"] = i.to_s
|
|
66
67
|
elm5.content = i.to_s
|
|
67
68
|
elm_.flash
|
|
68
69
|
end
|
|
@@ -76,9 +77,10 @@ end
|
|
|
76
77
|
elm_ = root.element(elm7)
|
|
77
78
|
|
|
78
79
|
10.times { |i|
|
|
79
|
-
elm_["momo"]= i
|
|
80
|
+
elm_["momo"] = i
|
|
80
81
|
elm_["eco"] = "えま"
|
|
81
|
-
|
|
82
|
+
# elm_["content"] = i.to_s
|
|
83
|
+
elm_.content = i
|
|
82
84
|
elm_.flash
|
|
83
85
|
}
|
|
84
86
|
|
|
@@ -95,24 +97,27 @@ root.flash
|
|
|
95
97
|
|
|
96
98
|
end_time = Time.new.to_f
|
|
97
99
|
|
|
98
|
-
puts
|
|
100
|
+
puts(root.document)
|
|
99
101
|
|
|
100
102
|
# elms = root.elements("potato2")
|
|
101
103
|
## elms = root.elements("kobe")
|
|
102
104
|
# elms = root.elements("potato")
|
|
103
105
|
|
|
104
|
-
|
|
105
|
-
elms.
|
|
106
|
-
|
|
107
|
-
puts
|
|
108
|
-
puts
|
|
109
|
-
puts
|
|
110
|
-
puts
|
|
111
|
-
puts
|
|
112
|
-
puts
|
|
106
|
+
# elms = root.css('test')
|
|
107
|
+
elms = root.elements("test")
|
|
108
|
+
elms.each { |elm, i|
|
|
109
|
+
puts("-------")
|
|
110
|
+
puts("doc----")
|
|
111
|
+
puts(elm.document)
|
|
112
|
+
puts("attrs--")
|
|
113
|
+
puts(elm.attributes)
|
|
114
|
+
puts("mixed--")
|
|
115
|
+
puts(elm.mixed_content)
|
|
113
116
|
}
|
|
114
117
|
|
|
115
|
-
puts
|
|
118
|
+
puts("content-type:#{root.content_type}")
|
|
119
|
+
|
|
120
|
+
puts("" + (end_time - start_time).to_s + " sec")
|
|
116
121
|
|
|
117
122
|
# start_time = Time.new.to_f
|
|
118
123
|
# obj = eval("\"#{elm3.name}\"")
|
data/lib/meteor/attribute_map.rb
CHANGED
|
@@ -14,12 +14,12 @@ module Meteor
|
|
|
14
14
|
#
|
|
15
15
|
def initialize(*args)
|
|
16
16
|
case args.length
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
when ZERO
|
|
18
|
+
initialize_0
|
|
19
|
+
when ONE
|
|
20
|
+
initialize_1(args[0])
|
|
21
|
+
else
|
|
22
|
+
raise ArgumentError
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -59,6 +59,7 @@ module Meteor
|
|
|
59
59
|
attr.changed = true
|
|
60
60
|
attr.removed = false
|
|
61
61
|
end
|
|
62
|
+
|
|
62
63
|
@map[name] = attr
|
|
63
64
|
else
|
|
64
65
|
attr = @map[name]
|
|
@@ -66,6 +67,7 @@ module Meteor
|
|
|
66
67
|
attr.changed = true
|
|
67
68
|
attr.removed = false
|
|
68
69
|
end
|
|
70
|
+
|
|
69
71
|
attr.value = value
|
|
70
72
|
end
|
|
71
73
|
end
|