attachments 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/attachments/extract.rb +13 -13
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -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
- @from = nil
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
- ct, charset = mail.content_type.split(/;/, 2) if mail.content_type
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, :from => @from, :to => @to }
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: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rune Myrland