lettr 1.0.4 → 1.1.0
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.
- data/README.md +0 -2
- data/init.rb +6 -1
- data/lib/lettr.rb +7 -0
- data/lib/lettr/action_mailer.rb +2 -32
- data/lib/lettr/deliverable.rb +2 -1
- data/lib/lettr/mail_extensions.rb +44 -0
- metadata +19 -4
data/README.md
CHANGED
|
@@ -13,8 +13,6 @@ For Rails 3.x or if you use Bundler drop the following line into your Gemfile:
|
|
|
13
13
|
|
|
14
14
|
gem 'lettr'
|
|
15
15
|
|
|
16
|
-
NOTE: In a Rails 3 Application you currently cant use Delivery Method nor Lettr::Mailer.
|
|
17
|
-
|
|
18
16
|
## Configuration
|
|
19
17
|
There are some configuration options you can provide either inside config/environment.rb or config/environments/$RAILS_ENV.rb or create an initializer in config/initializers.
|
|
20
18
|
At least you have to provide your lettr login credentials:
|
data/init.rb
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
if defined? ActionMailer::Base
|
|
2
|
-
|
|
2
|
+
if defined? TMail
|
|
3
|
+
ActionMailer::Base.send(:include, Lettr::ActionMailer)
|
|
4
|
+
elsif defined? Mail
|
|
5
|
+
require 'lettr/mail_extensions'
|
|
6
|
+
ActionMailer::Base.add_delivery_method :lettr, Mail::Lettr
|
|
7
|
+
end
|
|
3
8
|
end
|
data/lib/lettr.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
1
2
|
require 'active_support'
|
|
2
3
|
|
|
3
4
|
module Lettr
|
|
@@ -12,6 +13,9 @@ module Lettr
|
|
|
12
13
|
require 'lettr/collection'
|
|
13
14
|
require 'lettr/rendered_mailing'
|
|
14
15
|
require 'lettr/whitelist'
|
|
16
|
+
require 'lettr/action_mailer'
|
|
17
|
+
require 'lettr/mailer'
|
|
18
|
+
require 'lettr/mail_extensions'
|
|
15
19
|
|
|
16
20
|
mattr_accessor :host
|
|
17
21
|
mattr_accessor :attributes
|
|
@@ -83,6 +87,9 @@ module Lettr
|
|
|
83
87
|
end
|
|
84
88
|
|
|
85
89
|
def self.method_missing *args, &block
|
|
90
|
+
if args.first.to_s =~ /^to_/
|
|
91
|
+
super
|
|
92
|
+
end
|
|
86
93
|
load_api_mailing_or_fail_loud *args
|
|
87
94
|
rescue RestClient::ResourceNotFound
|
|
88
95
|
super
|
data/lib/lettr/action_mailer.rb
CHANGED
|
@@ -3,37 +3,7 @@ module Lettr::ActionMailer
|
|
|
3
3
|
private
|
|
4
4
|
|
|
5
5
|
def perform_delivery_lettr mail
|
|
6
|
-
|
|
7
|
-
mail.to.each do |recipient|
|
|
8
|
-
lettr_request_hash = {}
|
|
9
|
-
lettr_request_hash[:recipient] = recipient
|
|
10
|
-
lettr_request_hash[:subject] = mail.subject
|
|
11
|
-
if mail.parts.empty?
|
|
12
|
-
case mail.content_type
|
|
13
|
-
when 'text/html'
|
|
14
|
-
lettr_request_hash[:html] = mail.body
|
|
15
|
-
when 'text/plain'
|
|
16
|
-
lettr_request_hash[:text] = mail.body
|
|
17
|
-
end
|
|
18
|
-
else
|
|
19
|
-
mail.parts.each do |part|
|
|
20
|
-
case part.content_type
|
|
21
|
-
when 'text/html'
|
|
22
|
-
lettr_request_hash[:html] = part.body
|
|
23
|
-
when 'text/plain'
|
|
24
|
-
lettr_request_hash[:text] = part.body
|
|
25
|
-
else
|
|
26
|
-
lettr_request_hash[:attachments] ||= []
|
|
27
|
-
lettr_request_hash[:attachments] << part.body
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
lettr_request_hashes << lettr_request_hash
|
|
32
|
-
end
|
|
33
|
-
identifier = @template
|
|
34
|
-
lettr_request_hashes.each do |lettr_request_hash|
|
|
35
|
-
Lettr.send(identifier, lettr_request_hash).deliver
|
|
36
|
-
end
|
|
37
|
-
|
|
6
|
+
Mail::Lettr.new(:template => @template).deliver! mail
|
|
38
7
|
end
|
|
8
|
+
|
|
39
9
|
end
|
data/lib/lettr/deliverable.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
1
2
|
module Lettr::Deliverable
|
|
2
3
|
|
|
3
4
|
def self.included base
|
|
@@ -30,7 +31,7 @@ module Lettr::Deliverable
|
|
|
30
31
|
group_variables if respond_to? :group_variables
|
|
31
32
|
handle_options
|
|
32
33
|
append_used_variables if respond_to? :append_used_variables
|
|
33
|
-
Rails.logger.debug @hash.inspect
|
|
34
|
+
Rails.logger.debug @hash.inspect if defined? Rails
|
|
34
35
|
|
|
35
36
|
# perform delivery request
|
|
36
37
|
rec = Lettr::Delivery.new @hash, @files
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Mail
|
|
2
|
+
class Lettr
|
|
3
|
+
|
|
4
|
+
def initialize(values={})
|
|
5
|
+
@settings = values
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def deliver!(mail)
|
|
9
|
+
lettr_request_hashes = []
|
|
10
|
+
raise 'no recipient' unless mail.to
|
|
11
|
+
mail.to.each do |recipient|
|
|
12
|
+
lettr_request_hash = {}
|
|
13
|
+
lettr_request_hash[:recipient] = recipient
|
|
14
|
+
lettr_request_hash[:subject] = mail.subject
|
|
15
|
+
if mail.parts.empty?
|
|
16
|
+
case mail.content_type
|
|
17
|
+
when /text\/html/
|
|
18
|
+
lettr_request_hash[:html] = mail.body
|
|
19
|
+
when /text\/plain/
|
|
20
|
+
lettr_request_hash[:text] = mail.body
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
mail.parts.each do |part|
|
|
24
|
+
case part.content_type
|
|
25
|
+
when /text\/html/
|
|
26
|
+
lettr_request_hash[:html] = part.body
|
|
27
|
+
when /text\/plain/
|
|
28
|
+
lettr_request_hash[:text] = part.body
|
|
29
|
+
else
|
|
30
|
+
lettr_request_hash[:attachments] ||= []
|
|
31
|
+
lettr_request_hash[:attachments] << part.body
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
lettr_request_hashes << lettr_request_hash
|
|
36
|
+
end
|
|
37
|
+
identifier = @settings[:template] || mail.subject.downcase.gsub(/\s/, '_')
|
|
38
|
+
lettr_request_hashes.each do |lettr_request_hash|
|
|
39
|
+
::Lettr.send(identifier, lettr_request_hash).deliver
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lettr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 19
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
|
+
- 1
|
|
8
9
|
- 0
|
|
9
|
-
|
|
10
|
-
version: 1.0.4
|
|
10
|
+
version: 1.1.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Digineo GmbH
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
18
|
+
date: 2011-01-31 00:00:00 +01:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -77,6 +77,20 @@ dependencies:
|
|
|
77
77
|
version: "0"
|
|
78
78
|
type: :development
|
|
79
79
|
version_requirements: *id004
|
|
80
|
+
- !ruby/object:Gem::Dependency
|
|
81
|
+
name: actionmailer
|
|
82
|
+
prerelease: false
|
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
84
|
+
none: false
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
hash: 3
|
|
89
|
+
segments:
|
|
90
|
+
- 0
|
|
91
|
+
version: "0"
|
|
92
|
+
type: :development
|
|
93
|
+
version_requirements: *id005
|
|
80
94
|
description: lettr.de Api
|
|
81
95
|
email: kontakt@digineo.de
|
|
82
96
|
executables: []
|
|
@@ -97,6 +111,7 @@ files:
|
|
|
97
111
|
- lib/lettr/deliverable.rb
|
|
98
112
|
- lib/lettr/rendered_mailing.rb
|
|
99
113
|
- lib/lettr/base.rb
|
|
114
|
+
- lib/lettr/mail_extensions.rb
|
|
100
115
|
- lib/lettr/api_mailing.rb
|
|
101
116
|
- lib/lettr.rb
|
|
102
117
|
- lib/tasks/newsletter_boy.rake
|