Class: MailFakk2
Instance Attribute Summary collapse
-
#fax ⇒ Object
readonly
Returns the value of attribute fax.
Class Method Summary collapse
Instance Method Summary collapse
- #archive_path ⇒ Object
- #callfile_contents ⇒ Object
- #callfile_path ⇒ Object
- #config ⇒ Object
- #deliver! ⇒ Object
-
#initialize(source) ⇒ MailFakk2
constructor
A new instance of MailFakk2.
- #write_callfile ⇒ Object
Methods included from Logging
Constructor Details
Instance Attribute Details
#fax ⇒ Object (readonly)
Returns the value of attribute fax.
8 9 10 |
# File 'lib/mailfakk2.rb', line 8 def fax @fax end |
Class Method Details
.deliver!(source) ⇒ Object
4 5 6 |
# File 'lib/mailfakk2.rb', line 4 def self.deliver!(source) new(source).deliver! end |
Instance Method Details
#archive_path ⇒ Object
21 22 23 |
# File 'lib/mailfakk2.rb', line 21 def archive_path File. File.join( config.archive_path, @fax.filename) end |
#callfile_contents ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mailfakk2.rb', line 44 def callfile_contents <<-EOCALL Channel: DAHDI/g0/#{@fax.number} MaxRetries: 5 WaitTime: 20 Context: incoming-fax Application: SendFax Data:#{archive_path} Archive: yes EOCALL end |
#callfile_path ⇒ Object
25 26 27 |
# File 'lib/mailfakk2.rb', line 25 def callfile_path File.join( config.outgoing_call_dir, @fax.callfile_name) end |
#config ⇒ Object
29 30 31 |
# File 'lib/mailfakk2.rb', line 29 def config @config ||= Configuration.load end |
#deliver! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/mailfakk2.rb', line 14 def deliver! log("sending fax to #{@fax.number}") @fax.write( archive_path ) write_callfile self end |
#write_callfile ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mailfakk2.rb', line 33 def write_callfile tmp = Tempfile.new('call') log("write tmp callfile to #{tmp.path}") tmp.puts callfile_contents tmp.close log("mv callfile to asterisk spool: #{callfile_path}") FileUtils.mkdir_p config.outgoing_call_dir FileUtils.mv tmp.path, callfile_path FileUtils.chmod 0666, callfile_path end |