mdarby-mq 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -4,26 +4,51 @@ A Rails gem that generates an MVC stack that does email queuing
4
4
 
5
5
  h3. What it does
6
6
 
7
- I got tire of crappy attempts at queuing emails, so I wrote my own. mq is a generator that generates an MVC stack for queuing emails. It has a UI too.
7
+ mq is a generator that generates an MVC stack for queuing emails. It has a UI too.
8
+ I got tired of dealing with crappy email queuing systems in Rails, so I wrote my own.
8
9
 
9
10
  h3. Requirements
10
11
 
11
- An existing Mailer
12
+ None.
12
13
 
13
14
  h3. How to Install
14
15
 
15
- <pre>sudo gem install mdarby-mq</pre>
16
+ <pre>sudo gem install mdarby-mq -s http://gems.github.com</pre>
16
17
 
17
18
  h3. How to Use
18
19
 
19
- <pre>./script/generate mq EmailModelName MailerModelName</pre>
20
+ Assuming you'd like to name your mq table @Email@, and your Mailer model is named @Notifier@
21
+
22
+ Generate the files necessary for your app:
23
+ <pre>./script/generate mq Email Notifier</pre>
24
+
25
+ mq requires your Mailer methods accept an email address as its first parameter, so a Mailer method should look like:
26
+ <pre>Notifier.send_email_method(email_address)</pre>
27
+
28
+ Of course, you can pass as many parameters as you'd like:
29
+ <pre>Notifier.send_email_method(email_address, some_object, some_other_object, ...)</pre>
30
+
31
+ Queue an email by calling @Email.queue@ with the name of your Notifier method as the first parameter, and the recipient email address as the second parameter, followed by anything else you'd like to pass.
32
+ <pre>Email.queue(:send_email_method, "matt@matt-darby.com")</pre>
33
+
34
+ You can pass multiple email addresses to the @Email.queue@ method and mq will automatically generate individual emails for the recipients.
35
+ <pre>Email.queue(:send_email_method, ["matt@matt-darby.com", "foo@bar.com"], ...)</pre>
36
+
37
+ h3. Delivery of queued email
38
+
39
+ You can create a cronjob (this on runs every five minutes)
40
+ <pre>*/5 * * * * cd /path/to/your/app && ./script/runner/Email.deliver_all</pre>
20
41
 
21
42
  h3. How to Test
22
43
 
23
44
  Complete Rspec specs are included automatically. Well, complete aside from view specs as you'll just change the damned things anyway.
24
45
 
46
+ h3. Help
47
+
48
+ Add a ticket to "MQ's Lighthouse Account":http://mdarby.lighthouseapp.com/projects/28699-mq/overview
49
+
25
50
  h3. About the Author
26
51
 
27
52
  My name is Matt Darby. I'm the Lead Web Developer and IT Manager at "Dynamix Engineering":http://dynamix-ltd.com and hold a Master's Degree in Computer Science from "Franklin University":http://franklin.edu in Columbus, OH.
28
53
 
29
- Feel free to check out my "blog":http://blog.matt-darby.com or to "recommend me":http://www.workingwithrails.com/recommendation/new/person/10908-matt-darby
54
+ Feel free to check out my "blog":http://blog.matt-darby.com or to "recommend me":http://www.workingwithrails.com/recommendation/new/person/10908-matt-darby
@@ -39,7 +39,7 @@ class MqGenerator < Rails::Generator::NamedBase
39
39
  m.template "email.rb", File.join('app/models', "#{table_name.singularize}.rb")
40
40
 
41
41
  # Migrations
42
- m.migration_template "create_email_table.rb", "db/migrate", :migration_file_name => "create_mq_table"
42
+ m.migration_template "create_email_table.rb", "db/migrate", :migration_file_name => "create_#{object_name}_table"
43
43
 
44
44
  # Views
45
45
  m.template "views/index.html.erb", File.join("app/views/#{table_name}", "index.html.erb")
@@ -36,7 +36,7 @@ class <%= class_name %> < ActiveRecord::Base
36
36
  private
37
37
 
38
38
  def self.generate_mail(method, address, args)
39
- create!(:mailer_method => method, :tmail => <% mailer_name %>.send("create_#{method}".to_sym, address, *args))
39
+ create!(:mailer_method => method, :tmail => <%= mailer_name %>.send("create_#{method}".to_sym, address, *args))
40
40
  end
41
41
 
42
42
  end
@@ -1,10 +1,10 @@
1
- <tr id="<%%= dom_id(<%= object_name %>) %>
2
- <td><%= object_name %>.to</td>
3
- <td><%= object_name %>.mailer_method</td>
1
+ <tr id="<%%= dom_id(<%= object_name %>) %>">
2
+ <td><%%=<%= object_name %>.to %></td>
3
+ <td><%%=<%= object_name %>.mailer_method %></td>
4
4
  <td><%%= time_ago_in_words(<%= object_name %>.created_at) %> ago</td>
5
5
 
6
6
  <%% if <%= object_name %>.attempts > 0 %>
7
- <td><%= object_name %>.attempts</td>
7
+ <td><%%=<%= object_name %>.attempts %></td>
8
8
  <td><%%= time_ago_in_words(<%= object_name %>.last_attempt_at) %> ago</td>
9
9
  <%% else %>
10
10
  <td>&nbsp;</td>
@@ -12,4 +12,4 @@
12
12
  <%% end %>
13
13
 
14
14
  <td><%%= link_to "Deliver", deliver_<%= object_name %>_path(<%= object_name %>), :method => :get %></td>
15
- <td><%%= link_to 'Delete', <%= object_name %>_path(@<%= object_name %>), :method => :destroy %></td>
15
+ <td><%%= link_to 'Delete', <%= object_name %>_path(<%= object_name %>), :method => :delete %></td>
data/mq.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mq"
3
- s.version = "0.1.1"
4
- s.date = "2009-02-11"
3
+ s.version = "0.1.2"
4
+ s.date = "2009-07-11"
5
5
  s.summary = "An email queue that actually works"
6
6
  s.email = "matt@matt-darby.com"
7
7
  s.homepage = "http://github.com/mdarby/mq"
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  "generators/mq/templates/create_email_table.rb",
17
17
  "generators/mq/templates/email.rb",
18
18
  "generators/mq/templates/emails_controller.rb",
19
- "generators/mq/templates/spec/email_routing_spec.rb",
19
+ "generators/mq/templates/spec/emails_routing_spec.rb",
20
20
  "generators/mq/templates/spec/email_spec.rb",
21
21
  "generators/mq/templates/spec/emails_controller_spec.rb",
22
22
  "generators/mq/templates/views/_email.html.erb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdarby-mq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Darby
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-11 00:00:00 -08:00
12
+ date: 2009-07-11 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -29,7 +29,7 @@ files:
29
29
  - generators/mq/templates/create_email_table.rb
30
30
  - generators/mq/templates/email.rb
31
31
  - generators/mq/templates/emails_controller.rb
32
- - generators/mq/templates/spec/email_routing_spec.rb
32
+ - generators/mq/templates/spec/emails_routing_spec.rb
33
33
  - generators/mq/templates/spec/email_spec.rb
34
34
  - generators/mq/templates/spec/emails_controller_spec.rb
35
35
  - generators/mq/templates/views/_email.html.erb