raw_content is the post-MIME-decode content. this is used for saving the attachment to disk.
raw_content is the post-MIME-decode content. this is used for saving the attachment to disk.
raw_content is the post-MIME-decode content. this is used for saving the attachment to disk.
raw_content is the post-MIME-decode content. this is used for saving the attachment to disk.
# File lib/sup/message-chunks.rb, line 86 def initialize content_type, filename, encoded_content, sibling_types @content_type = content_type.downcase @filename = filename @quotable = false # changed to true if we can parse it through the # mime-decode hook, or if it's plain text @raw_content = if encoded_content.body encoded_content.decode else "For some bizarre reason, RubyMail was unable to parse this attachment.\n" end text = case @content_type when /^text\/plain\b/ @raw_content else HookManager.run "mime-decode", :content_type => content_type, :filename => lambda { write_to_disk }, :charset => encoded_content.charset, :sibling_types => sibling_types end @lines = nil if text text = text.transcode(encoded_content.charset || $encoding) @lines = text.gsub("\r\n", "\n").gsub(/\t/, " ").gsub(/\r/, "").split("\n") @quotable = true end end
# File lib/sup/message-chunks.rb, line 129 def expandable?; !viewable? end
# File lib/sup/message-chunks.rb, line 130 def initial_state; :open end
an attachment is exapndable if we've managed to decode it into something we can display inline. otherwise, it's viewable.
# File lib/sup/message-chunks.rb, line 128 def inlineable?; false end
# File lib/sup/message-chunks.rb, line 117 def patina_color; :attachment_color end
# File lib/sup/message-chunks.rb, line 118 def patina_text if expandable? "Attachment: #{filename} (#{lines.length} lines)" else "Attachment: #{filename} (#{content_type}; #{@raw_content.size.to_human_size})" end end
used when viewing the attachment as text
# File lib/sup/message-chunks.rb, line 159 def to_s @lines || @raw_content end
# File lib/sup/message-chunks.rb, line 144 def view! path = write_to_disk ret = HookManager.run "mime-view", :content_type => @content_type, :filename => path ret || view_default!(path) end
# File lib/sup/message-chunks.rb, line 132 def view_default! path case Config::CONFIG['arch'] when /darwin/ cmd = "open '#{path}'" else cmd = "/usr/bin/run-mailcap --action=view '#{@content_type}:#{path}'" end debug "running: #{cmd.inspect}" BufferManager.shell_out(cmd) $? == 0 end
Generated with the Darkfish Rdoc Generator 2.