jzimmek-reportme 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/reportme/mailer.rb +15 -23
- data/lib/reportme/report_factory.rb +1 -2
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/reportme/mailer.rb
CHANGED
@@ -1,35 +1,27 @@
|
|
1
1
|
module Reportme
|
2
2
|
class Mailer < ActionMailer::Base
|
3
|
-
def message (
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def message (_from, _recipients, _subject, _body, attachments=[])
|
4
|
+
|
5
|
+
subject(_subject)
|
6
|
+
from(_from)
|
7
|
+
recipients(_recipients)
|
8
|
+
body(_body)
|
8
9
|
|
9
|
-
attachments.
|
10
|
-
|
10
|
+
unless attachments.blank?
|
11
|
+
attachments.each do |att|
|
12
|
+
content_type = att[:content_type]
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
attachment content_type do |a|
|
15
|
+
a.filename = att[:filename]
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
a.body = File.read(att[:filepath]) if att[:filepath]
|
18
|
+
a.body = att[:text] if att[:text]
|
17
19
|
|
18
|
-
|
20
|
+
a.transfer_encoding = 'quoted-printable' if content_type =~ /^text\//
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
|
-
# # Include all the pdf files in the PDF subdirectory as attachments.
|
23
|
-
# FileList['PDF/*.pdf'].each do |path|
|
24
|
-
# file = File.basename(path)
|
25
|
-
# mime_type = MIME::Types.of(file).first
|
26
|
-
# content_type = mime_type ? mime_type.content_type : 'application/binary'
|
27
|
-
# attachment (content_type) do |a|
|
28
|
-
# a.body = File.read(path)
|
29
|
-
# a.filename = file
|
30
|
-
# a.transfer_encoding = 'quoted-printable' if content_type =~ /^text\//
|
31
|
-
# end
|
32
|
-
# end
|
33
25
|
end
|
34
26
|
end
|
35
27
|
end
|
@@ -23,7 +23,6 @@ module Reportme
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def connect
|
26
|
-
puts "connection: #{@properties}"
|
27
26
|
ActiveRecord::Base.establish_connection(@properties)
|
28
27
|
end
|
29
28
|
|
@@ -36,7 +35,7 @@ module Reportme
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def mail(from, recipients, subject, body, attachments=[])
|
39
|
-
Mailer.deliver_message(
|
38
|
+
Mailer.deliver_message(from, recipients, subject, body, attachments)
|
40
39
|
end
|
41
40
|
|
42
41
|
def init(&block)
|