monkey-mailer 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGY5ZDE2MGNhZDNlYzcyYzcxNzFjNjk4MTQxMTliNmQ5MGIyZWViMQ==
4
+ YjViOWIzNTk3ZGEyMWFhMTFhNTE5NTA2NTI4ZWE4MDNiMmQ4MDU5Yw==
5
5
  data.tar.gz: !binary |-
6
- MDUzZmUxMGY3YzZjZGFkYjMwNmZjNWMxNGVjODdiODcyMjdhMzYxNw==
6
+ YTViODJjZjExZWRmMjM0YzljMjQwZThjYjZhZGNmOGEzMTRhZGNiYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGJlNjY4ZmQ5ODA1Y2UxNGU2NGU4ZDQ4ZDExYzYxNzA3NDY4MTIyMjVhNGYy
10
- ZWYwYTAyYmE2ZTQ4YTY1OTMyMjk0NGJkYzk0YWFjZDdmMmE0ZWI1ZWY2NDc3
11
- ODgxNGMyNjA3NGJmOWNjNmZhMzFjMTIzN2EyYTc0ZTRkYWU1NDQ=
9
+ NjkwNzJlODAzZDVhZWNlYjMxMzI2OWQ0OGE0MjA5NmRkNmVjYmVlMzgxMDk1
10
+ OTJhZWM0ZTk4MTNjZjRmMWE0MzM5Y2M1MDk2MTQxNTkwOTg1Y2VhNTk1MTMw
11
+ NjU3YjdiYmUzY2QzOWViMTNkYWYzMWY3NTU2YmY2OGRkMjVlYjk=
12
12
  data.tar.gz: !binary |-
13
- MTg1NzAxZTUwOTRiZjllM2NmNzU0ODMzYTg2MTkzMmVkZjYxMDFhMzJiOWFk
14
- MzJlYWZiYjEzYzQxYzdkMDg1ODA4YzEyZDQzZWNkYTYxNDdmNjg1MzIxOWQ2
15
- OWY2MDNmNDRmNzFiOGE1ODc1Mjk1ZmM2OWVmMDVlNWVlMmY1N2Q=
13
+ YmUxYTg4MDRjZjM2MmUzMjIzZTZmYWE2NzY1MTg4OGM0OWMzZGMxYjM2ZmMy
14
+ YWM1NjFjNjU1NWZkY2FhODljZTY5NDg4MDBjMWNjMWU0YjI1MWQzYjA4OGM2
15
+ OWM3MTM2YjQyNTlmOTliNTNhMzAyODAxYzNjMjdmZWU3ZWMwMjE=
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+
3
+ script: "bundle exec rspec"
4
+ before_install:
5
+ - gem install bundler
data/README.md CHANGED
@@ -1,11 +1,18 @@
1
+ [![Build Status](https://travis-ci.org/fsaravia/monkey-mailer.png)](https://travis-ci.org/fsaravia/monkey-mailer)
2
+ [![Code Climate](https://codeclimate.com/github/fsaravia/monkey-mailer.png)](https://codeclimate.com/github/fsaravia/monkey-mailer)
3
+
1
4
  Monkey Mailer
2
5
  ======
3
6
 
4
7
  ## Description
5
- Monkey Mailer is a gem that allows handling a mailing queue, it supports email priority (urgent, normal and low priorities) and is higly customizable.
6
- Emails can be loaded from different data sources using Loader gems (See below), feel free to contribute a loader with your preferred datastore!
7
- Once loaded, emails can be sent using either SMTP or [Mailchimp's Mandril API](http://mandrill.com/)
8
- After setup, Monkey Mailer can be configured to run and process your emails in a infinite loop until you stop it, it uses the [fallen](https://github.com/inkel/fallen/) gem, to run as a daemon in your server
8
+ Monkey Mailer is a gem that allows building a service for handling an email queue, it supports priority (urgent, normal and low priorities) and is higly customizable.
9
+ Emails can be loaded from different data sources using `loader` plugins (See below), it uses priority to determine which mails will be sent as soon as they are queued and which mails can wait
10
+ Once loaded, emails can be sent using either SMTP or [Mailchimp's Mandril API](http://mandrill.com/), they are `adapters` and, as with `loaders`, MonkeyMailer can be easily extended to work with the email provider of your choice
11
+ After setup, Monkey Mailer can be configured to run and process your emails in a infinite loop until you stop it, it uses the [fallen](https://github.com/inkel/fallen/) gem, to run as a daemon in your server
12
+ The principle behind MonkeyMailer's functionality is simple, it runs an infinite loop, within that loop it asks the `adapter` for emails to send. And this is where priority becomes important:
13
+ * `Urgent` mails are loaded and sent on every iteration
14
+ * `Normal` and `Low` priority emails are loaded and sent after a certain number of iterations have passed
15
+ Also, in order to avoid problems with your email provider, all priorities have a quota, so if there are many urgent emails to send, MonkeyMailer will only load and send a certain number on each iteration
9
16
 
10
17
  ## Instalation
11
18
  gem install monkey-mailer
@@ -28,10 +35,10 @@ Adapters are classes that send your emails using different providers. MonkeyMail
28
35
  * `MonkeyMailer::Adapters::MandrilAPI`
29
36
  * `MonkeyMailer::Adapters::Smtp`
30
37
 
31
- Any adapter receives its settings by setting up MonkeyMailer.configuration.adapter_options, check out each loader for specific options
38
+ Any adapter receives its settings by setting up MonkeyMailer.configuration.adapter_options, check out each one for specific options
32
39
 
33
40
  ##Dummy loader and adapter
34
- Test adapter and loader are provided within MonkeyMailer so you can play with them for testing purposes:
41
+ Test adapter and loader are provided within MonkeyMailer so you can play with them:
35
42
 
36
43
  * Dummy loader: `MonkeyMailer::Loaders::Dummy` # It generates random emails for adapters to consume
37
44
  * Dummy adapter: `MonkeyMailer::Adapters::Dummy` # It just displays the email content on stdout
@@ -45,7 +52,7 @@ Test adapter and loader are provided within MonkeyMailer so you can play with th
45
52
  extend MonkeyMailer
46
53
 
47
54
  MonkeyMailer.configure do |config|
48
- config.adapter = MonkeyMailer::Adapters::MandrilAPI, # Method used to send emails
55
+ config.adapter = MonkeyMailer::Adapters::MandrilAPI # Method used to send emails
49
56
  config.adapter_options = {:mandril_api_key => 'YOUR_API_KEY'}
50
57
  config.loader = MonkeyMailer::Loaders::DataMapper #Uses the loader on mm-data_mapper gem to load emails from a database
51
58
  config.loader_options = {
@@ -95,6 +102,27 @@ You can also build your own loader gem, we have thought of some ideas about load
95
102
  * mm-redis
96
103
  * mm-your-storage-of-choice
97
104
 
105
+ ## Building your own loader
106
+ It is painfully easy to write your own loader, just create a class inside `MonkeyMailer::Loaders` module and define this three methods:
107
+ ```ruby
108
+ def initialize(opts)
109
+ # The content of MonkeyMailer.loader_options will be available on opts
110
+ end
111
+
112
+ def find_emails(priority, quota)
113
+ # Return an array of emails with the given priority with a limit of quota
114
+ end
115
+
116
+ def delete_email(end)
117
+ # Delete the email from your data storage, this method will only be called if email sent
118
+ # was successful
119
+ end
120
+ ```
121
+
122
+ ## List of known loaders:
123
+
124
+ * [mm-data_mapper](https://github.com/fsaravia/mm-data_mapper): Uses the DataMapper gem to load emails from a database
125
+
98
126
  ## License
99
127
  See the `UNLICENSE` file included with this gem distribution.
100
128
 
@@ -44,7 +44,7 @@ module MonkeyMailer
44
44
  @request[:message][:from_name] = email.from_name
45
45
  @request[:message][:from_email] = email.from_email
46
46
  @request[:message][:html] = email.body
47
- @request[:message][:text] = email.body.gsub(/<\/?[^>]*>/, "")
47
+ @request[:message][:text] = email.body.gsub(/<\/?[^>]*>/, "") unless email.body.nil?
48
48
  @request[:message][:subject] = email.subject
49
49
 
50
50
  req = Net::HTTP::Post.new('/api/1.0/messages/send.json', initheader = {'Content-Type' =>'application/json'})
@@ -30,7 +30,7 @@ module MonkeyMailer
30
30
  end
31
31
 
32
32
  text_part do
33
- body email.body.gsub(/<\/?[^>]*>/, "")
33
+ body email.body.nil? ? '' : email.body.gsub(/<\/?[^>]*>/, "")
34
34
  end
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module MonkeyMailer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkey-mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lautaro Orazi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-12 00:00:00.000000000 Z
12
+ date: 2013-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clap
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - .gitignore
78
+ - .travis.yml
78
79
  - Gemfile
79
80
  - README.md
80
81
  - UNLICENSE