ar_mailer_revised 1.0.0 → 1.0.1

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: 0aef767abd393af9428a1bbea305cd024d6cf994
4
- data.tar.gz: 4011b3fa47058260ebdeb930c6c2c49ba9396539
3
+ metadata.gz: 0b1e7179059d80144067968beac5f41151eda097
4
+ data.tar.gz: 42554e87ed8bfb15baef54d94a7c0e28e0c7b515
5
5
  SHA512:
6
- metadata.gz: f7f9318aa6523598867b1d62c968d8d3fdc49ecd3842a0922c5525b7a0a87539f2a5c85c95a5048bd4858f8ed8d0687c3eb3a22aadfb58e66f863ce406d5548f
7
- data.tar.gz: 3b51d939495ce060b28aae0fac4df7df49eeec32374d881ce67533badc69d41b6edee65260062f526cd2db53e70b35e0f34d1bb730d4308ab9c285824ad05def
6
+ metadata.gz: 0cb4f0f7c22ebf0e85ff61ded487ac20acf38036e0b8f45dd074923f153aeda836e416af01d73fa14263fe9f2203f76e7b8a653d938e8408f2d670899ccd2d2e
7
+ data.tar.gz: 827bb354ebb58010182591543be6ee60774146de9e5b9f5eda8649f39daf44d6c309c2cd986b3bb7a73e7e9812ce4b133099507b4b6b3613d6b4d0d846f966db
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # ArMailerRevised
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/ar_mailer_revised.svg)](http://badge.fury.io/rb/ar_mailer_revised)
3
4
  [![Code Climate](https://codeclimate.com/github/Stex/ar_mailer_revised.png)](https://codeclimate.com/github/Stex/ar_mailer_revised)
4
- ![Travis CI](https://travis-ci.org/Stex/ar_mailer_revised.svg?branch=rails_4)
5
+ [![Build Status](https://travis-ci.org/Stex/ar_mailer_revised.svg?branch=rails_4)](https://travis-ci.org/Stex/ar_mailer_revised)
5
6
 
6
- [ArMailer](https://github.com/seattlerb/ar_mailer) was a great gem which allows you to store emails in your application's database and batch deliver
7
+ [ArMailer](https://github.com/seattlerb/ar_mailer) is a great gem which allows you to store emails in your application's database and batch deliver
7
8
  them later using a background task.
8
9
 
9
10
  However, it was not compatible with newer versions of Rails and also lacking some of the functionality I needed in my applications.
@@ -57,11 +58,15 @@ add them to the migration before migrating.
57
58
  First of all, you have to set ActionMailer to use the gem's delivery method.
58
59
  This can be done per environment or globally for the application using either
59
60
 
60
- config.action_mailer.delivery_method = :activerecord
61
+ ```ruby
62
+ config.action_mailer.delivery_method = :activerecord
63
+ ```
61
64
 
62
65
  or - not inside a configuration file
63
66
 
64
- ActionMailer::Base.delivery_method = :activerecord
67
+ ```ruby
68
+ ActionMailer::Base.delivery_method = :activerecord
69
+ ```
65
70
 
66
71
  ### SMTP-Settings
67
72
 
@@ -88,13 +93,15 @@ ArMailerRevised uses the normal ActionMailer::Base templates, so you can write
88
93
  deliver-methods like you would for direct email sending.
89
94
  On delivering, the email will be stored in the database and not being sent diretly.
90
95
 
91
- class TestMailer < ActionMailer::Base
92
- default from: 'from@example.com'
93
-
94
- def basic_email
95
- mail(to: 'basic_email@example.com', subject: 'Basic Email Subject', body: 'Basic Email Body')
96
- end
97
- end
96
+ ```ruby
97
+ class TestMailer < ActionMailer::Base
98
+ default from: 'from@example.com'
99
+
100
+ def basic_email
101
+ mail(to: 'basic_email@example.com', subject: 'Basic Email Subject', body: 'Basic Email Body')
102
+ end
103
+ end
104
+ ```
98
105
 
99
106
  ### Setting a custom delivery time
100
107
 
@@ -103,10 +110,12 @@ the resulting email record. One of them is +ar_mailer_delivery_time+.
103
110
  This method sets a time which determines the earliest sending time for this email,
104
111
  in other words: If you set this time, the email won't be sent prior to it.
105
112
 
106
- def delayed_email
107
- ar_mailer_delivery_time Time.now + 2.hours
108
- mail(to: 'delayed_email@example.com', subject: 'Delayed Email Subject', :body => 'Delayed Email Body')
109
- end
113
+ ```ruby
114
+ def delayed_email
115
+ ar_mailer_delivery_time Time.now + 2.hours
116
+ mail(to: 'delayed_email@example.com', subject: 'Delayed Email Subject', :body => 'Delayed Email Body')
117
+ end
118
+ ```
110
119
 
111
120
  **Important**: It may happen that the Rails logging output of the generated mail may still contain
112
121
  custom attributes (like the delivery time) in its header. This happens because ActionMailer will
@@ -117,19 +126,21 @@ log the email before actually delivering it. The generated email will **not** co
117
126
  It is possible to set own SMTP settings for each email in the system which will then be used for delivery.
118
127
  These settings may contain everything the global settings do (see above).
119
128
 
120
- def custom_smtp_email
121
- ar_mailer_smtp_settings({
122
- :address => 'localhost',
123
- :port => 25,
124
- :domain => 'localhost.localdomain',
125
- :user_name => 'some.user',
126
- :password => 'some.password',
127
- :authentication => :plain,
128
- :enable_starttls_auto => true
129
- })
130
-
131
- mail(to: 'custom_smtp_email@example.com', subject: 'Custom SMTP Email Subject', :body => 'Custom SMTP Email Body')
132
- end
129
+ ```ruby
130
+ def custom_smtp_email
131
+ ar_mailer_smtp_settings({
132
+ :address => 'localhost',
133
+ :port => 25,
134
+ :domain => 'localhost.localdomain',
135
+ :user_name => 'some.user',
136
+ :password => 'some.password',
137
+ :authentication => :plain,
138
+ :enable_starttls_auto => true
139
+ })
140
+
141
+ mail(to: 'custom_smtp_email@example.com', subject: 'Custom SMTP Email Subject', :body => 'Custom SMTP Email Body')
142
+ end
143
+ ```
133
144
 
134
145
  **Important**: As the mailer has to use the password to connect to the SMTP server, it is stored in the database in plain text!
135
146
  If this means a security issue to you, please use only the global settings which are loaded from the environment and not stored in the database.
@@ -145,10 +156,12 @@ You can add custom attributes to the email table simply by altering the generate
145
156
 
146
157
  In the email delivering method, these attributes may then be filled with the actual data using the `ar_mailer_attribute` helper method:
147
158
 
148
- def custom_attribute_email
149
- ar_mailer_attribute :a_number, 42
150
- mail(to: 'custom_attribute_email@example.com', subject: 'Custom Attribute Email Subject', :body => 'Custom Attribute Email Body')
151
- end
159
+ ```ruby
160
+ def custom_attribute_email
161
+ ar_mailer_attribute :a_number, 42
162
+ mail(to: 'custom_attribute_email@example.com', subject: 'Custom Attribute Email Subject', :body => 'Custom Attribute Email Body')
163
+ end
164
+ ```
152
165
 
153
166
  ### Sending Emails
154
167
 
@@ -158,9 +171,17 @@ be accessed from the application's root directory.
158
171
  It accepts the argument `-h` (or `--help`), showing all available options.
159
172
  If you call it without options, it will run a single batch sending in the foreground and exist afterwards.
160
173
 
161
- There will be daemon functionality in the future (mostly to avoid loading the application envirionment
174
+ There will be daemon functionality in the future (mostly to avoid loading the application environment
162
175
  every single time emails are being sent), for now I suggest using a gem like [whenever](https://github.com/javan/whenever)
163
176
  to run the executable every X minutes.
177
+
178
+ An entry in whenever's `schedule.rb` might look like this:
179
+
180
+ ```ruby
181
+ every 5.minutes do
182
+ command "cd #{path} && bundle exec ar_sendmail -c #{path} -e production -b 25 --log-file './log/ar_mailer.log' --log-level info"
183
+ end
184
+ ```
164
185
 
165
186
  ### SMTP settings for common providers (to be extended)
166
187
 
@@ -23,7 +23,7 @@ module ArMailerRevised
23
23
 
24
24
  #Applies a +limit+ to the finder if batch_size is set
25
25
  scope :with_batch_size, lambda { |batch_size|
26
- batch_size ? {:limit => batch_size} : {}
26
+ limit(batch_size) if batch_size
27
27
  }
28
28
  end
29
29
 
@@ -240,6 +240,10 @@ module ArMailerRevised
240
240
  end
241
241
  end
242
242
 
243
+ #----------------------------------------------------------------
244
+ # Email Record Alteration
245
+ #----------------------------------------------------------------
246
+
243
247
  #
244
248
  # Adjusts the last send attempt timestamp in the given
245
249
  # email to the current time.
@@ -1,3 +1,3 @@
1
1
  module ArMailerRevised
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_mailer_revised
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
  - Stefan Exner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-29 00:00:00.000000000 Z
11
+ date: 2014-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler