witch 0.0.3 → 0.0.4

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -123
  3. data/lib/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a844251fad9136572ae168e4ccec604679651caf
4
- data.tar.gz: 51f9b573a0bfcb8b59885ed2d88e5c518455d7b4
3
+ metadata.gz: 64a969de8320e9adb6c72c13be3ae3d13c51eaeb
4
+ data.tar.gz: 403a58d810b091e25dfa7c43d5e9382daa8707b9
5
5
  SHA512:
6
- metadata.gz: 47e2ab33086fa1b4bc303dd5fddd3fdb3abca21d43dd263a4ba7db1990bf23bd2236d61eb37552febae197018277c674f8a8490391ffa11fa41e824e36ae4f5f
7
- data.tar.gz: 015e88a9dbb40aaa85f321bb086a3d809c249811252429d0803f7a7a60d26101ed3147f6cc0ce98c173ebe155ef5d426ff3b3683041bd39c526f868e2ebd3638
6
+ metadata.gz: 4e6497fbdc894c06800f665af7cf50c6fad172ad116219c9e3b9c9e26794b7f38f3e95ff24b1d7105dfbf1c6560396d19a37c3948c8166fde2ac56c3128518e0
7
+ data.tar.gz: 70895fc62110b11c42c350d357a19c3babf3c5c05d4d2a5bd2c5fa2a68a8457411761cbd3deb3d1160d8b9821bec3b2de8bf2f51e5506296ce0e338384c30ac2
data/README.md CHANGED
@@ -1,140 +1,37 @@
1
- Tuktuk - SMTP client for Ruby
2
- =============================
3
-
4
- Unlike famous ol' Pony gem (which is friggin' awesome by the way), Tuktuk does not rely on
5
- `sendmail` or a separate SMTP server in order to deliver email. Tuktuk looks up the
6
- MX servers of the destination address and connects directly using Net::SMTP.
7
- This way you don't need to install Exim or Postfix and you can actually handle
8
- response status codes -- like bounces, 5xx -- within your application.
9
-
10
- Plus, it supports DKIM out of the box.
11
-
12
- Delivering mail
13
- ---------------
1
+ Witch
2
+ =====
14
3
 
15
4
  ``` ruby
16
- require 'tuktuk'
17
5
 
18
- message = {
19
- :from => 'you@username.com',
20
- :to => 'user@yoursite.com',
21
- :body => 'Hello there',
22
- :subject => 'Hiya'
23
- }
6
+ # foo.rb
7
+ require 'witch'
24
8
 
25
- response, email = Tuktuk.deliver(message)
26
- ```
27
-
28
- The `response` is either a Net::SMTP::Response object, or a Bounce exception (HardBounce or SoftBounce, depending on the cause). `email` is a [mail](https://github.com/mikel/mail) object. So, to handle bounces you'd do:
9
+ Witch.init(:queue => 'events')
29
10
 
30
- ``` ruby
31
- [...]
32
-
33
- response, email = Tuktuk.deliver(message)
34
-
35
- if response.is_a?(Tuktuk::Bounce)
36
- puts 'Email bounced. Type: ' + response.class.name # => HardBounce or SoftBounce
37
- else
38
- puts 'Email delivered!'
11
+ Witch.once 'hello', do |name|
12
+ Witch.publish('message', "Well hello there #{name}")
39
13
  end
40
- ```
41
-
42
- Delivering multiple
43
- -------------------
44
-
45
- With Tuktuk, you can also deliver multiple messages at once. Depending on the `max_workers` config parameter, Tuktuk will either connect sequentially to the target domain's MX servers, or do it in parallel by spawning threads.
46
-
47
- Tuktuk will try to send all emails targeted for a specific domain on the same SMTP session. If a MX server is not responding -- or times out in the middle --, Tuktuk will try to deliver the remaining messages to next MX server, and so on.
48
-
49
- To #deliver_many, you need to pass an array of messages, and you'll receive an array of [response, email] elements, just as above.
50
-
51
- ``` ruby
52
- messages = [ { ... }, { ... }, { ... }, { ... } ] # array of messages
53
-
54
- result = Tuktuk.deliver_many(messages)
55
-
56
- result.each do |response, email|
57
-
58
- if response.is_a?(Tuktuk::Bounce)
59
- puts 'Email bounced. Type: ' + response.class.name
60
- else
61
- puts 'Email delivered!'
62
- end
63
14
 
15
+ Witch.on 'message', do |msg|
16
+ puts "Got message: #{msg}"
64
17
  end
65
- ```
66
-
67
- Options & DKIM
68
- --------------
69
18
 
70
- Now, if you want to enable DKIM (and you should):
71
-
72
- ``` ruby
73
- require 'tuktuk'
19
+ Witch.publish('hello', 'foo')
74
20
 
75
- Tuktuk.options = {
76
- :dkim => {
77
- :domain => 'yoursite.com',
78
- :selector => 'mailer',
79
- :private_key => IO.read('ssl/yoursite.com.key')
80
- }
81
- }
21
+ # bar.rb
22
+ require 'witch'
82
23
 
83
- message = { ... }
24
+ Witch.init(:queue => 'events')
84
25
 
85
- response, email = Tuktuk.deliver(message)
86
- ```
87
-
88
- For DKIM to work, you need to set up some TXT records in your domain's DNS. You can use [this tool](http://www.socketlabs.com/domainkey-dkim-generation-wizard/) to generate the key. You should also create [SPF records](http://www.spfwizard.net/) if you haven't.
89
-
90
- All available options, with their defaults:
91
-
92
- ``` ruby
93
- Tuktuk.options = {
94
- :log_to => nil, # e.g. log/mailer.log or STDOUT
95
- :helo_domain => nil, # your server's domain goes here
96
- :max_workers => 0, # controls number of threads for delivering_many emails (read below)
97
- :open_timeout => 20, # max seconds to wait for opening a connection
98
- :read_timeout => 20, # 20 seconds to wait for a response, once connected
99
- :verify_ssl => true, # whether to skip SSL keys verification or not
100
- :debug => false, # connects and delivers email to localhost, instead of real target server. CAUTION!
101
- :dkim => { ... }
102
- }
103
- ```
104
-
105
- You can set the `max_threads` option to `auto`, which will spawn the necessary threads to connect in paralell to all target MX servers when delivering multiple messages. When set to `0`, these batches will be delivered sequentially.
106
-
107
- In other words, if you have three emails targeted to Gmail users and two for Hotmail users, using `auto` Tuktuk will spawn two threads and connect to both servers at once. Using `0` will have email deliveried to one host and then the other.
108
-
109
- Using with Rails
110
- ----------------
111
-
112
- Tuktuk comes with ActionMailer support out of the box. In your environment.rb or environments/{env}.rb:
113
-
114
- ``` ruby
115
- require 'tuktuk/rails'
116
-
117
- [...]
118
-
119
- config.action_mailer.delivery_method = :tuktuk
120
- ```
121
-
122
- Since Tuktuk delivers email directly to the user's MX servers, it's probably a good idea to set `config.action_mailer.raise_delivery_errors` to true. That way you can actually know if an email couldn't make it to its destination.
123
-
124
- When used with ActionMailer, you can pass options using ActionMailer's interface, like this:
125
-
126
- ``` ruby
26
+ Witch.once 'hello', do |name|
27
+ Witch.publish('message', "Well hello there #{name}")
28
+ end
127
29
 
128
- config.action_mailer.delivery_method = :tuktuk
30
+ Witch.on 'message', do |msg|
31
+ puts "Got message: #{msg}"
32
+ end
129
33
 
130
- config.action_mailer.tuktuk_settings = {
131
- :log_to => 'log/mailer.log', # when not set, Tuktuk will use Rails.logger
132
- :dkim => {
133
- :domain => 'yoursite.com',
134
- :selector => 'mailer',
135
- :private_key => IO.read('ssl/yoursite.com.key')
136
- }
137
- }
34
+ Witch.publish('hello', 'bar')
138
35
  ```
139
36
 
140
37
  # Contributions
@@ -1,3 +1,3 @@
1
1
  module Witch
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: witch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomás Pollak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-01 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler