mailgun_rails 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3eb3586b44fc3032dfcf6cf3778c9a9b4565eee6
4
- data.tar.gz: e7ff6e3420013419dfab185574d2515361707212
3
+ metadata.gz: 9c56490bbbbccdbcc1af3de56f1975048a33a0ad
4
+ data.tar.gz: ce12417419f575f639c24166111cda0d00f94c88
5
5
  SHA512:
6
- metadata.gz: f41934b3860ff3f6e828a7e85dd773be5010a0db8920d26014a464d1d0fb6d3653bf5a9b923c114825a868b445fb2c559cffc60ebead81d3ded711e47e78d5c7
7
- data.tar.gz: c5610c1de48dea927f680c16d6e360fb40d730d9e409c71bad054f658b86ef09e0ec4d9b40d635d36ff5ea6ea3a4ec953adc604319b0512eeb9240da8d1b0322
6
+ metadata.gz: 02eaffa49c0fc4f5b55a2d8f3308a936ca2f95204b59e3243eb728ea4cf426bf4e80894cc16a04df23901f80f1404c05d378aaae329131bbf80834ceac68b2f9
7
+ data.tar.gz: a9e10aa437d7ae83725694597962bbdfe573b00a4488f2bad922b26c3fdc24cb9d57bc2833ff6dae7081c96b38e79d53ed564696baeb4a8456b744a5223e6727
@@ -0,0 +1,16 @@
1
+ module Mailgun
2
+ class Attachment < StringIO
3
+ attr_reader :original_filename, :content_type, :path
4
+
5
+ def initialize (attachment, *rest)
6
+ @path = ''
7
+ if rest.detect {|opt| opt[:inline] }
8
+ basename = @original_filename = attachment.cid
9
+ else
10
+ basename = @original_filename = attachment.filename
11
+ end
12
+ @content_type = attachment.content_type.split(';')[0]
13
+ super attachment.body.decoded
14
+ end
15
+ end
16
+ end
@@ -38,8 +38,28 @@ module Mailgun
38
38
  end
39
39
 
40
40
  def build_basic_mailgun_message_for(rails_message)
41
- {:from => rails_message[:from].formatted, :to => rails_message[:to].formatted, :subject => rails_message.subject,
42
- :html => extract_html(rails_message), :text => extract_text(rails_message)}
41
+ mailgun_message = {
42
+ from: rails_message[:from].formatted,
43
+ to: rails_message[:to].formatted,
44
+ subject: rails_message.subject,
45
+ html: extract_html(rails_message),
46
+ text: extract_text(rails_message)
47
+ }
48
+ return mailgun_message if rails_message.attachments.empty?
49
+
50
+ # RestClient requires attachments to be in file format, use a temp directory and the decoded attachment
51
+ mailgun_message[:attachment] = []
52
+ mailgun_message[:inline] = []
53
+ rails_message.attachments.each do |attachment|
54
+ # then add as a file object
55
+ if attachment.inline?
56
+ mailgun_message[:inline] << Mailgun::Attachment.new(attachment, encoding: 'ascii-8bit', inline: true)
57
+ else
58
+ mailgun_message[:attachment] << Mailgun::Attachment.new(attachment, encoding: 'ascii-8bit')
59
+ end
60
+ end
61
+
62
+ return mailgun_message
43
63
  end
44
64
 
45
65
  def transform_reply_to(rails_message, mailgun_message)
@@ -1,3 +1,3 @@
1
1
  module Mailgun
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailgun_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Manrubia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-13 00:00:00.000000000 Z
11
+ date: 2015-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -76,6 +76,7 @@ files:
76
76
  - MIT-LICENSE
77
77
  - README.rdoc
78
78
  - Rakefile
79
+ - lib/mailgun/attachment.rb
79
80
  - lib/mailgun/client.rb
80
81
  - lib/mailgun/deliverer.rb
81
82
  - lib/mailgun/mail_ext.rb