class Byebug::Printers::Xml
Public Instance Methods
print(path, args = {})
click to toggle source
# File lib/byebug/printers/xml.rb, line 8 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)
click to toggle source
# File lib/byebug/printers/xml.rb, line 23 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)
click to toggle source
# File lib/byebug/printers/xml.rb, line 40 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)
click to toggle source
# File lib/byebug/printers/xml.rb, line 34 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
Private Instance Methods
contents_files()
click to toggle source
Calls superclass method
# File lib/byebug/printers/xml.rb, line 91 def contents_files [File.expand_path(File.join("..", "texts", "xml.yml"), __FILE__)] + super end
print_confirmation(path, args)
click to toggle source
# File lib/byebug/printers/xml.rb, line 70 def print_confirmation(path, args) xml = ::Builder::XmlMarkup.new xml.confirmation { print_content(xml, path, args) } end
print_content(xml, path, args)
click to toggle source
# File lib/byebug/printers/xml.rb, line 80 def print_content(xml, path, args) xml.text!(translate(locate(path), args)) end
print_debug(path, args)
click to toggle source
# File lib/byebug/printers/xml.rb, line 61 def print_debug(path, args) translate(locate(path), args) end
print_error(path, args)
click to toggle source
# File lib/byebug/printers/xml.rb, line 65 def print_error(path, args) xml = ::Builder::XmlMarkup.new xml.error { print_content(xml, path, args) } end
print_general(path, args)
click to toggle source
# File lib/byebug/printers/xml.rb, line 53 def print_general(path, args) settings = locate(path) xml = ::Builder::XmlMarkup.new tag = translate(settings["tag"], args) attributes = translated_attributes(settings["attributes"], args) xml.tag!(tag, attributes) end
print_message(path, args)
click to toggle source
# File lib/byebug/printers/xml.rb, line 75 def print_message(path, args) xml = ::Builder::XmlMarkup.new xml.message { print_content(xml, path, args) } end
translated_attributes(attributes, args)
click to toggle source
# File lib/byebug/printers/xml.rb, line 84 def translated_attributes(attributes, args) attributes.inject({}) do |hash, (key, value)| hash[key] = translate(value, args) hash end end