emailparser 0.0.9 → 0.1.0
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.
- checksums.yaml +4 -4
- data/lib/emailparser.rb +14 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e2190c9de315bdca71d4698ef17f0c8f661c516
|
4
|
+
data.tar.gz: 5ce860b1920126fd6f09be564ad15f720d99c1ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bdb187b9330bb47b332b5c8431431819c43e40256019f801e3e431455e4e8dbc3db09fda5a92cfd6f5f91ea3a88a7d5e2f94d2f089737b5c57f9730952dd225
|
7
|
+
data.tar.gz: ebb5ebef9df35b28d4ef30888d0c3807fad8b4385bb045ee961a8ed203dc3a5815e7fa8485092eeec1980c1198432db7a310be4fd97668ea8ab33d05dd8c5ccd
|
data/lib/emailparser.rb
CHANGED
@@ -135,10 +135,18 @@ class Emailparser
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
def
|
138
|
+
def make_attachment_folder(attachments, message_id)
|
139
|
+
if (!attachments.empty?)
|
140
|
+
puts "Creating attachments directory: " + message_id
|
141
|
+
attachments_dir = @attachment_dir + message_id
|
142
|
+
Dir.mkdir(attachments_dir) if !Dir.exist?(attachments_dir)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def save_attachment(attachment, message_id, filename)
|
139
147
|
puts " - found attachment " + filename + "\n"
|
140
148
|
begin
|
141
|
-
File.open(@attachment_dir + filename, "w+b", 0644) do |f|
|
149
|
+
File.open(@attachment_dir + message_id + "/" + filename, "w+b", 0644) do |f|
|
142
150
|
f.write attachment.body.decoded
|
143
151
|
end
|
144
152
|
rescue => e
|
@@ -207,6 +215,7 @@ class Emailparser
|
|
207
215
|
end
|
208
216
|
|
209
217
|
# Handle Attachments
|
218
|
+
make_attachment_folder(email.attachments, email.message_id)
|
210
219
|
email.attachments.each do | attachment |
|
211
220
|
attachment_save = false
|
212
221
|
filename = fix_encode(attachment.filename)
|
@@ -235,11 +244,11 @@ class Emailparser
|
|
235
244
|
puts " - Attachment is: video"
|
236
245
|
attachment_save = true
|
237
246
|
end
|
238
|
-
|
247
|
+
|
239
248
|
# Process Attachment
|
240
249
|
if (attachment_save == true)
|
241
|
-
attachments.push(filename)
|
242
|
-
save_attachment(attachment, filename)
|
250
|
+
attachments.push(email.message_id + "/" + filename)
|
251
|
+
save_attachment(attachment, email.message_id, filename)
|
243
252
|
end
|
244
253
|
end
|
245
254
|
|