Sha256: 0254a2a854e5dd0a9050eb0e3cc82cd4150f499f093c6c0ee73fa4a267963b6e
Contents?: true
Size: 1.49 KB
Versions: 5
Compression:
Stored size: 1.49 KB
Contents
ALLOWED_CHARACTERS = /[^\s&<]+/ # :nodoc: module RCAP # :nodoc: def self.generate_identifier UUIDTools::UUID.random_create.to_s end def self.xpath_text( xml_element, xpath, namespace ) element = self.xpath_first( xml_element, xpath, namespace ) element.text if element end def self.xpath_first( xml_element, xpath, namespace ) REXML::XPath.first( xml_element, xpath, { 'cap' => namespace }) end def self.xpath_match( xml_element, xpath, namespace ) REXML::XPath.match( xml_element, xpath, { 'cap' => namespace }) end def self.format_lines_for_inspect( header, inspect_string ) max_line_length = inspect_string.lines.map{ |line| line.chomp.length }.max "\n." + '-' * (max_line_length + 2) + ".\n"+ '| ' + header.ljust( max_line_length ) + " |\n"+ '|' + '-' * ( max_line_length + 2 ) + "|\n"+ inspect_string.lines.map{ |line| '| ' + line.chomp.ljust( max_line_length ) +' |'}.join( "\n" ) + "\n" + "'" + '-' * ( max_line_length + 2 ) + "'\n" end def self.attribute_values_to_hash( *attribute_values ) Hash[ *attribute_values.reject{ |key, value| value.nil? || ( value.respond_to?( :'empty?' ) && value.empty? )}.flatten( 1 )] end def self.to_s_for_cap( object ) if object if object.respond_to?( :to_s_for_cap ) object.to_s_for_cap else object.to_s end end end def self.parse_datetime( date_string ) if date_string.is_a?( String ) DateTime.parse( date_string ) end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
rcap-1.3.0 | lib/rcap/utilities.rb |
rcap-1.2.4 | lib/rcap/utilities.rb |
rcap-1.2.3 | lib/rcap/utilities.rb |
rcap-1.2.2 | lib/rcap/utilities.rb |
rcap-1.2.1 | lib/rcap/utilities.rb |