class SourceCleaner::MrProper
Constants
- ATTRIBUTES_INDENT
- BORING_ATTRS
- INDENT_WIDTH
Public Class Methods
new()
click to toggle source
# File lib/adb_driver/source_cleaner.rb, line 24 def initialize @indent = 0 end
Public Instance Methods
end_element(uri, localname, qname)
click to toggle source
# File lib/adb_driver/source_cleaner.rb, line 54 def end_element(uri, localname, qname) @indent -= 1 end
start_element(uri, localname, qname, attributes)
click to toggle source
# File lib/adb_driver/source_cleaner.rb, line 28 def start_element(uri, localname, qname, attributes) return if localname == 'hierarchy' @indent += 1 node = ' ' * INDENT_WIDTH * @indent node << "class_name: '#{attributes['class']}'" clean_attributes = attributes.delete_if { |k, v| BORING_ATTRS.include?(k) || v.empty? } if value = clean_attributes.delete('resource-id') clean_attributes[:id] = value end if value = clean_attributes.delete('content-desc') clean_attributes[:content_desc] = value end unless clean_attributes.empty? node << ' ' * ATTRIBUTES_INDENT node << clean_attributes.map { |k, v| "#{k}: '#{v}'" }.join(', ') end puts node end