griddler 1.1.0 → 1.1.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: 9a3833d3d95363c7d1c7a96d6078cf765420809e
4
- data.tar.gz: 77d63d65d0711aa139fb0e2eea6a8e57ec1bbcf6
3
+ metadata.gz: e7fb296b5effeac25db3cb6002e6f19cbfe2d50f
4
+ data.tar.gz: 1264bafeb3155a1b2225c0c4f12984c4f1585664
5
5
  SHA512:
6
- metadata.gz: f0542546228a7e7685623346b580ba24768469e5648f3da2124df7447a54cf2f5b3dbe5892f9efcc60ff864cf07e9426f1f459ccfb94fa33313be676148cec77
7
- data.tar.gz: 430a118db9bf578b9c2f43f3274458a248342390db5a109e06fba769ae60f33a7b2bd5e9057e5e0962871deb40a12dfefbc758f1c6fd124a304b22eee83857e1
6
+ metadata.gz: e6accc72dc651295925009e576edcf1674ab3aa43b00e341d55b91b8daad5db06b96c458b538efab2ec2795cb1701ad6c5570741d239bae871ce4fc38a1b29a0
7
+ data.tar.gz: 9820e905ce61d4499ba01b2d013610c666240de18e98aad857c04d1110e95048ec20732305ae59fd6de90bcee248066be70cb4c7776f8f856831522d3c033191
data/README.md CHANGED
@@ -66,9 +66,10 @@ end
66
66
  | `reply_delimiter` | The string searched for that will split your body.
67
67
  | `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.
68
68
 
69
- By default Griddler will look for a class named `EmailProcessor` with a method
70
- named `process`, taking in one argument, a `Griddler::Email` instance
71
- representing the incoming email. For example, in `./lib/email_processor.rb`:
69
+ By default Griddler will look for a class named `EmailProcessor`. The class is
70
+ initialized with a `Griddler::Email` instance representing the incoming
71
+ email, and has a `process` method to actually process the email.
72
+ For example, in `./lib/email_processor.rb`:
72
73
 
73
74
  ```ruby
74
75
  class EmailProcessor
@@ -131,7 +132,7 @@ with the following sample factory:
131
132
  factory :email, class: OpenStruct do
132
133
  # Assumes Griddler.configure.to is :hash (default)
133
134
  to [{ full: 'to_user@email.com', email: 'to_user@email.com', token: 'to_user', host: 'email.com', name: nil }]
134
- from 'user@email.com'
135
+ from({ token: 'from_user', host: 'email.com', email: 'from_email@email.com', full: 'From User <from_user@email.com>', name: 'From User' })
135
136
  subject 'email subject'
136
137
  body 'Hello!'
137
138
  attachments {[]}
@@ -189,7 +190,7 @@ your adapter returns a hash with these keys:
189
190
  | `:from` | The sender field
190
191
  | `:subject` | Email subject
191
192
  | `:text` | The text body of the email
192
- | `:html` | The html body of the email, nil or empty string if not present
193
+ | `:html` | The html body of the email, or an empty string
193
194
  | `:attachments` | Array of attachments to the email. Can be an empty array.
194
195
  | `:headers` | The raw headers of the email. **Optional**.
195
196
  | `:charsets` | A JSON string containing the character sets of the fields extracted from the message. **Optional**.
@@ -22,7 +22,7 @@ module Griddler
22
22
  @processor_class ||=
23
23
  begin
24
24
  if Kernel.const_defined?(:EmailProcessor)
25
- EmailProcessor
25
+ "EmailProcessor"
26
26
  else
27
27
  raise NameError.new(<<-ERROR.strip_heredoc, 'EmailProcessor')
28
28
  To use Griddler, you must either define `EmailProcessor` or configure a
@@ -31,6 +31,12 @@ module Griddler
31
31
  ERROR
32
32
  end
33
33
  end
34
+
35
+ @processor_class.constantize
36
+ end
37
+
38
+ def processor_class=(klass)
39
+ @processor_class = klass.to_s
34
40
  end
35
41
 
36
42
  def processor_method
@@ -3,7 +3,7 @@ require 'htmlentities'
3
3
  module Griddler
4
4
  class Email
5
5
  include ActionView::Helpers::SanitizeHelper
6
- attr_reader :to, :from, :cc, :subject, :body, :raw_body, :raw_text, :raw_html,
6
+ attr_reader :to, :from, :cc, :bcc, :subject, :body, :raw_body, :raw_text, :raw_html,
7
7
  :headers, :raw_headers, :attachments
8
8
 
9
9
  def initialize(params)
@@ -21,6 +21,7 @@ module Griddler
21
21
  @headers = extract_headers
22
22
 
23
23
  @cc = recipients(:cc)
24
+ @bcc = recipients(:bcc)
24
25
 
25
26
  @raw_headers = params[:headers]
26
27
 
@@ -48,7 +49,7 @@ module Griddler
48
49
  end
49
50
 
50
51
  def extract_headers
51
- EmailParser.extract_headers(params[:headers])
52
+ EmailParser.extract_headers(clean_invalid_utf8_bytes(params[:headers]))
52
53
  end
53
54
 
54
55
  def extract_cc_from_headers(headers)
@@ -72,7 +73,7 @@ module Griddler
72
73
  end
73
74
 
74
75
  def clean_invalid_utf8_bytes(text)
75
- if !text.valid_encoding?
76
+ if text && !text.valid_encoding?
76
77
  text = text
77
78
  .force_encoding('ISO-8859-1')
78
79
  .encode('UTF-8')
@@ -81,8 +81,8 @@ RSpec::Matchers.define :be_normalized_to do |expected|
81
81
  match do |actual|
82
82
  expected.each do |k, v|
83
83
  case v
84
- when Regexp then expect(actual[k]).to =~ v
85
- else expect(actual[k]).to === v
84
+ when Regexp then expect(actual[k]).to match(v)
85
+ else expect(actual[k]).to eq(v)
86
86
  end
87
87
  end
88
88
  end
@@ -1,3 +1,3 @@
1
1
  module Griddler
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
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.1.0
4
+ version: 1.1.1
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: 2014-10-03 00:00:00.000000000 Z
14
+ date: 2015-05-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -124,10 +124,7 @@ files:
124
124
  homepage: http://thoughtbot.com
125
125
  licenses: []
126
126
  metadata: {}
127
- post_install_message: |
128
- When upgrading from a Griddler version previous to 0.5.0, it is important that
129
- you view https://github.com/thoughtbot/griddler/#upgrading-to-griddler-050 for
130
- upgrade information.
127
+ post_install_message:
131
128
  rdoc_options: []
132
129
  require_paths:
133
130
  - app