mailfakk2 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/configuration.rb +2 -0
- data/lib/facsimile.rb +9 -0
- data/lib/mailfakk2.rb +2 -0
- metadata +3 -3
data/lib/configuration.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
class Configuration < Hash
|
3
|
+
include Logging
|
3
4
|
Defaults = {
|
4
5
|
'outgoing_call_dir' => '/var/spool/asterisk/outgoing',
|
5
6
|
'archive_path' => File.join(ENV['HOME'], 'facsimiles')
|
@@ -29,6 +30,7 @@ class Configuration < Hash
|
|
29
30
|
Sources.each do |source|
|
30
31
|
|
31
32
|
if File.file?(source) && File.readable?(source)
|
33
|
+
log("loading config from #{source}")
|
32
34
|
loaded = YAML.load_file source
|
33
35
|
if loaded.is_a?(Hash)
|
34
36
|
h.merge! loaded
|
data/lib/facsimile.rb
CHANGED
@@ -47,6 +47,8 @@ class Facsimile
|
|
47
47
|
add_frames oo2tiff( part.decoded )
|
48
48
|
when %r'openxmlformats-officedocument' # docx, xlsx
|
49
49
|
add_frames oo2tiff( part.decoded, part.filename )
|
50
|
+
when %r'application/pdf'
|
51
|
+
add_frames pdfdata2tiff( part.decoded )
|
50
52
|
when %r'text/html'
|
51
53
|
# FIXME ignore html, let's hope a plain text contained everything important
|
52
54
|
when %r'multipart/alternative'
|
@@ -126,6 +128,13 @@ class Facsimile
|
|
126
128
|
read_frame dest.path
|
127
129
|
end
|
128
130
|
|
131
|
+
def pdfdata2tiff(source_data)
|
132
|
+
pdf = mktemp('pdf')
|
133
|
+
pdf.puts source_data
|
134
|
+
pdf.close
|
135
|
+
pdf2tiff(pdf.path)
|
136
|
+
end
|
137
|
+
|
129
138
|
# For some filetypes we need the filename to apend the same extention to the tempfile
|
130
139
|
def oo2tiff(source_data, filename=nil)
|
131
140
|
if filename.blank?
|
data/lib/mailfakk2.rb
CHANGED
@@ -32,8 +32,10 @@ class MailFakk2
|
|
32
32
|
|
33
33
|
def write_callfile
|
34
34
|
tmp = Tempfile.new('call')
|
35
|
+
log("write tmp callfile to #{tmp.path}")
|
35
36
|
tmp.puts callfile_contents
|
36
37
|
tmp.close
|
38
|
+
log("mv callfile to asterisk spool: #{callfile_path}")
|
37
39
|
FileUtils.mkdir_p config.outgoing_call_dir
|
38
40
|
FileUtils.mv tmp.path, callfile_path
|
39
41
|
FileUtils.chmod 0666, callfile_path
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 1
|
8
7
|
- 2
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Niklas Hofer
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-15 00:00:00 +02:00
|
18
18
|
default_executable: mailfakk2
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|