module CI::Reporter::StructureXmlHelpers

Public Instance Methods

attr_hash() click to toggle source

Struct#to_h is not available in Ruby 1.9

# File lib/ci/reporter/test_suite.rb, line 9
def attr_hash
  Hash[self.members.zip(self.values)]
end
cleaned_attributes() click to toggle source

Removes empty attributes and truncates long attributes.

# File lib/ci/reporter/test_suite.rb, line 14
def cleaned_attributes
  attr_array = attr_hash
    .reject {|k,v| v.to_s.empty? }
    .map    {|k,v| [k, truncate_at_newline(v)] }
  Hash[attr_array]
end
truncate_at_newline(txt) click to toggle source
# File lib/ci/reporter/test_suite.rb, line 21
def truncate_at_newline(txt)
  txt.to_s.sub(/\n.*/m, '...')
end