postageapp 1.0.0 → 1.0.1
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/.document +1 -1
- data/README.md +8 -8
- data/VERSION +1 -1
- data/lib/postageapp.rb +9 -7
- data/lib/postageapp/mailer.rb +4 -3
- data/lib/postageapp/rails.rb +1 -0
- data/lib/postageapp/request.rb +1 -1
- data/postageapp.gemspec +2 -2
- data/test/mailer_helper_methods_test.rb +3 -3
- metadata +3 -3
data/.document
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
PostageApp Gem
|
2
|
-
|
1
|
+
[PostageApp](http://postageapp.com) Gem
|
2
|
+
=======================================
|
3
3
|
|
4
4
|
This is the gem used to integrate Ruby apps with PostageApp service.
|
5
5
|
Personalized, mass email sending can be offloaded to PostageApp via JSON based API.
|
6
6
|
|
7
|
-
|
7
|
+
### [API Documentation](http://help.postageapp.com/faqs/api-reference) • [PostageApp FAQs](http://help.postageapp.com/faqs) • [PostageApp Help Portal](http://help.postageapp.com)
|
8
8
|
|
9
9
|
Installation
|
10
10
|
------------
|
@@ -45,7 +45,7 @@ And then it's as simple as doing something like this:
|
|
45
45
|
|
46
46
|
Usage
|
47
47
|
-----
|
48
|
-
Here's an example of sending a message ([See full API documentation](http://
|
48
|
+
Here's an example of sending a message ([See full API documentation](http://help.postageapp.com/faqs/api-reference/send_message)):
|
49
49
|
|
50
50
|
request = PostageApp::Request.new(:send_message, {
|
51
51
|
'headers' => { 'from' => 'sender@example.com',
|
@@ -85,7 +85,7 @@ Sometimes you don't want to send emails to real people in your application. For
|
|
85
85
|
|
86
86
|
ActionMailer Integration
|
87
87
|
------------------------
|
88
|
-
You can quickly convert your existing mailers to use PostageApp service by simply changing `class MyMailer < ActionMailer::Base` to `class MyMailer < PostageApp::Mailer`.
|
88
|
+
You can quickly convert your existing mailers to use PostageApp service by simply changing `class MyMailer < ActionMailer::Base` to `class MyMailer < PostageApp::Mailer`. If you using ActionMailer from outside of Rails make sure you have this line somewhere: `require 'postageapp/mailer'`
|
89
89
|
|
90
90
|
### Rails 3.x
|
91
91
|
|
@@ -122,9 +122,9 @@ API of previous ActionMailer is partially supported under Rails 3 environment. P
|
|
122
122
|
class Notifier < PostageApp::Mailer
|
123
123
|
|
124
124
|
def signup_notification
|
125
|
-
from
|
126
|
-
subject
|
127
|
-
recipients
|
125
|
+
from 'sender@example.com'
|
126
|
+
subject 'Test Email'
|
127
|
+
recipients 'recipient@example.com'
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/postageapp.rb
CHANGED
@@ -19,24 +19,26 @@ module PostageApp
|
|
19
19
|
|
20
20
|
class << self
|
21
21
|
|
22
|
-
# Accessor for the PostageApp::Configuration object
|
23
|
-
attr_accessor :configuration
|
24
|
-
|
25
22
|
# Call this method to modify your configuration
|
26
|
-
#
|
27
23
|
# Example:
|
28
24
|
# PostageApp.configure do |config|
|
29
25
|
# config.api_key = '1234567890abcdef'
|
30
26
|
# config.recipient_override = 'test@test.test' if Rails.env.staging?
|
31
27
|
# end
|
32
28
|
def configure
|
33
|
-
|
34
|
-
|
29
|
+
yield configuration
|
30
|
+
end
|
31
|
+
|
32
|
+
# Accessor for the PostageApp::Configuration object
|
33
|
+
# Example use:
|
34
|
+
# PostageApp.configuration.api_key = '1234567890abcdef'
|
35
|
+
def configuration
|
36
|
+
@configuration ||= Configuration.new
|
35
37
|
end
|
38
|
+
alias :config :configuration
|
36
39
|
|
37
40
|
# Logger for the plugin
|
38
41
|
def logger
|
39
|
-
raise Error, 'Need configuration to be set before logger can be used' if !configuration
|
40
42
|
@logger ||= begin
|
41
43
|
configuration.logger || PostageApp::Logger.new(
|
42
44
|
if configuration.project_root
|
data/lib/postageapp/mailer.rb
CHANGED
@@ -30,11 +30,12 @@ class PostageApp::Request
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def to
|
33
|
-
self.arguments_to_send.dig('arguments', 'recipients')
|
33
|
+
out = self.arguments_to_send.dig('arguments', 'recipients')
|
34
|
+
out = out.is_a?(Hash) ? out : [out].flatten
|
34
35
|
end
|
35
36
|
|
36
37
|
def from
|
37
|
-
self.arguments_to_send.dig('arguments', 'headers', 'from')
|
38
|
+
[self.arguments_to_send.dig('arguments', 'headers', 'from')].flatten
|
38
39
|
end
|
39
40
|
|
40
41
|
def subject
|
@@ -42,7 +43,7 @@ class PostageApp::Request
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def body
|
45
|
-
self.arguments_to_send.dig('arguments', 'content')
|
46
|
+
self.arguments_to_send.dig('arguments', 'content').to_s
|
46
47
|
end
|
47
48
|
|
48
49
|
end
|
data/lib/postageapp/rails.rb
CHANGED
data/lib/postageapp/request.rb
CHANGED
@@ -73,7 +73,7 @@ class PostageApp::Request
|
|
73
73
|
|
74
74
|
# Arguments need to be appended with some some stuff before it's ready to be send out
|
75
75
|
def arguments_to_send
|
76
|
-
hash = { 'uid' => self.uid, 'api_key'
|
76
|
+
hash = { 'uid' => self.uid, 'api_key' => PostageApp.configuration.api_key }
|
77
77
|
|
78
78
|
if !self.arguments.nil? && !self.arguments.empty?
|
79
79
|
if !PostageApp.configuration.recipient_override.nil? && self.method.to_sym == :send_message
|
data/postageapp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{postageapp}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oleg Khabarov, The Working Group Inc"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-26}
|
13
13
|
s.description = %q{Gem that interfaces with PostageApp.com service to send emails from web apps}
|
14
14
|
s.email = %q{oleg@twg.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -12,13 +12,13 @@ class MailerHelperMethodsTest < Test::Unit::TestCase
|
|
12
12
|
'text/html' => 'html content'
|
13
13
|
}
|
14
14
|
})
|
15
|
-
assert_equal 'test@test.test', request.to
|
16
|
-
assert_equal 'sender@test.test', request.from
|
15
|
+
assert_equal ['test@test.test'], request.to
|
16
|
+
assert_equal ['sender@test.test'], request.from
|
17
17
|
assert_equal 'Test Message', request.subject
|
18
18
|
assert_equal ({
|
19
19
|
'text/html' => 'html content',
|
20
20
|
'text/plain' => 'text content'
|
21
|
-
}), request.body
|
21
|
+
}).to_s, request.body
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Oleg Khabarov, The Working Group Inc
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-07-
|
17
|
+
date: 2010-07-26 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|