contactology-mailer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in contactology-mailer.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "contactology-mailer/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "contactology-mailer"
7
+ s.version = Contactology::Mailer::VERSION
8
+ s.authors = ["Nathaniel Bibler"]
9
+ s.email = ["git@nathanielbibler.com"]
10
+ s.homepage = "https://github.com/nbibler/contactology-mailer"
11
+ s.summary = %q{An ActionMailer interface to sending Contactology transactional campaigns}
12
+ s.description = %q{Using the contactology gem, this library provides a Contactology::Mailer to provide simple integration with sending Contactology transactional campaigns.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency 'contactology', '~>1.1'
20
+ s.add_dependency 'actionmailer', '~>2.3.0'
21
+ end
@@ -0,0 +1,46 @@
1
+ require "contactology-mailer/version"
2
+
3
+ module Contactology
4
+ class Mailer < ActionMailer::Base
5
+ UnrecognizedCampaignError = Class.new(RuntimeError)
6
+
7
+ private
8
+
9
+ def self.method_missing(method_symbol, *parameters, &block)
10
+ if method_symbol.id2name.match(/^deliver_([_a-z]\w*)/)
11
+ deliver_contactology_mail($1, *parameters)
12
+ else
13
+ super
14
+ end
15
+ end
16
+
17
+ def self.deliver_contactology_mail(method, *params)
18
+ mail = new
19
+ mail.__send__(method, *params)
20
+
21
+ return unless perform_deliveries
22
+
23
+ if delivery_method == :test
24
+ deliveries << (mail.mail ? mail.mail : mail)
25
+ else
26
+ all_recipients = [mail.recipients].flatten.compact
27
+ results = all_recipients.collect do |recipient|
28
+ mail.recipients = recipient
29
+ call_api!(mail, method)
30
+ end
31
+ results.all? { |r| r.is_a?(TrueClass) }
32
+ end
33
+ end
34
+
35
+ def self.call_api!(mail, method)
36
+ if campaign = Contactology::Campaign.find_by_name(method)
37
+ campaign.send_campaign(
38
+ Struct.new(:email).new(mail.recipients), {
39
+ :replacements => mail.body
40
+ }).successful?
41
+ else
42
+ raise UnrecognizedCampaignError, "No Contactology campaign found named \"#{method}\"."
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module Contactology
2
+ module Mailer
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: contactology-mailer
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Nathaniel Bibler
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-25 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: contactology
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 13
29
+ segments:
30
+ - 1
31
+ - 1
32
+ version: "1.1"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: actionmailer
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 2
46
+ - 3
47
+ - 0
48
+ version: 2.3.0
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ description: Using the contactology gem, this library provides a Contactology::Mailer to provide simple integration with sending Contactology transactional campaigns.
52
+ email:
53
+ - git@nathanielbibler.com
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ extra_rdoc_files: []
59
+
60
+ files:
61
+ - .gitignore
62
+ - Gemfile
63
+ - Rakefile
64
+ - contactology-mailer.gemspec
65
+ - lib/contactology-mailer.rb
66
+ - lib/contactology-mailer/version.rb
67
+ homepage: https://github.com/nbibler/contactology-mailer
68
+ licenses: []
69
+
70
+ post_install_message:
71
+ rdoc_options: []
72
+
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project:
96
+ rubygems_version: 1.8.5
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: An ActionMailer interface to sending Contactology transactional campaigns
100
+ test_files: []
101
+