Classes for MIME message handling. Should be put somewhere else! Tried using the ‘tmail’ module but found that I needed something lighter in weight.
# File lib/soap/mimemessage.rb, line 209 209: def add_attachment(attach) 210: part = Part.new 211: part.headers.add("Content-Type", attach.contenttype) 212: part.headers.add("Content-ID", attach.mime_contentid) 213: part.body = attach.content 214: @parts.unshift(part) 215: end
# File lib/soap/mimemessage.rb, line 200 200: def add_part(content) 201: part = Part.new 202: part.headers.add("Content-Type", 203: "text/xml; charset=" + XSD::Charset.xml_encoding_label) 204: part.headers.add("Content-ID", Attachment.contentid(part)) 205: part.body = content 206: @parts.unshift(part) 207: end
# File lib/soap/mimemessage.rb, line 193 193: def boundary 194: if @boundary == nil 195: @boundary = "----=Part_" + __id__.to_s + rand.to_s 196: end 197: @boundary 198: end
# File lib/soap/mimemessage.rb, line 161 161: def close 162: @headers.add( 163: "Content-Type", 164: "multipart/related; type=\"text/xml\"; boundary=\"#{boundary}\"; start=\"#{@parts[0].contentid}\"" 165: ) 166: end
# File lib/soap/mimemessage.rb, line 225 225: def content_str 226: str = '' 227: @parts.each do |prt| 228: str << "--" + boundary + "\r\n" 229: str << prt.to_s + "\r\n" 230: end 231: str << '--' + boundary + "--\r\n" 232: str 233: end
# File lib/soap/mimemessage.rb, line 217 217: def has_parts? 218: (@parts.length > 0) 219: end
# File lib/soap/mimemessage.rb, line 221 221: def headers_str 222: @headers.to_s 223: end
# File lib/soap/mimemessage.rb, line 168 168: def parse(head, str) 169: @headers = Headers.parse(head + "\r\n" + "From: jfh\r\n") 170: boundary = @headers['content-type']['boundary'] 171: if boundary != nil 172: parts = str.split(/--#{Regexp.quote(boundary)}\s*(?:\r\n|--\r\n)/) 173: part = parts.shift # preamble must be ignored. 174: @parts = parts.collect { |part| Part.parse(part) } 175: else 176: @parts = [Part.parse(str)] 177: end 178: if @parts.length < 1 179: raise MIMEMessageError.new("This message contains no valid parts!") 180: end 181: self 182: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.