eim_xml 0.0.4 → 1.0.0
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 +7 -0
- data/LICENSE +339 -0
- data/lib/eim_xml/assertions.rb +14 -14
- data/lib/eim_xml/dsl.rb +104 -96
- data/lib/eim_xml/formatter/element_wrapper.rb +8 -6
- data/lib/eim_xml/formatter.rb +105 -106
- data/lib/eim_xml/matcher.rb +23 -20
- data/lib/eim_xml/parser.rb +68 -70
- data/lib/eim_xml/xhtml/dsl.rb +16 -14
- data/lib/eim_xml/xhtml.rb +156 -152
- data/lib/eim_xml.rb +202 -202
- metadata +31 -61
- data/Rakefile +0 -26
- data/Rakefile.utirake +0 -374
- data/spec/assertions_test.rb +0 -30
- data/spec/dsl_spec.rb +0 -217
- data/spec/eim_xml_spec.rb +0 -441
- data/spec/formatter_spec.rb +0 -260
- data/spec/parser_spec.rb +0 -102
- data/spec/xhtml_spec.rb +0 -524
data/lib/eim_xml/xhtml.rb
CHANGED
@@ -1,153 +1,157 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
1
|
+
require 'English'
|
2
|
+
require 'eim_xml'
|
3
|
+
require 'eim_xml/formatter'
|
4
|
+
|
5
|
+
module EimXML
|
6
|
+
module XHTML
|
7
|
+
module DocType
|
8
|
+
XHTML_MATHML = %(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">)
|
9
|
+
end
|
10
|
+
|
11
|
+
class Base < EimXML::Element
|
12
|
+
end
|
13
|
+
|
14
|
+
class HTML < Base
|
15
|
+
attr_accessor :prefix
|
16
|
+
|
17
|
+
module NameSpace
|
18
|
+
XHTML = 'http://www.w3.org/1999/xhtml'
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(attributes = {})
|
22
|
+
super(:html, attributes)
|
23
|
+
end
|
24
|
+
|
25
|
+
def write_to(out = '')
|
26
|
+
out << @prefix << "\n" if @prefix
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Simple < Base
|
32
|
+
def initialize(attributes = {})
|
33
|
+
super(self.class.name[/.*::(.*)/, 1].downcase.to_sym, attributes)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class PreserveSpace < Base
|
38
|
+
def initialize(name = {}, attributes = {})
|
39
|
+
if name.is_a?(Hash)
|
40
|
+
super(self.class.name[/.*::(.*)/, 1].downcase.to_sym, name)
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class HEAD < Simple; end
|
48
|
+
class META < Simple; end
|
49
|
+
class LINK < Simple; end
|
50
|
+
class IMG < Simple; end
|
51
|
+
class STYLE < PreserveSpace; end
|
52
|
+
class SCRIPT < PreserveSpace; end
|
53
|
+
class TITLE < Simple; end
|
54
|
+
class BODY < Simple; end
|
55
|
+
class PRE < PreserveSpace; end
|
56
|
+
|
57
|
+
class FORM < Simple
|
58
|
+
def initialize(attributes = {})
|
59
|
+
if attributes && (s = attributes.delete(:session))
|
60
|
+
name = attributes.delete(:session_name) || 'token'
|
61
|
+
require 'digest/sha1'
|
62
|
+
token = s[name] ||= Digest::SHA1.hexdigest("#{$PID}#{Time.now}#{rand}")
|
63
|
+
end
|
64
|
+
super
|
65
|
+
add(HIDDEN.new(name:, value: token)) if token
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class H1 < PreserveSpace; end
|
70
|
+
class H2 < PreserveSpace; end
|
71
|
+
class H3 < PreserveSpace; end
|
72
|
+
class H4 < PreserveSpace; end
|
73
|
+
class H5 < PreserveSpace; end
|
74
|
+
class H6 < PreserveSpace; end
|
75
|
+
class P < PreserveSpace; end
|
76
|
+
class A < PreserveSpace; end
|
77
|
+
class EM < PreserveSpace; end
|
78
|
+
class STRONG < PreserveSpace; end
|
79
|
+
class DIV < Simple; end
|
80
|
+
class SPAN < PreserveSpace; end
|
81
|
+
class UL < Simple; end
|
82
|
+
class OL < Simple; end
|
83
|
+
class LI < PreserveSpace; end
|
84
|
+
class DL < Simple; end
|
85
|
+
class DT < PreserveSpace; end
|
86
|
+
class DD < PreserveSpace; end
|
87
|
+
class TABLE < Simple; end
|
88
|
+
class CAPTION < PreserveSpace; end
|
89
|
+
class TR < Simple; end
|
90
|
+
class TH < PreserveSpace; end
|
91
|
+
class TD < PreserveSpace; end
|
92
|
+
class BR < Simple; end
|
93
|
+
class HR < Simple; end
|
94
|
+
class SELECT < Simple; end
|
95
|
+
class OPTION < Simple; end
|
96
|
+
|
97
|
+
module Hn
|
98
|
+
def self.new(level, attr = {}, &)
|
99
|
+
raise ArgumentError unless 1 <= level && level <= 6
|
100
|
+
|
101
|
+
klass = EimXML::XHTML.const_get("H#{level}")
|
102
|
+
klass.new(attr, &)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class TEXTAREA < PreserveSpace; end
|
107
|
+
|
108
|
+
class INPUT < Base
|
109
|
+
def initialize(opt = {})
|
110
|
+
super(:input, opt)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class BUTTON < PreserveSpace
|
115
|
+
def initialize(opt = {})
|
116
|
+
super(:button, opt)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
class SUBMIT < BUTTON
|
121
|
+
def initialize(opt = {})
|
122
|
+
super(opt.merge(type: :submit))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
class HIDDEN < INPUT
|
127
|
+
def initialize(opt = {})
|
128
|
+
super(opt.merge(type: :hidden))
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
class TEXT < INPUT
|
133
|
+
def initialize(opt = {})
|
134
|
+
super(opt.merge(type: :text))
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
class PASSWORD < INPUT
|
139
|
+
def initialize(opt = {})
|
140
|
+
super(opt.merge(type: :password))
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class FILE < INPUT
|
145
|
+
def initialize(opt = {})
|
146
|
+
super(opt.merge(type: :file))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
PRESERVE_SPACES = [PreserveSpace]
|
151
|
+
class Formatter < EimXML::Formatter
|
152
|
+
def self.write(element, opt = {})
|
153
|
+
EimXML::Formatter.write(element, **opt.merge(preservers: PRESERVE_SPACES))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
153
157
|
end
|