Class: Printers::Xml
- Inherits:
-
Base
- Object
- Base
- Printers::Xml
show all
- Defined in:
- lib/debugger/printers/xml.rb
Defined Under Namespace
Classes: AllVariables, Variable
Instance Method Summary
collapse
Instance Method Details
#print(path, args = {}) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/debugger/printers/xml.rb', line 7
def print(path, args = {})
case parts(path)[1]
when "errors"
print_error(path, args)
when "confirmations"
print_confirmation(path, args)
when "debug"
print_debug(path, args)
when "messages"
print_message(path, args)
else
print_general(path, args)
end
end
|
#print_collection(path, collection, &block) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/debugger/printers/xml.rb', line 22
def print_collection(path, collection, &block)
settings = locate(path)
xml = ::Builder::XmlMarkup.new
tag = translate(settings["tag"])
xml.tag!("#{tag}s") do |xml|
array_of_args(collection, &block).each do |args|
xml.tag!(tag, translated_attributes(settings["attributes"], args))
end
end
end
|
#print_instance_variables(object) ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/debugger/printers/xml.rb', line 39
def print_instance_variables(object)
variables = if object.is_a?(Array)
object.each.with_index.map { |item, index| ["[#{index}]", item, 'instance'] }
elsif object.is_a?(Hash)
object.map { |key, value| [key.is_a?(String) ? "'#{key}'" : key.to_s, value, 'instance'] }
else
AllVariables.new(object).variables
end
print_variables(variables, nil)
end
|
#print_variables(variables, global_kind) ⇒ Object
33
34
35
36
37
|
# File 'lib/debugger/printers/xml.rb', line 33
def print_variables(variables, global_kind)
print_collection("variable.variable", variables) do |(key, value, kind), index|
Variable.new(key, value, kind || global_kind).to_hash
end
end
|