Skip to content

Commit

Permalink
- Convert rtf support tools in c to small ruby class.
Browse files Browse the repository at this point in the history
- Update bindings.


git-svn-id: https://ruby-msg.googlecode.com/svn/trunk@40 c30d66de-b626-0410-988f-81f6512a6d81
  • Loading branch information
aquasync committed Jan 23, 2007
1 parent 8f9b8b5 commit 5036d80
Show file tree
Hide file tree
Showing 4 changed files with 719 additions and 492 deletions.
3 changes: 0 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ spec = Gem::Specification.new do |s|
#s.rubyforge_project = %q{ruby-msg}

s.files = Dir.glob('data/*.yaml')
exe = RUBY_PLATFORM['win'] ? '.exe' : ''
# not great
s.files += ['rtfdecompr' + exe, 'rtf2html' + exe]
s.files += Dir.glob("lib/**/*.rb")
s.files += Dir.glob("test/test_*.rb") + Dir.glob("test/*.doc")

Expand Down
14 changes: 5 additions & 9 deletions lib/msg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require 'support'
require 'ole/storage'
require 'msg/properties'
require 'msg/rtf'
require 'mime'

module Ole
Expand All @@ -28,7 +29,7 @@ def self.parse_guid s
#

class Msg
VERSION = '1.2.12'
VERSION = '1.2.13'
# we look here for the yaml files in data/, and the exe files for support
# decoding at the moment.
SUPPORT_DIR = File.dirname(__FILE__) + '/..'
Expand Down Expand Up @@ -217,14 +218,9 @@ def body_to_mime
# (maybe i should just overload body_html do to this)
# its thus currently possible to get no body at all if the only body is rtf. that is not
# really acceptable
if props.body_rtf and !props.body_html and props.body_rtf['htmltag']
open('temp.html', 'w') { |f| f.write props.body_rtf }
begin
html = `#{SUPPORT_DIR}/rtf2html < temp.html`
mime.parts << Mime.new("Content-Type: text/html\r\n\r\n" + html.gsub(/(<\/html>).*\Z/mi, "\\1"))
ensure
File.unlink 'temp.html' rescue nil
end
if props.body_rtf and !props.body_html
html = Msg::RTF.rtf2html props.body_rtf
mime.parts << Mime.new("Content-Type: text/html\r\n\r\n" + html.gsub(/(<\/html>).*\Z/mi, "\\1"))
end
mime
else
Expand Down
Loading

0 comments on commit 5036d80

Please sign in to comment.