attachments 0.0.3 → 0.0.4
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/VERSION +1 -1
- data/lib/attachments/extract.rb +13 -13
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/attachments/extract.rb
CHANGED
@@ -32,24 +32,23 @@ module Attachments
|
|
32
32
|
@last_parsed = filename
|
33
33
|
|
34
34
|
# Load the email
|
35
|
-
mail = Mail.read(filename)
|
36
|
-
|
37
|
-
# To and from is important when sending mail to db
|
38
|
-
@to = mail.to
|
39
|
-
|
40
|
-
@from = mail.from
|
35
|
+
@mail = Mail.read(filename)
|
41
36
|
|
42
37
|
# Parse parts recursively until it is not multipart
|
43
38
|
# Ignore types that are not suited for forwarding
|
44
|
-
parse_part mail
|
39
|
+
parse_part @mail
|
45
40
|
end
|
46
41
|
|
47
42
|
def to
|
48
|
-
@to || nil
|
43
|
+
(@mail && @mail.to) || nil
|
49
44
|
end
|
50
45
|
|
51
46
|
def from
|
52
|
-
@from || nil
|
47
|
+
(@mail && @mail.from) || nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def subject
|
51
|
+
(@mail && @mail.subject) || nil
|
53
52
|
end
|
54
53
|
|
55
54
|
def name
|
@@ -69,15 +68,16 @@ module Attachments
|
|
69
68
|
# Use close
|
70
69
|
def reset
|
71
70
|
@last_parsed = nil
|
72
|
-
@to = nil
|
73
71
|
@name = nil
|
74
|
-
@
|
72
|
+
@mail = nil
|
75
73
|
@files = []
|
76
74
|
end
|
77
75
|
|
78
76
|
def parse_part mail
|
79
77
|
# Filter parts with a type that is not of interest
|
80
|
-
|
78
|
+
if mail.content_type
|
79
|
+
ct, charset = mail.content_type.split(/;/, 2)
|
80
|
+
end
|
81
81
|
unless(mail.multipart? || (ct && @include_types.include?(ct)))
|
82
82
|
return
|
83
83
|
end
|
@@ -143,7 +143,7 @@ module Attachments
|
|
143
143
|
end
|
144
144
|
|
145
145
|
# Save meta-data for further processing
|
146
|
-
@files << { :name => @name, :tmpfile => filepath, :save_as => name, :upload_to => filename, :mime_type => mime_type
|
146
|
+
@files << { :name => @name, :tmpfile => filepath, :save_as => name, :upload_to => filename, :mime_type => mime_type }
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attachments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rune Myrland
|