mailfakk2 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +6 -6
- data/lib/facsimile.rb +23 -7
- data/spec/facsimile_spec.rb +13 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -25,7 +25,7 @@ Debian / Ubuntu
|
|
25
25
|
---------------
|
26
26
|
|
27
27
|
* sudo apt-get install ruby ruby-dev gs unoconv openoffice.org-headless rubygems xvfb librmagick-ruby
|
28
|
-
* sudo gem install
|
28
|
+
* sudo gem install mailfakk2
|
29
29
|
|
30
30
|
Cons
|
31
31
|
====
|
@@ -34,16 +34,16 @@ If you plan to spam by fax you should consider another product. MailFaKK2 is
|
|
34
34
|
kind of slow. This is caused by launching OpenOffice.org for every conversion.
|
35
35
|
Speed is not a priority for us (yet).
|
36
36
|
|
37
|
-
TODO
|
38
|
-
|
37
|
+
TODO / Features
|
38
|
+
===============
|
39
39
|
|
40
40
|
* [x] generate cover sheet TIFF frame from email body
|
41
41
|
* [x] append OpenOffice.org documents
|
42
42
|
* [ ] append MS Office documents
|
43
|
-
* [
|
44
|
-
* [
|
43
|
+
* [x] write TIFF and callfile
|
44
|
+
* [x] procmail mode
|
45
45
|
* [ ] header and footer for every frame
|
46
|
-
* [
|
46
|
+
* [x] gemspec
|
47
47
|
* [ ] check if fax was delivered (callfile moved to outgoing_done)
|
48
48
|
|
49
49
|
Meta
|
data/lib/facsimile.rb
CHANGED
@@ -6,8 +6,10 @@ class Facsimile
|
|
6
6
|
|
7
7
|
#include ActiveSupport::Memoization
|
8
8
|
|
9
|
-
class
|
10
|
-
class
|
9
|
+
class Error < ::Exception; end
|
10
|
+
class NoPhoneNumberFound < Error; end
|
11
|
+
class NoContentFound < Error; end
|
12
|
+
class BadContent < Error; end
|
11
13
|
|
12
14
|
attr_reader :frames
|
13
15
|
attr_reader :mail
|
@@ -43,10 +45,14 @@ class Facsimile
|
|
43
45
|
add_frames text2tiff( part.decoded )
|
44
46
|
when %r'opendocument\.text'
|
45
47
|
add_frames oo2tiff( part.decoded )
|
48
|
+
when %r'openxmlformats-officedocument' # docx, xlsx
|
49
|
+
add_frames oo2tiff( part.decoded, part.filename )
|
46
50
|
when %r'text/html'
|
47
51
|
# FIXME ignore html, let's hope a plain text contained everything important
|
52
|
+
when %r'multipart/alternative'
|
53
|
+
# ignore this, stupid outlook
|
48
54
|
else
|
49
|
-
|
55
|
+
log "unsupported content type: #{part.content_type}"
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
@@ -120,15 +126,25 @@ class Facsimile
|
|
120
126
|
read_frame dest.path
|
121
127
|
end
|
122
128
|
|
123
|
-
|
124
|
-
|
129
|
+
# For some filetypes we need the filename to apend the same extention to the tempfile
|
130
|
+
def oo2tiff(source_data, filename=nil)
|
131
|
+
if filename.blank?
|
132
|
+
source = mktemp('oo', false)
|
133
|
+
pdf_path = source.path + '.pdf'
|
134
|
+
else
|
135
|
+
extention = filename.split('.').last
|
136
|
+
source = mktemp(['oo', ".#{extention}"], false)
|
137
|
+
pdf_path = source.path.sub(/#{extention}$/,'pdf')
|
138
|
+
end
|
125
139
|
source.write source_data
|
126
140
|
source.close
|
127
141
|
|
128
142
|
dest = mktemp('pdf')
|
129
143
|
xvfb("unoconv -f pdf #{source.path}")
|
130
|
-
|
131
|
-
|
144
|
+
if File.file?(pdf_path)
|
145
|
+
FileUtils.mv pdf_path, dest.path
|
146
|
+
pdf2tiff(dest.path)
|
147
|
+
end
|
132
148
|
end
|
133
149
|
|
134
150
|
def text2pdf(source)
|
data/spec/facsimile_spec.rb
CHANGED
@@ -68,3 +68,16 @@ describe "text with attached OpenOffice Writer Document (2 Pages)" do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
end
|
71
|
+
|
72
|
+
describe "mail with word (2 pages) and excel attachment" do
|
73
|
+
before(:each) do
|
74
|
+
@mail_path = mail_path('word_and_excel')
|
75
|
+
@fax = Facsimile.new @mail_path
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should produce 2+1 frames' do
|
79
|
+
@fax.write result_path('word_and_excel')
|
80
|
+
@fax.should have(3).frames
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|