griddler 1.3.1 → 1.4.0

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: 75f194d5d7ffebb9f599c4e67580b66759b894e7
4
- data.tar.gz: 7b1fe0580a6ec472aa19a05193e064d8140761b4
3
+ metadata.gz: 8f86495d4d8db4365d3cb48c7cb3270aab9b23bb
4
+ data.tar.gz: c4765e837d4102415a3b980503146b6644806126
5
5
  SHA512:
6
- metadata.gz: 5d44196465d1efb54a6c86e1892b487bed74a88e454b6f55ad20330194aa5459758dbc8656cdd601a6aa76db140c69366a33729d2a7f68779e3489c37db84059
7
- data.tar.gz: 5560e05ef5350e6285d92cbebe36415efa4d5e0999d9b175dbd5e934c815c27b9003750f6cf60701d249612696ec79a474b3eb56338198139bc9a5e2e5faaab4
6
+ metadata.gz: 7ab5c192b77282a442a0f1bd0f6a1b386687c694ad68f7eeeeb36d3a7b940e318c43375a64765c9ac4574d1ffe60ce3ab2937dcee262cac297cd85eaee7f9c2e
7
+ data.tar.gz: 98caf933840397cff2dcd5900cb4961e975e10c92f75f91d3c7b9d179bccf8a314e6f17ff8e5cdc6f26b43b6143a02dc2c7d028c6dc20f81b02d17b4fcb3e447
data/README.md CHANGED
@@ -14,7 +14,7 @@ Tutorials
14
14
  ---------
15
15
 
16
16
  * SendGrid wrote a
17
- [great tutorial](http://blog.sendgrid.com/receiving-email-in-your-rails-app-with-griddler/)
17
+ [great tutorial](https://sendgrid.com/blog/receiving-email-in-your-rails-app-with-griddler/)
18
18
  on integrating Griddler with your application.
19
19
  * We have our own blog post on the subject over at
20
20
  [Giant Robots](https://robots.thoughtbot.com/griddler-is-better-than-ever).
@@ -53,6 +53,7 @@ Defaults are shown below with sample overrides following. In
53
53
  ```ruby
54
54
  Griddler.configure do |config|
55
55
  config.processor_class = EmailProcessor # CommentViaEmail
56
+ config.email_class = Griddler::Email # MyEmail
56
57
  config.processor_method = :process # :create_comment (A method on CommentViaEmail)
57
58
  config.reply_delimiter = '-- REPLY ABOVE THIS LINE --'
58
59
  config.email_service = :sendgrid # :cloudmailin, :postmark, :mandrill, :mailgun
@@ -62,6 +63,7 @@ end
62
63
  | Option | Meaning
63
64
  | ------ | -------
64
65
  | `processor_class` | The class Griddler will use to handle your incoming emails.
66
+ | `email_class` | The class Griddler will use to represent an incoming e-mail. It must support an initializer that receives a hash as the only argument. We recommend inheriting it from Griddler::Email or checking this class to see all the methods it responds to.
65
67
  | `processor_method` | The method Griddler will call on the processor class when handling your incoming emails.
66
68
  | `reply_delimiter` | The string searched for that will split your body.
67
69
  | `email_service` | Tells Griddler which email service you are using. The supported email service options are `:sendgrid` (the default), `:cloudmailin` (expects multipart format), `:postmark`, `:mandrill` and `:mailgun`. You will also need to have an appropriate [adapter] gem included in your Gemfile.
@@ -107,6 +109,7 @@ Griddler::Email attributes
107
109
  | `#attachments` | An array of `File` objects containing any attachments.
108
110
  | `#headers` | A hash of headers parsed by `Mail::Header`, unless they are already formatted as a hash when received from the adapter in which case the original hash is returned.
109
111
  | `#raw_headers` | The raw headers included in the message.
112
+ | `#to_h` | A hash of the above attributes.
110
113
 
111
114
  ### Email Addresses
112
115
 
@@ -169,12 +172,14 @@ adapter gem in addition to `griddler`.
169
172
  | mailgun | [griddler-mailgun]
170
173
  | postmark | [griddler-postmark]
171
174
  | sparkpost | [griddler-sparkpost]
175
+ | ses (amazon)| [griddler-ses]
172
176
 
173
177
  [griddler-sendgrid]: https://github.com/thoughtbot/griddler-sendgrid
174
178
  [griddler-mandrill]: https://github.com/wingrunr21/griddler-mandrill
175
179
  [griddler-mailgun]: https://github.com/bradpauly/griddler-mailgun
176
180
  [griddler-postmark]: https://github.com/r38y/griddler-postmark
177
181
  [griddler-sparkpost]: https://github.com/PrestoDoctor/griddler-sparkpost
182
+ [griddler-ses]: https://github.com/85x14/griddler-ses
178
183
 
179
184
  Writing an Adapter
180
185
  ------------------
@@ -1,7 +1,7 @@
1
1
  class Griddler::EmailsController < ActionController::Base
2
2
  def create
3
3
  normalized_params.each do |p|
4
- process_email Griddler::Email.new(p)
4
+ process_email email_class.new(p)
5
5
  end
6
6
 
7
7
  head :ok
@@ -9,9 +9,9 @@ class Griddler::EmailsController < ActionController::Base
9
9
 
10
10
  private
11
11
 
12
- delegate :processor_class, :processor_method, :email_service, to: :griddler_configuration
12
+ delegate :processor_class, :email_class, :processor_method, :email_service, to: :griddler_configuration
13
13
 
14
- private :processor_class, :processor_method, :email_service
14
+ private :processor_class, :email_class, :processor_method, :email_service
15
15
 
16
16
  def normalized_params
17
17
  Array.wrap(email_service.normalize_params(params))
@@ -17,6 +17,7 @@ module Griddler
17
17
 
18
18
  class Configuration
19
19
  attr_accessor :processor_method, :reply_delimiter
20
+ attr_writer :email_class
20
21
 
21
22
  def processor_class
22
23
  @processor_class ||=
@@ -36,6 +37,10 @@ module Griddler
36
37
  @processor_class = klass.to_s
37
38
  end
38
39
 
40
+ def email_class
41
+ @email_class ||= Griddler::Email
42
+ end
43
+
39
44
  def processor_method
40
45
  @processor_method ||= :process
41
46
  end
@@ -28,6 +28,23 @@ module Griddler
28
28
  @attachments = params[:attachments]
29
29
  end
30
30
 
31
+ def to_h
32
+ @to_h ||= {
33
+ to: to,
34
+ from: from,
35
+ cc: cc,
36
+ bcc: bcc,
37
+ subject: subject,
38
+ body: body,
39
+ raw_body: raw_body,
40
+ raw_text: raw_text,
41
+ raw_html: raw_html,
42
+ headers: headers,
43
+ raw_headers: raw_headers,
44
+ attachments: attachments,
45
+ }
46
+ end
47
+
31
48
  private
32
49
 
33
50
  attr_reader :params
@@ -81,7 +81,7 @@ module Griddler::EmailParser
81
81
  /^[[:space:]]*[-]+[[:space:]]*Original Message[[:space:]]*[-]+[[:space:]]*$/i,
82
82
  /^[[:space:]]*--[[:space:]]*$/,
83
83
  /^[[:space:]]*\>?[[:space:]]*On.*\r?\n?.*wrote:\r?\n?$/,
84
- /^On.*<\n?.*>.*\n?wrote:$/,
84
+ /^On.*<\r?\n?.*>.*\r?\n?wrote:\r?\n?$/,
85
85
  /On.*wrote:/,
86
86
  /\*?From:.*$/i,
87
87
  /^[[:space:]]*\d{4}[-\/]\d{1,2}[-\/]\d{1,2}[[:space:]].*[[:space:]]<.*>?$/i
@@ -1,3 +1,3 @@
1
1
  module Griddler
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: griddler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Thompson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-03-23 00:00:00.000000000 Z
14
+ date: 2017-02-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.5.1
144
+ rubygems_version: 2.5.2
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: SendGrid Parse API client Rails Engine