postageapp 1.0.4 → 1.0.5

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 CHANGED
@@ -87,6 +87,8 @@ ActionMailer Integration
87
87
  ------------------------
88
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
+ There are custom methods that allow setting of `template` and `variables` parts of the API call. They are `postageapp_template` and `postageapp_variables`. Examples how they are used are below. For details what they do please see [documentation](http://help.postageapp.com/faqs)
91
+
90
92
  ### Rails 3.x
91
93
 
92
94
  Here's an example of a mailer in Rails 3 environment:
@@ -102,8 +104,8 @@ Here's an example of a mailer in Rails 3 environment:
102
104
  headers['Special-Header'] = 'SpecialValue'
103
105
 
104
106
  # PostageApp specific elements:
105
- postage_template 'example_template'
106
- postage_variables 'global_variable' => 'value'
107
+ postageapp_template 'example_template'
108
+ postageapp_variables 'global_variable' => 'value'
107
109
 
108
110
  mail(
109
111
  :from => 'test@test.test',
@@ -154,8 +156,8 @@ Here's an example of a mailer you'd set in in a Rails 2 environment:
154
156
  :body => File.read('/path/to/example.zip')
155
157
 
156
158
  # PostageApp specific elements:
157
- postage_template 'example_template'
158
- postage_variables 'global_variable' => 'value'
159
+ postageapp_template 'example_template'
160
+ postageapp_variables 'global_variable' => 'value'
159
161
 
160
162
  end
161
163
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
@@ -16,8 +16,8 @@
16
16
  #
17
17
  # Postage::Mailer introduces a few mailer methods specific to Postage:
18
18
  #
19
- # * postage_template - template name that is defined in your PostageApp project
20
- # * postage_variables - extra variables you want to send along with the message
19
+ # * template - template name that is defined in your PostageApp project
20
+ # * variables - extra variables you want to send along with the message
21
21
  #
22
22
  # Sending email
23
23
  #
@@ -29,8 +29,8 @@ class PostageApp::Mailer < ActionMailer::Base
29
29
  # Using :test as a delivery method if set somewhere else
30
30
  self.delivery_method = :postage unless (self.delivery_method == :test)
31
31
 
32
- adv_attr_accessor :postage_template
33
- adv_attr_accessor :postage_variables
32
+ adv_attr_accessor :postageapp_template
33
+ adv_attr_accessor :postageapp_variables
34
34
 
35
35
  def perform_delivery_postage(mail)
36
36
  mail.send
@@ -71,8 +71,8 @@ class PostageApp::Mailer < ActionMailer::Base
71
71
  end
72
72
  end
73
73
 
74
- params['template'] = self.postage_template unless self.postage_template.blank?
75
- params['variables'] = self.postage_variables unless self.postage_variables.blank?
74
+ params['template'] = self.postageapp_template unless self.postageapp_template.blank?
75
+ params['variables'] = self.postageapp_variables unless self.postageapp_variables.blank?
76
76
 
77
77
  params.delete('headers') if params['headers'].blank?
78
78
  params.delete('content') if params['content'].blank?
@@ -18,8 +18,8 @@
18
18
  #
19
19
  # Postage::Mailer introduces a few mailer methods specific to Postage:
20
20
  #
21
- # * postage_template - template name that is defined in your PostageApp project
22
- # * postage_variables - extra variables you want to send along with the message
21
+ # * postageapp_template - template name that is defined in your PostageApp project
22
+ # * postageapp_variables - extra variables you want to send along with the message
23
23
  #
24
24
  # Sending email
25
25
  #
@@ -57,25 +57,21 @@ class PostageApp::Mailer < ActionMailer::Base
57
57
  end
58
58
  end
59
59
 
60
- # In API call we can specify PostageApp template that will be used
61
- # to generate content of the message
62
- attr_accessor :postage_template
63
-
64
- # Hash of variables that will be used to inject into the content
65
- attr_accessor :postage_variables
66
-
67
60
  # Instead of initializing Mail object, we prepare PostageApp::Request
68
61
  def initialize(method_name = nil, *args)
69
62
  @_message = PostageApp::Request.new(:send_message)
70
63
  process(method_name, *args) if method_name
71
64
  end
72
65
 
73
- def postage_template(value)
74
- @_message.arguments['template'] = value
66
+ # In API call we can specify PostageApp template that will be used
67
+ # to generate content of the message
68
+ def postageapp_template(value = nil)
69
+ value ? @_message.arguments['template'] = value : @_message.arguments['template']
75
70
  end
76
71
 
77
- def postage_variables(variables = {})
78
- @_message.arguments['variables'] = variables
72
+ # Hash of variables that will be used to inject into the content
73
+ def postageapp_variables(value = nil)
74
+ value ? @_message.arguments['variables'] = value : @_message.arguments['variables']
79
75
  end
80
76
 
81
77
  def attachments
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{postageapp}
8
- s.version = "1.0.4"
8
+ s.version = "1.0.5"
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-27}
12
+ s.date = %q{2010-07-30}
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 = [
@@ -45,13 +45,18 @@ Gem::Specification.new do |s|
45
45
  "test/configuration_test.rb",
46
46
  "test/failed_request_test.rb",
47
47
  "test/helper.rb",
48
+ "test/live_test.rb",
48
49
  "test/mailer/action_mailer_2/notifier.rb",
49
50
  "test/mailer/action_mailer_2/notifier/with_body_and_attachment.erb",
51
+ "test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.html.erb",
52
+ "test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.plain.erb",
50
53
  "test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.html.erb",
51
54
  "test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.plain.erb",
52
55
  "test/mailer/action_mailer_2/notifier/with_simple_view.erb",
53
56
  "test/mailer/action_mailer_2/notifier/with_text_only_view.text.plain.erb",
54
57
  "test/mailer/action_mailer_3/notifier.rb",
58
+ "test/mailer/action_mailer_3/notifier/with_custom_postage_variables.html.erb",
59
+ "test/mailer/action_mailer_3/notifier/with_custom_postage_variables.text.erb",
55
60
  "test/mailer/action_mailer_3/notifier/with_html_and_text_views.html.erb",
56
61
  "test/mailer/action_mailer_3/notifier/with_html_and_text_views.text.erb",
57
62
  "test/mailer/action_mailer_3/notifier/with_old_api.html.erb",
@@ -63,19 +68,19 @@ Gem::Specification.new do |s|
63
68
  "test/mailer_helper_methods_test.rb",
64
69
  "test/postageapp_test.rb",
65
70
  "test/rails_initialization_test.rb",
66
- "test/request_integration_test.rb",
67
71
  "test/request_test.rb",
68
72
  "test/response_test.rb"
69
73
  ]
70
74
  s.homepage = %q{http://github.com/theworkinggroup/postageapp-gem}
71
75
  s.rdoc_options = ["--charset=UTF-8"]
72
76
  s.require_paths = ["lib"]
73
- s.rubygems_version = %q{1.3.6}
77
+ s.rubygems_version = %q{1.3.7}
74
78
  s.summary = %q{Easier way to send email from web apps}
75
79
  s.test_files = [
76
80
  "test/configuration_test.rb",
77
81
  "test/failed_request_test.rb",
78
82
  "test/helper.rb",
83
+ "test/live_test.rb",
79
84
  "test/mailer/action_mailer_2/notifier.rb",
80
85
  "test/mailer/action_mailer_3/notifier.rb",
81
86
  "test/mailer_2_test.rb",
@@ -83,7 +88,6 @@ Gem::Specification.new do |s|
83
88
  "test/mailer_helper_methods_test.rb",
84
89
  "test/postageapp_test.rb",
85
90
  "test/rails_initialization_test.rb",
86
- "test/request_integration_test.rb",
87
91
  "test/request_test.rb",
88
92
  "test/response_test.rb"
89
93
  ]
@@ -92,7 +96,7 @@ Gem::Specification.new do |s|
92
96
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
93
97
  s.specification_version = 3
94
98
 
95
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
99
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
96
100
  s.add_runtime_dependency(%q<json>, ["= 1.2.4"])
97
101
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
98
102
  else
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
- class RequestIntegrationTest < Test::Unit::TestCase
3
+ class LiveTest < Test::Unit::TestCase
4
4
 
5
5
  # Note: Need access to a live PostageApp.com account
6
6
  # See helper.rb to set host / api key
@@ -74,5 +74,16 @@ class RequestIntegrationTest < Test::Unit::TestCase
74
74
  assert_equal 'fail', response.status
75
75
  end
76
76
 
77
+ def test_deliver_with_custom_postage_variables
78
+ response = if ActionMailer::VERSION::MAJOR < 3
79
+ require File.expand_path('../mailer/action_mailer_2/notifier', __FILE__)
80
+ Notifier.deliver_with_custom_postage_variables
81
+ else
82
+ require File.expand_path('../mailer/action_mailer_3/notifier', __FILE__)
83
+ Notifier.with_custom_postage_variables.deliver
84
+ end
85
+ assert response.ok?
86
+ end
87
+
77
88
  end
78
89
  end
@@ -49,8 +49,8 @@ class Notifier < PostageApp::Mailer
49
49
  'test1@test.text' => { 'name' => 'Test 1' },
50
50
  'test2@test.text' => { 'name' => 'Test 2' }
51
51
  })
52
- postage_template 'test_template'
53
- postage_variables 'variable' => 'value'
52
+ postageapp_template 'test-template'
53
+ postageapp_variables 'variable' => 'value'
54
54
  end
55
55
 
56
56
  private
@@ -47,8 +47,8 @@ class Notifier < PostageApp::Mailer
47
47
  headers['CustomHeader1'] = 'CustomValue1'
48
48
  headers 'CustomHeader2' => 'CustomValue2'
49
49
 
50
- postage_template 'test_template'
51
- postage_variables 'variable' => 'value'
50
+ postageapp_template 'test-template'
51
+ postageapp_variables 'variable' => 'value'
52
52
 
53
53
  mail(
54
54
  :from => 'test@test.test',
@@ -85,8 +85,8 @@ class Notifier < PostageApp::Mailer
85
85
  :filename => 'foo.jpg',
86
86
  :body => '123456789'
87
87
 
88
- postage_template 'test_template'
89
- postage_variables 'variable' => 'value'
88
+ postageapp_template 'test-template'
89
+ postageapp_variables 'variable' => 'value'
90
90
  end
91
91
 
92
92
  private
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  # tests for ActionMailer bundled with Rails 2
4
- class Mailer3Test < Test::Unit::TestCase
4
+ class Mailer2Test < Test::Unit::TestCase
5
5
 
6
6
  if ActionMailer::VERSION::MAJOR < 3
7
7
 
@@ -67,10 +67,12 @@ class Mailer3Test < Test::Unit::TestCase
67
67
 
68
68
  def test_create_with_custom_postage_variables
69
69
  assert mail = Notifier.create_with_custom_postage_variables
70
- assert_equal 'test_template', mail.arguments['template']
70
+ assert_equal 'test-template', mail.arguments['template']
71
71
  assert_equal ({ 'variable' => 'value' }), mail.arguments['variables']
72
72
  assert_equal ({ 'test2@test.text' => { 'name' => 'Test 2'},
73
73
  'test1@test.text' => { 'name' => 'Test 1'}}), mail.arguments['recipients']
74
+ assert_equal 'text content', mail.arguments['content']['text/plain']
75
+ assert_equal 'html content', mail.arguments['content']['text/html']
74
76
  end
75
77
 
76
78
  def test_create_with_recipient_override
@@ -62,10 +62,12 @@ class Mailer3Test < Test::Unit::TestCase
62
62
  'test1@test.test' => { 'name' => 'Test 1'},
63
63
  'test2@test.test' => { 'name' => 'Test 2'}
64
64
  }), mail.arguments['recipients']
65
- assert_equal 'test_template', mail.arguments['template']
65
+ assert_equal 'test-template', mail.arguments['template']
66
66
  assert_equal ({ 'variable' => 'value' }), mail.arguments['variables']
67
67
  assert_equal 'CustomValue1', mail.arguments['headers']['CustomHeader1']
68
68
  assert_equal 'CustomValue2', mail.arguments['headers']['CustomHeader2']
69
+ assert_equal 'text content', mail.arguments['content']['text/plain']
70
+ assert_equal 'html content', mail.arguments['content']['text/html']
69
71
  end
70
72
 
71
73
  def test_create_with_old_api
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postageapp
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 29
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 4
9
- version: 1.0.4
9
+ - 5
10
+ version: 1.0.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Oleg Khabarov, The Working Group Inc
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-07-27 00:00:00 -04:00
18
+ date: 2010-07-30 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: json
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - "="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 23
27
30
  segments:
28
31
  - 1
29
32
  - 2
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: mocha
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 43
41
46
  segments:
42
47
  - 0
43
48
  - 9
@@ -83,13 +88,18 @@ files:
83
88
  - test/configuration_test.rb
84
89
  - test/failed_request_test.rb
85
90
  - test/helper.rb
91
+ - test/live_test.rb
86
92
  - test/mailer/action_mailer_2/notifier.rb
87
93
  - test/mailer/action_mailer_2/notifier/with_body_and_attachment.erb
94
+ - test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.html.erb
95
+ - test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.plain.erb
88
96
  - test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.html.erb
89
97
  - test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.plain.erb
90
98
  - test/mailer/action_mailer_2/notifier/with_simple_view.erb
91
99
  - test/mailer/action_mailer_2/notifier/with_text_only_view.text.plain.erb
92
100
  - test/mailer/action_mailer_3/notifier.rb
101
+ - test/mailer/action_mailer_3/notifier/with_custom_postage_variables.html.erb
102
+ - test/mailer/action_mailer_3/notifier/with_custom_postage_variables.text.erb
93
103
  - test/mailer/action_mailer_3/notifier/with_html_and_text_views.html.erb
94
104
  - test/mailer/action_mailer_3/notifier/with_html_and_text_views.text.erb
95
105
  - test/mailer/action_mailer_3/notifier/with_old_api.html.erb
@@ -101,7 +111,6 @@ files:
101
111
  - test/mailer_helper_methods_test.rb
102
112
  - test/postageapp_test.rb
103
113
  - test/rails_initialization_test.rb
104
- - test/request_integration_test.rb
105
114
  - test/request_test.rb
106
115
  - test/response_test.rb
107
116
  has_rdoc: true
@@ -114,23 +123,27 @@ rdoc_options:
114
123
  require_paths:
115
124
  - lib
116
125
  required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
117
127
  requirements:
118
128
  - - ">="
119
129
  - !ruby/object:Gem::Version
130
+ hash: 3
120
131
  segments:
121
132
  - 0
122
133
  version: "0"
123
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
124
136
  requirements:
125
137
  - - ">="
126
138
  - !ruby/object:Gem::Version
139
+ hash: 3
127
140
  segments:
128
141
  - 0
129
142
  version: "0"
130
143
  requirements: []
131
144
 
132
145
  rubyforge_project:
133
- rubygems_version: 1.3.6
146
+ rubygems_version: 1.3.7
134
147
  signing_key:
135
148
  specification_version: 3
136
149
  summary: Easier way to send email from web apps
@@ -138,6 +151,7 @@ test_files:
138
151
  - test/configuration_test.rb
139
152
  - test/failed_request_test.rb
140
153
  - test/helper.rb
154
+ - test/live_test.rb
141
155
  - test/mailer/action_mailer_2/notifier.rb
142
156
  - test/mailer/action_mailer_3/notifier.rb
143
157
  - test/mailer_2_test.rb
@@ -145,6 +159,5 @@ test_files:
145
159
  - test/mailer_helper_methods_test.rb
146
160
  - test/postageapp_test.rb
147
161
  - test/rails_initialization_test.rb
148
- - test/request_integration_test.rb
149
162
  - test/request_test.rb
150
163
  - test/response_test.rb