griddler-mailgun 1.0.0 → 1.0.1

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: 7b056d51cbc72ddb86286d5bc79ef3173ac5d266
4
- data.tar.gz: 7d9753839331a38a462d32a19aff575853aea364
3
+ metadata.gz: 35285f68548904ddab1f410fce0f047ab4681e5c
4
+ data.tar.gz: fae1d9a3d9b469dd0b020f098fa97647cd2f8ae3
5
5
  SHA512:
6
- metadata.gz: 30e9313154d7578aa97d99db8c24e34e88dffa7284b5da31901b9197da5a126c95ae1cd294d8a9be758fe8b253bd12217203dd9a51672cf382b9d9778d96a8ed
7
- data.tar.gz: 2ea37a65cacdea9c34d47e2589e2580ef1992305e49874f0acc476bb158e1e2d55f620f5b1a5d8263114208c7975aa0c406bdabe33fdb38ed68302e33f26d785
6
+ metadata.gz: 61908cb6d794afd73bd556a43bcba8ed64265d1e44f824595d4d9d39097ce6058746c17b6bf2837b460ebed945b1ab3054da3a6967975a1463a92923b2521b25
7
+ data.tar.gz: 756b89b4186b0b117e8fd41b605ef1d18d47d20f9fb893b8e8eacb9ff0f2a401ce56c443fd0b07217610ad945ace8c088904a06ae9aad8f0ffc4ed2553528989
data/README.md CHANGED
@@ -5,13 +5,15 @@
5
5
  This was extracted from the [griddler gem](https://github.com/thoughtbot/griddler) and is used to
6
6
  parse emails forwarded to your application from [mailgun](http://mailgun.com/).
7
7
 
8
+ **IMPORTANT:** Please use version 1.0.1 or higher. There was a bug in version 1.0.0.
9
+
8
10
  ## Installation
9
11
 
10
12
  Add this line to your application's Gemfile:
11
13
 
12
14
  ```ruby
13
- gem 'griddler'
14
- gem 'griddler-mailgun'
15
+ gem 'griddler', '~> 1.0.0'
16
+ gem 'griddler-mailgun', '~> 1.0.1'
15
17
  ```
16
18
 
17
19
  Then execute:
@@ -18,8 +18,7 @@ module Griddler
18
18
  subject: params[:subject],
19
19
  text: params['body-plain'],
20
20
  html: params['body-html'],
21
- attachments: attachment_files,
22
- headers: headers
21
+ attachments: attachment_files
23
22
  }
24
23
  end
25
24
 
@@ -39,7 +38,7 @@ module Griddler
39
38
  end
40
39
 
41
40
  def cc_recipients
42
- cc = param_or_header(:Cc)
41
+ cc = param_or_header(:Cc) || ''
43
42
  cc.split(',').map(&:strip)
44
43
  end
45
44
 
@@ -48,19 +47,21 @@ module Griddler
48
47
  end
49
48
 
50
49
  def extract_headers
51
- return nil unless params['message-headers']
52
-
53
50
  extracted_headers = {}
54
- parsed_headers = JSON.parse(params['message-headers'])
55
- parsed_headers.each{ |h| extracted_headers[h[0]] = h[1] }
51
+ if params['message-headers']
52
+ parsed_headers = JSON.parse(params['message-headers'])
53
+ parsed_headers.each{ |h| extracted_headers[h[0]] = h[1] }
54
+ end
56
55
  ActiveSupport::HashWithIndifferentAccess.new(extracted_headers)
57
56
  end
58
57
 
59
58
  def param_or_header(key)
60
59
  if params[key].present?
61
60
  params[key]
62
- else
61
+ elsif headers[key].present?
63
62
  headers[key]
63
+ else
64
+ nil
64
65
  end
65
66
  end
66
67
 
@@ -1,5 +1,5 @@
1
1
  module Griddler
2
2
  module Mailgun
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -7,6 +7,12 @@ describe Griddler::Mailgun::Adapter do
7
7
  end
8
8
 
9
9
  describe Griddler::Mailgun::Adapter, '.normalize_params' do
10
+ it 'works with Griddler::Email' do
11
+ normalized_params = Griddler::Mailgun::Adapter.normalize_params(default_params)
12
+ griddler_email = Griddler::Email.new(normalized_params)
13
+ expect(griddler_email.class).to eq Griddler::Email
14
+ end
15
+
10
16
  it 'falls back to headers for cc' do
11
17
  params = default_params.merge(Cc: '')
12
18
  normalized_params = Griddler::Mailgun::Adapter.normalize_params(params)
@@ -60,6 +66,7 @@ describe Griddler::Mailgun::Adapter, '.normalize_params' do
60
66
 
61
67
  it 'handles missing params' do
62
68
  normalized_params = Griddler::Mailgun::Adapter.normalize_params(short_params)
69
+ expect(normalized_params[:to]).to eq ['johndoe@example.com']
63
70
  end
64
71
 
65
72
  def upload_1
@@ -93,12 +100,13 @@ describe Griddler::Mailgun::Adapter, '.normalize_params' do
93
100
  end
94
101
 
95
102
  def short_params
96
- params = {
97
- To: 'Hello World <hi@example.com>',
98
- From: 'There <there@example.com>',
99
- Cc: 'emily@example.com',
100
- 'body-plain' => 'hi',
101
- }
103
+ params = ActiveSupport::HashWithIndifferentAccess.new(
104
+ {
105
+ "from" => "Jon Snow <jon@example.com>",
106
+ "recipient" => "johndoe@example.com",
107
+ "body-plain" => "hi"
108
+ }
109
+ )
102
110
  end
103
111
 
104
112
  def default_params
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: griddler-mailgun
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Pauly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake