meteor 0.9.11 → 0.9.13
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/.gitignore +1 -1
- data/ChangeLog +8 -0
- data/Gemfile.lock +2 -2
- data/README.md +5 -3
- data/Rakefile +1 -1
- data/demo/html.rb +42 -38
- data/demo/html4.rb +54 -50
- data/demo/ml/sample.xml +11 -11
- data/demo/ml/sample_html.html +25 -24
- data/demo/ml/sample_html4.html +38 -38
- data/demo/ml/sample_xhtml.html +25 -24
- data/demo/ml/sample_xhtml4.html +24 -24
- data/demo/xhtml.rb +40 -36
- data/demo/xhtml4.rb +38 -34
- data/demo/xml.rb +64 -63
- data/lib/meteor/attribute.rb +33 -0
- data/lib/meteor/attribute_map.rb +146 -0
- data/lib/meteor/core/kernel.rb +2182 -0
- data/lib/meteor/core/util/pattern_cache.rb +107 -0
- data/lib/meteor/element.rb +532 -0
- data/lib/meteor/element_factory.rb +68 -0
- data/lib/meteor/exception/no_such_element_exception.rb +84 -0
- data/lib/meteor/ml/html/parser_impl.rb +142 -0
- data/lib/meteor/ml/html4/parser_impl.rb +684 -0
- data/lib/meteor/ml/xhtml/parser_impl.rb +139 -0
- data/lib/meteor/ml/xhtml4/parser_impl.rb +398 -0
- data/lib/meteor/ml/xml/parser_impl.rb +160 -0
- data/lib/meteor/parser.rb +15 -0
- data/lib/meteor/parser_factory.rb +493 -0
- data/lib/meteor/root_element.rb +24 -0
- data/lib/meteor.rb +22 -5591
- data/meteor.gemspec +4 -4
- metadata +21 -6
data/demo/ml/sample_xhtml4.html
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<html lang="ja">
|
|
3
|
-
<head>
|
|
4
|
-
<title>HTMLテスト</title>
|
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
6
|
-
</head>
|
|
3
|
+
<head>
|
|
4
|
+
<title>HTMLテスト</title>
|
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
6
|
+
</head>
|
|
7
7
|
|
|
8
|
-
<body>
|
|
9
|
-
<div id="hello" class="black">Hello,World</div>
|
|
10
|
-
<div id="hello2">Hello,World</div>
|
|
11
|
-
<!-- @quark id="hello3" -->Hello,World<!-- /@quark -->
|
|
12
|
-
<form>
|
|
13
|
-
<input id="text1" type="text" />
|
|
8
|
+
<body>
|
|
9
|
+
<div id="hello" class="black">Hello,World</div>
|
|
10
|
+
<div id="hello2">Hello,World</div>
|
|
11
|
+
<!-- @quark id="hello3" -->Hello,World<!-- /@quark -->
|
|
12
|
+
<form>
|
|
13
|
+
<input id="text1" name="text1" type="text" />
|
|
14
14
|
|
|
15
|
-
<input id="radio1" type="radio" />
|
|
15
|
+
<input id="radio1" name="radio1" type="radio" />
|
|
16
16
|
|
|
17
|
-
<select>
|
|
18
|
-
<option id="option1">オプション</option>
|
|
19
|
-
</select>
|
|
17
|
+
<select>
|
|
18
|
+
<option id="option1">オプション</option>
|
|
19
|
+
</select>
|
|
20
20
|
|
|
21
|
-
<select id="select2">
|
|
22
|
-
<option id="option2">オプション</option>
|
|
23
|
-
</select>
|
|
24
|
-
</form>
|
|
21
|
+
<select id="select2" name="select2">
|
|
22
|
+
<option id="option2">オプション</option>
|
|
23
|
+
</select>
|
|
24
|
+
</form>
|
|
25
25
|
|
|
26
|
-
<table>
|
|
27
|
-
<tr id="loop">
|
|
28
|
-
<td id="aa"></td><td id="bb"></td><td id="cc"></td>
|
|
29
|
-
</tr>
|
|
30
|
-
</table>
|
|
26
|
+
<table>
|
|
27
|
+
<tr id="loop">
|
|
28
|
+
<td id="aa"></td><td id="bb"></td><td id="cc"></td>
|
|
29
|
+
</tr>
|
|
30
|
+
</table>
|
|
31
31
|
|
|
32
|
-
</body>
|
|
32
|
+
</body>
|
|
33
33
|
</html>
|
data/demo/xhtml.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!bin ruby
|
|
2
2
|
# -* coding: UTF-8 -*-
|
|
3
|
+
# frozen_string_literal: true
|
|
3
4
|
|
|
4
|
-
#require 'rubygems'
|
|
5
|
+
# require 'rubygems'
|
|
5
6
|
require 'meteor'
|
|
6
7
|
|
|
7
8
|
Meteor::ElementFactory.link(:xhtml,'ml/sample_xhtml.html', 'UTF-8')
|
|
@@ -10,40 +11,40 @@ root = Meteor::ElementFactory.element('/ml/sample_xhtml')
|
|
|
10
11
|
startTime = Time.new.to_f
|
|
11
12
|
|
|
12
13
|
elm_hello = root.element(id: 'hello')
|
|
13
|
-
elm_hello['class'] = 'red' #elm_hello.attr(class: "red")
|
|
14
|
-
#elm_hello['class'] = nil #elm_hello.remove_attr('class')
|
|
15
|
-
#elm_hello.attr(class: nil)
|
|
14
|
+
elm_hello['class'] = 'red' # elm_hello.attr(class: "red")
|
|
15
|
+
# elm_hello['class'] = nil # elm_hello.remove_attr('class')
|
|
16
|
+
# elm_hello.attr(class: nil)
|
|
16
17
|
|
|
17
18
|
elm_hello2 = root.element(id: 'hello2')
|
|
18
|
-
elm_hello2.content = "Hello,Tester" #elm_hello2.content("Hello,Tester")
|
|
19
|
-
#elm_hello2.remove
|
|
19
|
+
elm_hello2.content = "Hello,Tester" # elm_hello2.content("Hello,Tester")
|
|
20
|
+
# elm_hello2.remove
|
|
20
21
|
|
|
21
|
-
#elm_hello3 = root.cxtag("hello3")
|
|
22
|
-
#elm_hello3.content = "Hello,Hello\ntt" #elm_hello3.content("Hello,Hello\ntt")
|
|
23
|
-
#puts elm_hello3.content
|
|
24
|
-
#puts elm_hello3.mixed_content
|
|
22
|
+
# elm_hello3 = root.cxtag("hello3")
|
|
23
|
+
# elm_hello3.content = "Hello,Hello\ntt" # elm_hello3.content("Hello,Hello\ntt")
|
|
24
|
+
# puts elm_hello3.content
|
|
25
|
+
# puts elm_hello3.mixed_content
|
|
25
26
|
|
|
26
27
|
elm_text1 = root.element(id: 'text1')
|
|
27
|
-
elm_text1['value'] = 'めも' #elm_text1.attr(value: 'めも')
|
|
28
|
-
elm_text1['disabled'] = true #elm_text1.attr(disabled: true)
|
|
29
|
-
elm_text1['required'] = true #elm_text1.attr(required: true)
|
|
30
|
-
#map = elm_text1.attr_map
|
|
31
|
-
#map.names.each { |item|
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#}
|
|
35
|
-
|
|
36
|
-
#elm_radio1 = root.element("input",id: "radio1", type: "radio")
|
|
37
|
-
#elm_radio1['checked'] = true #elm_radio1.attr(checked: true)
|
|
38
|
-
|
|
39
|
-
#elm_select1 = root.element("select",id: "select1")
|
|
40
|
-
#elm_select1 = root.element("select")
|
|
41
|
-
#elm_select1['multiple'] = true #elm_select1.attr(multiple: true)
|
|
42
|
-
#puts elm_select1['multiple'] #puts elm_select1.attr("multiple")
|
|
43
|
-
#elm_option1 = root.element("option",id: "option1")
|
|
44
|
-
#elm_option1['selected'] = true #elm_option1.attr(selected: true)
|
|
45
|
-
#puts elm_option1['selected'] #puts elm_option1.attr("selected")
|
|
46
|
-
#puts elm_text1['readonly'] #puts elm_text1.attr("readonly")
|
|
28
|
+
elm_text1['value'] = 'めも' # elm_text1.attr(value: 'めも')
|
|
29
|
+
elm_text1['disabled'] = true # elm_text1.attr(disabled: true)
|
|
30
|
+
elm_text1['required'] = true # elm_text1.attr(required: true)
|
|
31
|
+
# map = elm_text1.attr_map
|
|
32
|
+
# map.names.each { |item|
|
|
33
|
+
# puts item
|
|
34
|
+
# puts map.fetch(item)
|
|
35
|
+
# }
|
|
36
|
+
|
|
37
|
+
# elm_radio1 = root.element("input",id: "radio1", type: "radio")
|
|
38
|
+
# elm_radio1['checked'] = true # elm_radio1.attr(checked: true)
|
|
39
|
+
|
|
40
|
+
# elm_select1 = root.element("select",id: "select1")
|
|
41
|
+
# elm_select1 = root.element("select")
|
|
42
|
+
# elm_select1['multiple'] = true # elm_select1.attr(multiple: true)
|
|
43
|
+
# puts elm_select1['multiple'] # puts elm_select1.attr("multiple")
|
|
44
|
+
# elm_option1 = root.element("option",id: "option1")
|
|
45
|
+
# elm_option1['selected'] = true # elm_option1.attr(selected: true)
|
|
46
|
+
# puts elm_option1['selected'] # puts elm_option1.attr("selected")
|
|
47
|
+
# puts elm_text1['readonly'] # puts elm_text1.attr("readonly")
|
|
47
48
|
|
|
48
49
|
elm_select2 = root.element("select",id: "select2")
|
|
49
50
|
elm_select2["multiple"] = true
|
|
@@ -51,13 +52,13 @@ elm_option2 = elm_select2.element("option",id: "option2")
|
|
|
51
52
|
co_elm = elm_option2.element()
|
|
52
53
|
10.times { |i|
|
|
53
54
|
if i == 1 then
|
|
54
|
-
co_elm['selected'] = true #co_elm.attr(selected: true)
|
|
55
|
+
co_elm['selected'] = true # co_elm.attr(selected: true)
|
|
55
56
|
else
|
|
56
|
-
co_elm['selected'] = false #co_elm.attr(selected: false)
|
|
57
|
+
co_elm['selected'] = false # co_elm.attr(selected: false)
|
|
57
58
|
end
|
|
58
|
-
co_elm['value'] = i #co_elm.attr(value: i)
|
|
59
|
-
co_elm['id'] = nil #co_elm.remove_attr("id")
|
|
60
|
-
co_elm.content = i #co_elm.content(i)
|
|
59
|
+
co_elm['value'] = i # co_elm.attr(value: i)
|
|
60
|
+
co_elm['id'] = nil # co_elm.remove_attr("id")
|
|
61
|
+
co_elm.content = i # co_elm.content(i)
|
|
61
62
|
co_elm.flash
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -71,7 +72,7 @@ elm_dt3_ = elm_.element(id: 'cc')
|
|
|
71
72
|
elm_dt1 = elm_dt1_.clone
|
|
72
73
|
elm_dt2 = elm_dt2_.clone
|
|
73
74
|
elm_dt3 = elm_dt3_.clone
|
|
74
|
-
elm_dt1.content = i #elm_dt1.content("<>\"' \n" << i.to_s)
|
|
75
|
+
elm_dt1.content = i # elm_dt1.content("<>\"' \n" << i.to_s)
|
|
75
76
|
elm_dt2.content = i
|
|
76
77
|
elm_dt3.content = i
|
|
77
78
|
elm_.flash
|
|
@@ -83,4 +84,7 @@ endTime = Time.new.to_f
|
|
|
83
84
|
|
|
84
85
|
puts root.document
|
|
85
86
|
|
|
87
|
+
puts "charset:#{root.charset}"
|
|
88
|
+
puts "content-type:#{root.content_type}"
|
|
89
|
+
|
|
86
90
|
puts '' + (endTime - startTime).to_s + ' sec'
|
data/demo/xhtml4.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!bin ruby
|
|
2
2
|
# -* coding: UTF-8 -*-
|
|
3
|
+
# frozen_string_literal: true
|
|
3
4
|
|
|
4
|
-
#require 'rubygems'
|
|
5
|
+
# require 'rubygems'
|
|
5
6
|
require 'meteor'
|
|
6
7
|
|
|
7
8
|
Meteor::ElementFactory.link(:xhtml4,'ml/sample_xhtml4.html', 'UTF-8')
|
|
@@ -10,39 +11,39 @@ root = Meteor::ElementFactory.element('/ml/sample_xhtml4')
|
|
|
10
11
|
startTime = Time.new.to_f
|
|
11
12
|
|
|
12
13
|
elm_hello = root.element("id","hello")
|
|
13
|
-
elm_hello['class'] = 'red' #elm_hello.attr(class: "red")
|
|
14
|
-
#elm_hello['class'] = nil #elm_hello.remove_attr('class')
|
|
14
|
+
elm_hello['class'] = 'red' # elm_hello.attr(class: "red")
|
|
15
|
+
# elm_hello['class'] = nil # elm_hello.remove_attr('class')
|
|
15
16
|
|
|
16
17
|
elm_hello2 = root.element(id: "hello2")
|
|
17
|
-
elm_hello2.content = "Hello,Tester" #elm_hello2.content("Hello,Tester")
|
|
18
|
-
#elm_hello2.remove
|
|
19
|
-
|
|
20
|
-
#elm_hello3 = root.cxtag("hello3")
|
|
21
|
-
#elm_hello3.content = "Hello,Hello\ntt" #elm_hello3.content("Hello,Hello\ntt")
|
|
22
|
-
#puts elm_hello3.content
|
|
23
|
-
#puts elm_hello3.mixed_content
|
|
24
|
-
|
|
25
|
-
#elm_text1 = root.element(id: "text1")
|
|
26
|
-
#elm_text1['value'] = 'めも' #elm_text1.attr(value: 'めも')
|
|
27
|
-
#elm_text1['disabled'] = true #elm_text1.attr(disabled: true)
|
|
28
|
-
#map = elm_text1.attr_map
|
|
29
|
-
#map.names.each { |item|
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#}
|
|
18
|
+
elm_hello2.content = "Hello,Tester" # elm_hello2.content("Hello,Tester")
|
|
19
|
+
# elm_hello2.remove
|
|
20
|
+
|
|
21
|
+
# elm_hello3 = root.cxtag("hello3")
|
|
22
|
+
# elm_hello3.content = "Hello,Hello\ntt" # elm_hello3.content("Hello,Hello\ntt")
|
|
23
|
+
# puts elm_hello3.content
|
|
24
|
+
# puts elm_hello3.mixed_content
|
|
25
|
+
|
|
26
|
+
# elm_text1 = root.element(id: "text1")
|
|
27
|
+
# elm_text1['value'] = 'めも' # elm_text1.attr(value: 'めも')
|
|
28
|
+
# elm_text1['disabled'] = true # elm_text1.attr(disabled: true)
|
|
29
|
+
# map = elm_text1.attr_map
|
|
30
|
+
# map.names.each { |item|
|
|
31
|
+
# puts item
|
|
32
|
+
# puts map.fetch(item)
|
|
33
|
+
# }
|
|
33
34
|
|
|
34
35
|
elm_radio1 = root.element("input", id: "radio1", type: "radio")
|
|
35
|
-
elm_radio1['checked'] = true #elm_radio1.attribute(checked: true)
|
|
36
|
+
elm_radio1['checked'] = true # elm_radio1.attribute(checked: true)
|
|
36
37
|
|
|
37
|
-
#elm_select1 = root.element("select",id: "select1")
|
|
38
|
-
#elm_select1 = root.element("select")
|
|
39
|
-
#elm_select1('multiple') = true #elm_select1.attr(multiple: true)
|
|
40
|
-
#puts elm_select1['multiple'] #puts elm_select1.attr("multiple")
|
|
38
|
+
# elm_select1 = root.element("select",id: "select1")
|
|
39
|
+
# elm_select1 = root.element("select")
|
|
40
|
+
# elm_select1('multiple') = true # elm_select1.attr(multiple: true)
|
|
41
|
+
# puts elm_select1['multiple'] # puts elm_select1.attr("multiple")
|
|
41
42
|
|
|
42
|
-
#elm_option1 = root.element("option",id: "option1")
|
|
43
|
-
#elm_option1['selected'] = true #elm_option1.attr(selected: true)
|
|
44
|
-
#puts elm_option1['selected'] #puts elm_option1.attr("selected")
|
|
45
|
-
#puts elm_option1['readonly'] #puts elm_text1.attr("readonly")
|
|
43
|
+
# elm_option1 = root.element("option",id: "option1")
|
|
44
|
+
# elm_option1['selected'] = true # elm_option1.attr(selected: true)
|
|
45
|
+
# puts elm_option1['selected'] # puts elm_option1.attr("selected")
|
|
46
|
+
# puts elm_option1['readonly'] # puts elm_text1.attr("readonly")
|
|
46
47
|
|
|
47
48
|
elm_select2 = root.element("select",id: "select2")
|
|
48
49
|
elm_select2["multiple"] = true
|
|
@@ -50,13 +51,13 @@ elm_option2 = elm_select2.element("option",id: "option2")
|
|
|
50
51
|
co_elm = elm_option2.element()
|
|
51
52
|
10.times { |i|
|
|
52
53
|
if i == 1 then
|
|
53
|
-
co_elm['selected'] = true #co_elm.attr(selected: true)
|
|
54
|
+
co_elm['selected'] = true # co_elm.attr(selected: true)
|
|
54
55
|
else
|
|
55
|
-
co_elm['selected'] = false #co_elm.attr(selected: false)
|
|
56
|
+
co_elm['selected'] = false # co_elm.attr(selected: false)
|
|
56
57
|
end
|
|
57
|
-
co_elm['value'] = i #co_elm.attr(value: i)
|
|
58
|
-
co_elm['id'] = nil #co_elm.remove_attr("id")
|
|
59
|
-
co_elm.content = i #co_elm.content(i)
|
|
58
|
+
co_elm['value'] = i # co_elm.attr(value: i)
|
|
59
|
+
co_elm['id'] = nil # co_elm.remove_attr("id")
|
|
60
|
+
co_elm.content = i # co_elm.content(i)
|
|
60
61
|
co_elm.flash
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -70,7 +71,7 @@ elm_dt3_ = elm_.element(id: 'cc')
|
|
|
70
71
|
elm_dt1 = elm_dt1_.clone
|
|
71
72
|
elm_dt2 = elm_dt2_.clone
|
|
72
73
|
elm_dt3 = elm_dt3_.clone
|
|
73
|
-
elm_dt1.content = i #elm_dt1.content("<>\"' \n" << i.to_s)
|
|
74
|
+
elm_dt1.content = i # elm_dt1.content("<>\"' \n" << i.to_s)
|
|
74
75
|
elm_dt2.content = i
|
|
75
76
|
elm_dt3.content = i
|
|
76
77
|
elm_.flash
|
|
@@ -82,4 +83,7 @@ endTime = Time.new.to_f
|
|
|
82
83
|
|
|
83
84
|
puts root.document
|
|
84
85
|
|
|
86
|
+
puts "charset:#{root.charset}"
|
|
87
|
+
puts "content-type:#{root.content_type}"
|
|
88
|
+
|
|
85
89
|
puts '' + (endTime - startTime).to_s + ' sec'
|
data/demo/xml.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!bin ruby
|
|
2
2
|
# -* coding: UTF-8 -*-
|
|
3
|
+
# frozen_string_literal: true
|
|
3
4
|
|
|
4
|
-
#require 'rubygems'
|
|
5
|
+
# require 'rubygems'
|
|
5
6
|
require 'meteor'
|
|
6
7
|
|
|
7
8
|
Meteor::ElementFactory.link(Meteor::XML,'ml/sample.xml', 'UTF-8')
|
|
@@ -9,52 +10,52 @@ root = Meteor::ElementFactory.element('/ml/sample')
|
|
|
9
10
|
|
|
10
11
|
start_time = Time.new.to_f
|
|
11
12
|
|
|
12
|
-
#elm_ = root.element('kobe')
|
|
13
|
-
#puts elm_.name
|
|
14
|
-
#puts elm_.attributes
|
|
15
|
-
#puts elm_.mixed_content
|
|
16
|
-
#puts elm_.text
|
|
13
|
+
# elm_ = root.element('kobe')
|
|
14
|
+
# puts elm_.name
|
|
15
|
+
# puts elm_.attributes
|
|
16
|
+
# puts elm_.mixed_content
|
|
17
|
+
# puts elm_.text
|
|
17
18
|
|
|
18
|
-
#elm_ = root.element('test')
|
|
19
|
-
#puts elm_.name
|
|
20
|
-
#puts elm_.attributes
|
|
21
|
-
#puts elm_.mixed_content
|
|
19
|
+
# elm_ = root.element('test')
|
|
20
|
+
# puts elm_.name
|
|
21
|
+
# puts elm_.attributes
|
|
22
|
+
# puts elm_.mixed_content
|
|
22
23
|
|
|
23
|
-
elm1 = root.element('test', manbo: 'manbo') #elm1 = root.element(manbo: "manbo")
|
|
24
|
-
#elm2 = root.element(id: "aa", id2: "bb") #elm2 = root.element(id: "aa")
|
|
25
|
-
#elm3 = root.element("potato", id: "aa")
|
|
26
|
-
#elm4 = root.element("potato", id: "aa", id2: "bb") #elm4 = root.element("potato", id2: "bb")
|
|
24
|
+
elm1 = root.element('test', manbo: 'manbo') # elm1 = root.element(manbo: "manbo")
|
|
25
|
+
# elm2 = root.element(id: "aa", id2: "bb") # elm2 = root.element(id: "aa")
|
|
26
|
+
# elm3 = root.element("potato", id: "aa")
|
|
27
|
+
# elm4 = root.element("potato", id: "aa", id2: "bb") # elm4 = root.element("potato", id2: "bb")
|
|
27
28
|
|
|
28
29
|
elm7 = root.element("kobe")
|
|
29
|
-
#elm7 = root.element(momo: "mono")
|
|
30
|
-
#elm8 = root.element(manbo: "mango")
|
|
31
|
-
#elm8 = root.element(momo: "momo")
|
|
30
|
+
# elm7 = root.element(momo: "mono")
|
|
31
|
+
# elm8 = root.element(manbo: "mango")
|
|
32
|
+
# elm8 = root.element(momo: "momo")
|
|
32
33
|
|
|
33
|
-
#elm9 = root.element("hamachi",id: "aa",id2: 'bb')
|
|
34
|
-
#elm_c1 = root.cxtag("cs")
|
|
34
|
+
# elm9 = root.element("hamachi",id: "aa",id2: 'bb')
|
|
35
|
+
# elm_c1 = root.cxtag("cs")
|
|
35
36
|
|
|
36
|
-
#puts elm8.name
|
|
37
|
-
#puts elm8.attributes
|
|
38
|
-
#puts elm8.mixed_content
|
|
37
|
+
# puts elm8.name
|
|
38
|
+
# puts elm8.attributes
|
|
39
|
+
# puts elm8.mixed_content
|
|
39
40
|
|
|
40
|
-
#elm1.attr(id2: "cc")
|
|
41
|
-
#elm1["id2"] = "cc"
|
|
41
|
+
# elm1.attr(id2: "cc")
|
|
42
|
+
# elm1["id2"] = "cc"
|
|
42
43
|
|
|
43
|
-
#elm8['mango'] = "mangoo" #elm8.attr(manbo: "mangoo")
|
|
44
|
-
#elm9.content = "\\1" #elm9.content("\\1")
|
|
44
|
+
# elm8['mango'] = "mangoo" # elm8.attr(manbo: "mangoo")
|
|
45
|
+
# elm9.content = "\\1" # elm9.content("\\1")
|
|
45
46
|
|
|
46
|
-
#elm2.attr(id3: 'cc')
|
|
47
|
+
# elm2.attr(id3: 'cc')
|
|
47
48
|
|
|
48
|
-
#elm3['id3'] = 'cc' #elm3.attr(id3: 'cc')
|
|
49
|
-
#elm3['id3'] = 'cc' #elm4.attr(id3: 'cc')
|
|
50
|
-
#elm9['id3'] = 'cc' #elm9.attr(id3: 'cc')
|
|
49
|
+
# elm3['id3'] = 'cc' # elm3.attr(id3: 'cc')
|
|
50
|
+
# elm3['id3'] = 'cc' # elm4.attr(id3: 'cc')
|
|
51
|
+
# elm9['id3'] = 'cc' # elm9.attr(id3: 'cc')
|
|
51
52
|
|
|
52
|
-
#co_elm = elm1.element()
|
|
53
|
-
#map = co_elm.attr_map
|
|
54
|
-
#map.names.each { |item|
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#}
|
|
53
|
+
# co_elm = elm1.element()
|
|
54
|
+
# map = co_elm.attr_map
|
|
55
|
+
# map.names.each { |item|
|
|
56
|
+
# puts item
|
|
57
|
+
# puts map.fetch(item)
|
|
58
|
+
# }
|
|
58
59
|
|
|
59
60
|
elm_ = root.element(elm1)
|
|
60
61
|
elm5_ = elm_.element('tech')
|
|
@@ -66,29 +67,29 @@ elm5_ = elm_.element('tech')
|
|
|
66
67
|
elm_.flash
|
|
67
68
|
end
|
|
68
69
|
|
|
69
|
-
#am3 = elm3.attr_map
|
|
70
|
-
#am3.names.each { |item|
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#}
|
|
70
|
+
# am3 = elm3.attr_map
|
|
71
|
+
# am3.names.each { |item|
|
|
72
|
+
# puts item
|
|
73
|
+
# puts am3.fetch(item)
|
|
74
|
+
# }
|
|
74
75
|
|
|
75
76
|
elm_ = root.element(elm7)
|
|
76
77
|
|
|
77
78
|
10.times { |i|
|
|
78
79
|
elm_["momo"]= i
|
|
79
80
|
elm_["eco"] = "えま"
|
|
80
|
-
elm_.content = i #elm_["content"] = i.to_s
|
|
81
|
+
elm_.content = i # elm_["content"] = i.to_s
|
|
81
82
|
elm_.flash
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
#co_elm = root.element(elm_c1)
|
|
85
|
+
# co_elm = root.element(elm_c1)
|
|
85
86
|
#
|
|
86
|
-
#10.times { |i|
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#}
|
|
87
|
+
# 10.times { |i|
|
|
88
|
+
# co_elm.content = i # co_elm.content(i)
|
|
89
|
+
# co_elm.flash
|
|
90
|
+
# }
|
|
90
91
|
|
|
91
|
-
#elm3['id3'] = 'dd' #elm3.attr(id3: 'dd')
|
|
92
|
+
# elm3['id3'] = 'dd' # elm3.attr(id3: 'dd')
|
|
92
93
|
|
|
93
94
|
root.flash
|
|
94
95
|
|
|
@@ -96,11 +97,11 @@ end_time = Time.new.to_f
|
|
|
96
97
|
|
|
97
98
|
puts root.document
|
|
98
99
|
|
|
99
|
-
#elms = root.elements("potato2")
|
|
100
|
-
##elms = root.elements("kobe")
|
|
101
|
-
#elms = root.elements("potato")
|
|
100
|
+
# elms = root.elements("potato2")
|
|
101
|
+
## elms = root.elements("kobe")
|
|
102
|
+
# elms = root.elements("potato")
|
|
102
103
|
|
|
103
|
-
elms = root.elements("test") #elms = root.css('test')
|
|
104
|
+
elms = root.elements("test") # elms = root.css('test')
|
|
104
105
|
elms.each{|elm, i|
|
|
105
106
|
puts '-------'
|
|
106
107
|
puts 'doc----'
|
|
@@ -113,14 +114,14 @@ elms.each{|elm, i|
|
|
|
113
114
|
|
|
114
115
|
puts '' + (end_time - start_time).to_s + ' sec'
|
|
115
116
|
|
|
116
|
-
#start_time = Time.new.to_f
|
|
117
|
-
#obj = eval("\"#{elm3.name}\"")
|
|
118
|
-
#end_time = Time.new.to_f
|
|
119
|
-
#puts '' + (end_time - start_time).to_s + ' sec'
|
|
120
|
-
#puts obj
|
|
121
|
-
|
|
122
|
-
#start_time = Time.new.to_f
|
|
123
|
-
#obj = elm3.name
|
|
124
|
-
#end_time = Time.new.to_f
|
|
125
|
-
#puts '' + (end_time - start_time).to_s + ' sec'
|
|
126
|
-
#puts obj
|
|
117
|
+
# start_time = Time.new.to_f
|
|
118
|
+
# obj = eval("\"#{elm3.name}\"")
|
|
119
|
+
# end_time = Time.new.to_f
|
|
120
|
+
# puts '' + (end_time - start_time).to_s + ' sec'
|
|
121
|
+
# puts obj
|
|
122
|
+
|
|
123
|
+
# start_time = Time.new.to_f
|
|
124
|
+
# obj = elm3.name
|
|
125
|
+
# end_time = Time.new.to_f
|
|
126
|
+
# puts '' + (end_time - start_time).to_s + ' sec'
|
|
127
|
+
# puts obj
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -* coding: UTF-8 -*-
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Meteor
|
|
5
|
+
#
|
|
6
|
+
# Attribute class (属性クラス)
|
|
7
|
+
#
|
|
8
|
+
# @!attribute [rw] name
|
|
9
|
+
# @return [String,Symbol] attribute name (名前)
|
|
10
|
+
# @!attribute [rw] value
|
|
11
|
+
# @return [String] attribute value (値)
|
|
12
|
+
# @!attribute [rw] changed
|
|
13
|
+
# @return [true,false] update flag (更新フラグ)
|
|
14
|
+
# @!attribute [rw] removed
|
|
15
|
+
# @return [true,false] deletion flag (削除フラグ)
|
|
16
|
+
#
|
|
17
|
+
class Attribute
|
|
18
|
+
attr_accessor :name
|
|
19
|
+
attr_accessor :value
|
|
20
|
+
attr_accessor :changed
|
|
21
|
+
attr_accessor :removed
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
## initializer (イニシャライザ)
|
|
25
|
+
##
|
|
26
|
+
# def initialize
|
|
27
|
+
# @name = nil
|
|
28
|
+
# @value = nil
|
|
29
|
+
# @changed = false
|
|
30
|
+
# @removed = false
|
|
31
|
+
# end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# -* coding: UTF-8 -*-
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Meteor
|
|
5
|
+
#
|
|
6
|
+
# Attribute Map Class (属性マップ クラス)
|
|
7
|
+
#
|
|
8
|
+
class AttributeMap
|
|
9
|
+
#
|
|
10
|
+
# initializer (イニシャライザ)
|
|
11
|
+
# @overload initialize
|
|
12
|
+
# @overload initialize(attr_map)
|
|
13
|
+
# @param [Meteor::AttributeMap] attr_map attribute map (属性マップ)
|
|
14
|
+
#
|
|
15
|
+
def initialize(*args)
|
|
16
|
+
case args.length
|
|
17
|
+
when ZERO
|
|
18
|
+
initialize_0
|
|
19
|
+
when ONE
|
|
20
|
+
initialize_1(args[0])
|
|
21
|
+
else
|
|
22
|
+
raise ArgumentError
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# initializer (イニシャライザ)
|
|
28
|
+
#
|
|
29
|
+
def initialize_0
|
|
30
|
+
@map = Hash.new
|
|
31
|
+
@recordable = false
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private :initialize_0
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# initializer (イニシャライザ)
|
|
38
|
+
# @param [Meteor::AttributeMap] attr_map attribute map (属性マップ)
|
|
39
|
+
#
|
|
40
|
+
def initialize_1(attr_map)
|
|
41
|
+
# @map = Marshal.load(Marshal.dump(attr_map.map))
|
|
42
|
+
@map = attr_map.map.dup
|
|
43
|
+
@recordable = attr_map.recordable
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private :initialize_1
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# set a couple of attribute name and attribute value (属性名と属性値を対としてセットする)
|
|
50
|
+
# @param [String,Symbol] name attribute name (属性名)
|
|
51
|
+
# @param [String] value attribute value (属性値)
|
|
52
|
+
#
|
|
53
|
+
def store(name, value)
|
|
54
|
+
if !@map[name]
|
|
55
|
+
attr = Attribute.new
|
|
56
|
+
attr.name = name
|
|
57
|
+
attr.value = value
|
|
58
|
+
if @recordable
|
|
59
|
+
attr.changed = true
|
|
60
|
+
attr.removed = false
|
|
61
|
+
end
|
|
62
|
+
@map[name] = attr
|
|
63
|
+
else
|
|
64
|
+
attr = @map[name]
|
|
65
|
+
if @recordable && attr.value != value
|
|
66
|
+
attr.changed = true
|
|
67
|
+
attr.removed = false
|
|
68
|
+
end
|
|
69
|
+
attr.value = value
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# get attribute name array (属性名配列を取得する)
|
|
75
|
+
# @return [Array] attribute name array (属性名配列)
|
|
76
|
+
#
|
|
77
|
+
def names
|
|
78
|
+
@map.keys
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
#
|
|
82
|
+
# get attribute value using attribute name (属性名で属性値を取得する)
|
|
83
|
+
# @param [String,Symbol] name attribute name (属性名)
|
|
84
|
+
# @return [String] attribute value (属性値)
|
|
85
|
+
#
|
|
86
|
+
def fetch(name)
|
|
87
|
+
if @map[name] && !@map[name].removed
|
|
88
|
+
@map[name].value
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
#
|
|
93
|
+
# delete attribute using attribute name (属性名に対応した属性を削除する)
|
|
94
|
+
# @param name attribute name (属性名)
|
|
95
|
+
#
|
|
96
|
+
def delete(name)
|
|
97
|
+
if @recordable && @map[name]
|
|
98
|
+
@map[name].removed = true
|
|
99
|
+
@map[name].changed = false
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#
|
|
104
|
+
# get update flag of attribute using attribute name (属性名で属性の変更フラグを取得する)
|
|
105
|
+
# @return [true,false] update flag of attribute (属性の変更状況)
|
|
106
|
+
#
|
|
107
|
+
def changed(name)
|
|
108
|
+
if @map[name]
|
|
109
|
+
@map[name].changed
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
#
|
|
114
|
+
# get delete flag of attribute using attribute name (属性名で属性の削除状況を取得する)
|
|
115
|
+
# @return [true,false] delete flag of attribute (属性の削除状況)
|
|
116
|
+
#
|
|
117
|
+
def removed(name)
|
|
118
|
+
if @map[name]
|
|
119
|
+
@map[name].removed
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
attr_accessor :map
|
|
124
|
+
attr_accessor :recordable
|
|
125
|
+
|
|
126
|
+
#
|
|
127
|
+
# set a couple of attribute name and attribute value (属性名と属性値を対としてセットする)
|
|
128
|
+
#
|
|
129
|
+
# @param [String,Symbol] name attribute name (属性名)
|
|
130
|
+
# @param [String] value attribute value (属性値)
|
|
131
|
+
#
|
|
132
|
+
def []=(name, value)
|
|
133
|
+
store(name, value)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
#
|
|
137
|
+
# get attribute value using attribute name (属性名で属性値を取得する)
|
|
138
|
+
#
|
|
139
|
+
# @param [String,Symbol] name attribute name (属性名)
|
|
140
|
+
# @return [String] attribute value (属性値)
|
|
141
|
+
#
|
|
142
|
+
def [](name)
|
|
143
|
+
fetch(name)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|