mailgun_rails 0.8.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb4aa63218033ccf4340f3604dd2e269480e362c
4
- data.tar.gz: b391fcad06be6a5895df2e02d7ee47959b433f9b
3
+ metadata.gz: 63183189eacb0c20e4a14087e07e86e9b4624d01
4
+ data.tar.gz: f7f9035897ab07b44cd3b918212b148d943bab45
5
5
  SHA512:
6
- metadata.gz: 46afabe284fa2c4d3a6375cfef6a73a8d09517f06799e33d5e619571115d7c6fd8605ce67aee2d75d6c83dfb36ef6802b1dc3550f65c2b9f24ad3f4f871c0ec0
7
- data.tar.gz: 0214e74df375fde905767e1fa0a51e2707754b3be02be37895e34234be908740787463f09e6e274efb3b101d11968ccf337015376285d4ed1b8db77f3eb58269
6
+ metadata.gz: f2815255a0acc510d7c3a23d9c03e9ab7a9a71ef7ed38ea48f28706bd74ec04da66b3ed8a4d4e3104b20b2d667e76a85729cc11e4a090e5be1c29057d87afa66
7
+ data.tar.gz: e97e56b7f3ab995a704192dd87c541151491c8ab1d6abcca2d192a796d4636867199d93cfcd7c5d5ec28db244124526023fcaf86b99873c234c5acd8af9aeab8
@@ -2,7 +2,7 @@ require 'action_mailer'
2
2
  require 'json'
3
3
 
4
4
 
5
- Dir[File.dirname(__FILE__) + '/mailgun/*.rb'].each {|file| require file }
5
+ Dir[File.dirname(__FILE__) + '/mailgun_rails/*.rb'].each {|file| require file }
6
6
 
7
- module Mailgun
7
+ module MailgunRails
8
8
  end
@@ -1,4 +1,4 @@
1
- module Mailgun
1
+ module MailgunRails
2
2
  class Attachment < StringIO
3
3
  attr_reader :original_filename, :content_type, :path
4
4
 
@@ -0,0 +1,31 @@
1
+ require 'rest_client'
2
+
3
+
4
+ module MailgunRails
5
+ class Client
6
+ attr_reader :api_key, :domain, :verify_ssl
7
+
8
+ def initialize(api_key, domain, verify_ssl = true)
9
+ @api_key = api_key
10
+ @domain = domain
11
+ @verify_ssl = verify_ssl
12
+ end
13
+
14
+ def send_message(options)
15
+ RestClient::Request.execute(
16
+ method: :post,
17
+ url: mailgun_url,
18
+ payload: options,
19
+ verify_ssl: verify_ssl
20
+ )
21
+ end
22
+
23
+ def mailgun_url
24
+ api_url+"/messages"
25
+ end
26
+
27
+ def api_url
28
+ "https://api:#{api_key}@api.mailgun.net/v3/#{domain}"
29
+ end
30
+ end
31
+ end
@@ -1,4 +1,4 @@
1
- module Mailgun
1
+ module MailgunRails
2
2
  class Deliverer
3
3
 
4
4
  attr_accessor :settings
@@ -15,6 +15,11 @@ module Mailgun
15
15
  self.settings[:api_key]
16
16
  end
17
17
 
18
+ def verify_ssl
19
+ #default value = true
20
+ self.settings[:verify_ssl] != false
21
+ end
22
+
18
23
  def deliver!(rails_message)
19
24
  response = mailgun_client.send_message build_mailgun_message_for(rails_message)
20
25
  if response.code == 200
@@ -63,9 +68,9 @@ module Mailgun
63
68
  rails_message.attachments.each do |attachment|
64
69
  # then add as a file object
65
70
  if attachment.inline?
66
- mailgun_message[:inline] << Mailgun::Attachment.new(attachment, encoding: 'ascii-8bit', inline: true)
71
+ mailgun_message[:inline] << MailgunRails::Attachment.new(attachment, encoding: 'ascii-8bit', inline: true)
67
72
  else
68
- mailgun_message[:attachment] << Mailgun::Attachment.new(attachment, encoding: 'ascii-8bit')
73
+ mailgun_message[:attachment] << MailgunRails::Attachment.new(attachment, encoding: 'ascii-8bit')
69
74
  end
70
75
  end
71
76
 
@@ -116,13 +121,14 @@ module Mailgun
116
121
  end
117
122
 
118
123
  def remove_empty_values(mailgun_message)
119
- mailgun_message.delete_if { |key, value| value.nil? }
124
+ mailgun_message.delete_if { |key, value| value.nil? or
125
+ value.respond_to?(:empty?) && value.empty? }
120
126
  end
121
127
 
122
128
  def mailgun_client
123
- @mailgun_client ||= Client.new(api_key, domain)
129
+ @maingun_client ||= Client.new(api_key, domain, verify_ssl)
124
130
  end
125
131
  end
126
132
  end
127
133
 
128
- ActionMailer::Base.add_delivery_method :mailgun, Mailgun::Deliverer
134
+ ActionMailer::Base.add_delivery_method :mailgun, MailgunRails::Deliverer
@@ -0,0 +1,3 @@
1
+ module MailgunRails
2
+ VERSION = "0.9.0"
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Manrubia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-15 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -90,12 +90,12 @@ files:
90
90
  - MIT-LICENSE
91
91
  - README.rdoc
92
92
  - Rakefile
93
- - lib/mailgun/attachment.rb
94
- - lib/mailgun/client.rb
95
- - lib/mailgun/deliverer.rb
96
- - lib/mailgun/mail_ext.rb
97
- - lib/mailgun/version.rb
98
93
  - lib/mailgun_rails.rb
94
+ - lib/mailgun_rails/attachment.rb
95
+ - lib/mailgun_rails/client.rb
96
+ - lib/mailgun_rails/deliverer.rb
97
+ - lib/mailgun_rails/mail_ext.rb
98
+ - lib/mailgun_rails/version.rb
99
99
  homepage: https://github.com/jorgemanrubia/mailgun_rails/
100
100
  licenses:
101
101
  - MIT
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.2.2
119
+ rubygems_version: 2.5.1
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Rails Action Mailer adapter for Mailgun
@@ -1,25 +0,0 @@
1
- require 'rest_client'
2
-
3
-
4
- module Mailgun
5
- class Client
6
- attr_reader :api_key, :domain
7
-
8
- def initialize(api_key, domain)
9
- @api_key = api_key
10
- @domain = domain
11
- end
12
-
13
- def send_message(options)
14
- RestClient.post mailgun_url, options
15
- end
16
-
17
- def mailgun_url
18
- api_url+"/messages"
19
- end
20
-
21
- def api_url
22
- "https://api:#{api_key}@api.mailgun.net/v3/#{domain}"
23
- end
24
- end
25
- end
@@ -1,3 +0,0 @@
1
- module Mailgun
2
- VERSION = "0.8.0"
3
- end