Sha256: 360d46f2b48663f9eafe3e082a6c401edaefc2201884855ad8a3ede619b24aa3

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

ALLOWED_CHARACTERS = /[^\s&<]+/ # :nodoc:

class Array # :nodoc:
  def to_s_for_cap
    self.map{ |element| element.to_s.for_cap_list }.join( ' ' )
  end
end

class String # :nodoc:
  CAP_LIST_REGEX = /"([\w\s]+)"|(\S+)/
  WHITESPACE_REGEX = /^\s+$/ 

  def for_cap_list
    if self =~ /\s/
      '"'+self+'"'
    else
      self
    end
  end

  def unpack_cap_list
    self.split( CAP_LIST_REGEX ).reject{ |match| match == "" || match =~ WHITESPACE_REGEX }  
  end
end

class DateTime # :nodoc:
	alias inspect to_s
  alias to_s_for_cap to_s
end

class Time # :nodoc:
  def to_s_for_cap

  end
end

module RCAP # :nodoc:
	def self.xpath_text( xml_element, xpath ) 
		element = self.xpath_first( xml_element, xpath )
		element.text if element
	end

	def self.xpath_first( xml_element, xpath )
		REXML::XPath.first( xml_element, xpath, { 'cap' => RCAP::XMLNS })
	end

	def self.xpath_match( xml_element, xpath )
		REXML::XPath.match( xml_element, xpath, { 'cap' => RCAP::XMLNS })
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rcap-0.1 lib/rcap/utilities.rb