Class: Athena::Formats::XML::BaseSpec
- Inherits:
-
XMLStreamin::XMLSpec
- Object
- XMLStreamin::XMLSpec
- Athena::Formats::XML::BaseSpec
show all
- Includes:
- Util
- Defined in:
- lib/athena/formats/xml.rb
Instance Method Summary
collapse
Methods included from Util
#verbose
Instance Method Details
#done(context, name) ⇒ Object
159
160
161
162
163
164
165
166
|
# File 'lib/athena/formats/xml.rb', line 159
def done(context, name)
verbose(:xml) do
step :up
spit "#{indent(level)}</#{name}>"
end
return context
end
|
#empty(context) ⇒ Object
168
169
170
171
172
173
174
|
# File 'lib/athena/formats/xml.rb', line 168
def empty(context)
verbose(:xml) do
step :up
end
return context
end
|
#inspect_spec(element = nil, level = 0) ⇒ Object
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/athena/formats/xml.rb', line 176
def inspect_spec(element = nil, level = 0)
if respond_to?(:field)
msg = "#{indent(level)}[#{element}] #{field.to_s.upcase} -> #{name}"
respond_to?(:spit) ? spit(msg) : warn(msg)
specs.each { |e, s|
s.inspect_spec(e, level + 1)
}
else
if specs.empty?
specs.default.inspect_spec('?', level)
else
specs.each { |e, s|
s.inspect_spec(e, level)
}
end
end
end
|
#start(context, name, attrs) ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/athena/formats/xml.rb', line 137
def start(context, name, attrs)
verbose(:xml) do
spit "#{indent(level)}<#{name}>"
step :down
attrs.each { |attr|
spit "#{indent(level + 1)}[#{attr[0]} = #{attr[1]}]"
}
end
return context
end
|
#text(context, data) ⇒ Object
150
151
152
153
154
155
156
157
|
# File 'lib/athena/formats/xml.rb', line 150
def text(context, data)
verbose(:xml) do
content = data.strip
spit "#{indent(level)}#{content}" unless content.empty?
end
return context
end
|