mailgun_rails 0.5.3 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright 2013 YOURNAME
1
+ Copyright 2013 Jorge Manrubia
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -16,30 +16,32 @@ module Mailgun
16
16
  end
17
17
 
18
18
  def deliver!(rails_message)
19
- mailgun_message = prepare_mailgun_message_for(rails_message)
20
- remove_empty_values mailgun_message
21
- mailgun_client.send_message mailgun_message
19
+ mailgun_client.send_message build_mailgun_message_for(rails_message)
22
20
  end
23
21
 
24
22
  private
25
23
 
26
- def prepare_mailgun_message_for(rails_message)
27
- mailgun_message = build_basic_mailgun_message_from_rails_message rails_message
28
-
29
- prepare_reply_to rails_message, mailgun_message if rails_message.reply_to
30
- prepare_mailgun_variables rails_message, mailgun_message
31
- prepare_mailgun_recipient_variables rails_message, mailgun_message
24
+ def build_mailgun_message_for(rails_message)
25
+ mailgun_message = build_basic_mailgun_message_for rails_message
26
+ transform_mailgun_attributes_from_rails rails_message, mailgun_message
27
+ remove_empty_values mailgun_message
32
28
 
33
29
  mailgun_message
34
30
  end
35
31
 
36
- def build_basic_mailgun_message_from_rails_message(rails_message)
37
- {:from => rails_message.from, :to => rails_message.to, :subject => rails_message.subject,
32
+ def transform_mailgun_attributes_from_rails(rails_message, mailgun_message)
33
+ transform_reply_to rails_message, mailgun_message if rails_message.reply_to
34
+ transform_mailgun_variables rails_message, mailgun_message
35
+ transform_mailgun_recipient_variables rails_message, mailgun_message
36
+ end
37
+
38
+ def build_basic_mailgun_message_for(rails_message)
39
+ {:from => rails_message[:from].formatted, :to => rails_message[:to].formatted, :subject => rails_message.subject,
38
40
  :html => extract_html(rails_message), :text => extract_text(rails_message)}
39
41
  end
40
42
 
41
- def prepare_reply_to(rails_message, mailgun_message)
42
- mailgun_message['h:Reply-To'] = rails_message.reply_to
43
+ def transform_reply_to(rails_message, mailgun_message)
44
+ mailgun_message['h:Reply-To'] = rails_message.reply_to.first
43
45
  end
44
46
 
45
47
  # @see http://stackoverflow.com/questions/4868205/rails-mail-getting-the-body-as-plain-text
@@ -59,13 +61,13 @@ module Mailgun
59
61
  end
60
62
  end
61
63
 
62
- def prepare_mailgun_variables(rails_message, mailgun_message)
64
+ def transform_mailgun_variables(rails_message, mailgun_message)
63
65
  rails_message.mailgun_variables.try(:each) do |name, value|
64
66
  mailgun_message["v:#{name}"] = value
65
67
  end
66
68
  end
67
69
 
68
- def prepare_mailgun_recipient_variables(rails_message, mailgun_message)
70
+ def transform_mailgun_recipient_variables(rails_message, mailgun_message)
69
71
  mailgun_message['recipient-variables'] = rails_message.mailgun_recipient_variables.to_json if rails_message.mailgun_recipient_variables
70
72
  end
71
73
 
@@ -79,4 +81,4 @@ module Mailgun
79
81
  end
80
82
  end
81
83
 
82
- ActionMailer::Base.add_delivery_method :mailgun, Mailgun::Deliverer
84
+ ActionMailer::Base.add_delivery_method :mailgun, Mailgun::Deliverer
@@ -1,3 +1,3 @@
1
1
  module Mailgun
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailgun_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-29 00:00:00.000000000 Z
12
+ date: 2013-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 3.2.13
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.13
30
30
  - !ruby/object:Gem::Dependency
@@ -91,7 +91,8 @@ files:
91
91
  - Rakefile
92
92
  - README.rdoc
93
93
  homepage: https://github.com/jorgemanrubia/mailgun_rails/
94
- licenses: []
94
+ licenses:
95
+ - MIT
95
96
  post_install_message:
96
97
  rdoc_options: []
97
98
  require_paths:
@@ -104,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
105
  version: '0'
105
106
  segments:
106
107
  - 0
107
- hash: 2196270500897695838
108
+ hash: 1001558418500426276
108
109
  required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  none: false
110
111
  requirements:
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  version: '0'
114
115
  segments:
115
116
  - 0
116
- hash: 2196270500897695838
117
+ hash: 1001558418500426276
117
118
  requirements: []
118
119
  rubyforge_project:
119
120
  rubygems_version: 1.8.23