meteor 0.9.12 → 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.
data/demo/xhtml4.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # -* coding: UTF-8 -*-
3
3
  # frozen_string_literal: true
4
4
 
5
- #require 'rubygems'
5
+ # require 'rubygems'
6
6
  require 'meteor'
7
7
 
8
8
  Meteor::ElementFactory.link(:xhtml4,'ml/sample_xhtml4.html', 'UTF-8')
@@ -11,39 +11,39 @@ root = Meteor::ElementFactory.element('/ml/sample_xhtml4')
11
11
  startTime = Time.new.to_f
12
12
 
13
13
  elm_hello = root.element("id","hello")
14
- elm_hello['class'] = 'red' #elm_hello.attr(class: "red")
15
- #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')
16
16
 
17
17
  elm_hello2 = root.element(id: "hello2")
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
- #}
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
+ # }
34
34
 
35
35
  elm_radio1 = root.element("input", id: "radio1", type: "radio")
36
- elm_radio1['checked'] = true #elm_radio1.attribute(checked: true)
36
+ elm_radio1['checked'] = true # elm_radio1.attribute(checked: true)
37
37
 
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")
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")
42
42
 
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")
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")
47
47
 
48
48
  elm_select2 = root.element("select",id: "select2")
49
49
  elm_select2["multiple"] = true
@@ -51,13 +51,13 @@ elm_option2 = elm_select2.element("option",id: "option2")
51
51
  co_elm = elm_option2.element()
52
52
  10.times { |i|
53
53
  if i == 1 then
54
- co_elm['selected'] = true #co_elm.attr(selected: true)
54
+ co_elm['selected'] = true # co_elm.attr(selected: true)
55
55
  else
56
- co_elm['selected'] = false #co_elm.attr(selected: false)
56
+ co_elm['selected'] = false # co_elm.attr(selected: false)
57
57
  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)
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)
61
61
  co_elm.flash
62
62
  }
63
63
 
@@ -71,7 +71,7 @@ elm_dt3_ = elm_.element(id: 'cc')
71
71
  elm_dt1 = elm_dt1_.clone
72
72
  elm_dt2 = elm_dt2_.clone
73
73
  elm_dt3 = elm_dt3_.clone
74
- elm_dt1.content = i #elm_dt1.content("<>\"' \n" << i.to_s)
74
+ elm_dt1.content = i # elm_dt1.content("<>\"' \n" << i.to_s)
75
75
  elm_dt2.content = i
76
76
  elm_dt3.content = i
77
77
  elm_.flash
@@ -83,4 +83,7 @@ endTime = Time.new.to_f
83
83
 
84
84
  puts root.document
85
85
 
86
+ puts "charset:#{root.charset}"
87
+ puts "content-type:#{root.content_type}"
88
+
86
89
  puts '' + (endTime - startTime).to_s + ' sec'
data/demo/xml.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # -* coding: UTF-8 -*-
3
3
  # frozen_string_literal: true
4
4
 
5
- #require 'rubygems'
5
+ # require 'rubygems'
6
6
  require 'meteor'
7
7
 
8
8
  Meteor::ElementFactory.link(Meteor::XML,'ml/sample.xml', 'UTF-8')
@@ -10,52 +10,52 @@ root = Meteor::ElementFactory.element('/ml/sample')
10
10
 
11
11
  start_time = Time.new.to_f
12
12
 
13
- #elm_ = root.element('kobe')
14
- #puts elm_.name
15
- #puts elm_.attributes
16
- #puts elm_.mixed_content
17
- #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
18
18
 
19
- #elm_ = root.element('test')
20
- #puts elm_.name
21
- #puts elm_.attributes
22
- #puts elm_.mixed_content
19
+ # elm_ = root.element('test')
20
+ # puts elm_.name
21
+ # puts elm_.attributes
22
+ # puts elm_.mixed_content
23
23
 
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")
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")
28
28
 
29
29
  elm7 = root.element("kobe")
30
- #elm7 = root.element(momo: "mono")
31
- #elm8 = root.element(manbo: "mango")
32
- #elm8 = root.element(momo: "momo")
30
+ # elm7 = root.element(momo: "mono")
31
+ # elm8 = root.element(manbo: "mango")
32
+ # elm8 = root.element(momo: "momo")
33
33
 
34
- #elm9 = root.element("hamachi",id: "aa",id2: 'bb')
35
- #elm_c1 = root.cxtag("cs")
34
+ # elm9 = root.element("hamachi",id: "aa",id2: 'bb')
35
+ # elm_c1 = root.cxtag("cs")
36
36
 
37
- #puts elm8.name
38
- #puts elm8.attributes
39
- #puts elm8.mixed_content
37
+ # puts elm8.name
38
+ # puts elm8.attributes
39
+ # puts elm8.mixed_content
40
40
 
41
- #elm1.attr(id2: "cc")
42
- #elm1["id2"] = "cc"
41
+ # elm1.attr(id2: "cc")
42
+ # elm1["id2"] = "cc"
43
43
 
44
- #elm8['mango'] = "mangoo" #elm8.attr(manbo: "mangoo")
45
- #elm9.content = "\\1" #elm9.content("\\1")
44
+ # elm8['mango'] = "mangoo" # elm8.attr(manbo: "mangoo")
45
+ # elm9.content = "\\1" # elm9.content("\\1")
46
46
 
47
- #elm2.attr(id3: 'cc')
47
+ # elm2.attr(id3: 'cc')
48
48
 
49
- #elm3['id3'] = 'cc' #elm3.attr(id3: 'cc')
50
- #elm3['id3'] = 'cc' #elm4.attr(id3: 'cc')
51
- #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')
52
52
 
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
- #}
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
+ # }
59
59
 
60
60
  elm_ = root.element(elm1)
61
61
  elm5_ = elm_.element('tech')
@@ -67,29 +67,29 @@ elm5_ = elm_.element('tech')
67
67
  elm_.flash
68
68
  end
69
69
 
70
- #am3 = elm3.attr_map
71
- #am3.names.each { |item|
72
- # puts item
73
- # puts am3.fetch(item)
74
- #}
70
+ # am3 = elm3.attr_map
71
+ # am3.names.each { |item|
72
+ # puts item
73
+ # puts am3.fetch(item)
74
+ # }
75
75
 
76
76
  elm_ = root.element(elm7)
77
77
 
78
78
  10.times { |i|
79
79
  elm_["momo"]= i
80
80
  elm_["eco"] = "えま"
81
- elm_.content = i #elm_["content"] = i.to_s
81
+ elm_.content = i # elm_["content"] = i.to_s
82
82
  elm_.flash
83
83
  }
84
84
 
85
- #co_elm = root.element(elm_c1)
85
+ # co_elm = root.element(elm_c1)
86
86
  #
87
- #10.times { |i|
88
- # co_elm.content = i #co_elm.content(i)
89
- # co_elm.flash
90
- #}
87
+ # 10.times { |i|
88
+ # co_elm.content = i # co_elm.content(i)
89
+ # co_elm.flash
90
+ # }
91
91
 
92
- #elm3['id3'] = 'dd' #elm3.attr(id3: 'dd')
92
+ # elm3['id3'] = 'dd' # elm3.attr(id3: 'dd')
93
93
 
94
94
  root.flash
95
95
 
@@ -97,11 +97,11 @@ end_time = Time.new.to_f
97
97
 
98
98
  puts root.document
99
99
 
100
- #elms = root.elements("potato2")
101
- ##elms = root.elements("kobe")
102
- #elms = root.elements("potato")
100
+ # elms = root.elements("potato2")
101
+ ## elms = root.elements("kobe")
102
+ # elms = root.elements("potato")
103
103
 
104
- elms = root.elements("test") #elms = root.css('test')
104
+ elms = root.elements("test") # elms = root.css('test')
105
105
  elms.each{|elm, i|
106
106
  puts '-------'
107
107
  puts 'doc----'
@@ -114,14 +114,14 @@ elms.each{|elm, i|
114
114
 
115
115
  puts '' + (end_time - start_time).to_s + ' sec'
116
116
 
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
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