module AlsTypograf # The request class class Request include HTTParty base_uri 'typograf.artlebedev.ru' format :xml headers('Content-Type' => 'text/xml', 'Host' => 'typograf.artlebedev.ru', 'SOAPAction' => '"http://typograf.artlebedev.ru/webservices/ProcessText"') # Process text with remote web-service # @param [String] text text to process # @param [Hash] options options for web-service def process_text(text, options = {}) soap_request = <<-END_SOAP #{text.gsub(/&/, '&').gsub(//, '>')} #{options[:entity_type]} #{options[:use_br]} #{options[:use_p]} #{options[:max_nobr]} END_SOAP response = self.class.post('/webservices/typograf.asmx', :body => soap_request) response['soap:Envelope']['soap:Body']['ProcessTextResponse']['ProcessTextResult'].gsub(/&/, '&').gsub(/</, '<').gsub(/>/, '>').gsub(/\t$/, '') rescue ::Exception => exception return text end end end