postageapp 1.0.21 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6380fa116f59e249ad1fce5897f34d160708caef
4
+ data.tar.gz: 87c9ee3959cc3d6f1b2b68a22b74e8367dfa89b5
5
+ SHA512:
6
+ metadata.gz: 280c702bde5cd63bf66c9b05fd8beac698cf9e2ad201416bc1ee542e122048d971ddf0b0c4aaf1b4bc512a874e4b1f9b6910253af8eab413486ef128c7aac67f
7
+ data.tar.gz: 0eb12f766ca5cc385e88ffb5aceacd4d10469ba920541fcdac36f6f0fdcccb234c689aa52523f055691755e1a28bae74418185055820f02b2ca2f3396016fb0d
@@ -3,9 +3,9 @@
3
3
  # to PostageApp::Mailer. Also don't forget to require 'postageapp/mailer'
4
4
  #
5
5
  # Here's an example of a valid PostageApp::Mailer class
6
- #
6
+ #
7
7
  # require 'postageapp/mailer'
8
- #
8
+ #
9
9
  # class Notifier < PostageApp::Mailer
10
10
  # def signup_notification(recipient)
11
11
  # mail(
@@ -27,7 +27,7 @@
27
27
  # response = request.deliver # attempts to deliver the message and creates a PostageApp::Response
28
28
  #
29
29
  class PostageApp::Mailer < ActionMailer::Base
30
-
30
+
31
31
  # Wrapper for creating attachments
32
32
  # Attachments sent to PostageApp are in the following format:
33
33
  # 'filename.ext' => {
@@ -35,12 +35,12 @@ class PostageApp::Mailer < ActionMailer::Base
35
35
  # 'content' => 'base64_encoded_content'
36
36
  # }
37
37
  class Attachments < Hash
38
-
38
+
39
39
  def initialize(message)
40
40
  @_message = message
41
41
  message.arguments['attachments'] ||= { }
42
42
  end
43
-
43
+
44
44
  def []=(filename, attachment)
45
45
  default_content_type = MIME::Types.type_for(filename).first.content_type rescue ''
46
46
  if attachment.is_a?(Hash)
@@ -56,81 +56,80 @@ class PostageApp::Mailer < ActionMailer::Base
56
56
  }
57
57
  end
58
58
  end
59
-
59
+
60
60
  # Instead of initializing Mail object, we prepare PostageApp::Request
61
61
  def initialize(method_name = nil, *args)
62
62
  super()
63
63
  @_message = PostageApp::Request.new(:send_message)
64
64
  process(method_name, *args) if method_name
65
65
  end
66
-
66
+
67
67
  # Possible to define custom uid. Should be sufficiently unique
68
68
  def postageapp_uid(value = nil)
69
69
  value ? @_message.uid = value : @_message.uid
70
70
  end
71
-
71
+
72
72
  def postageapp_api_key(value = nil)
73
73
  value ? @_message.api_key = value : @_message.api_key
74
74
  end
75
-
75
+
76
76
  # In API call we can specify PostageApp template that will be used
77
77
  # to generate content of the message
78
78
  def postageapp_template(value = nil)
79
79
  value ? @_message.arguments['template'] = value : @_message.arguments['template']
80
80
  end
81
-
81
+
82
82
  # Hash of variables that will be used to inject into the content
83
83
  def postageapp_variables(value = nil)
84
84
  value ? @_message.arguments['variables'] = value : @_message.arguments['variables']
85
85
  end
86
-
86
+
87
87
  def attachments
88
88
  @_attachments ||= Attachments.new(@_message)
89
89
  end
90
-
90
+
91
91
  # Override for headers assignment
92
92
  def headers(args=nil)
93
93
  @_message.headers(args)
94
94
  end
95
-
96
- # Overriding method that prepares Mail object. This time we'll be
95
+
96
+ # Overriding method that prepares Mail object. This time we'll be
97
97
  # contructing PostageApp::Request payload.
98
98
  def mail(headers = {}, &block)
99
99
  # Guard flag to prevent both the old and the new API from firing
100
100
  # Should be removed when old API is removed
101
101
  @mail_was_called = true
102
102
  m = @_message
103
-
103
+
104
104
  # At the beginning, do not consider class default for parts order neither content_type
105
105
  content_type = headers[:content_type]
106
106
  parts_order = headers[:parts_order]
107
-
107
+
108
108
  # Call all the procs (if any)
109
109
  default_values = self.class.default.merge(self.class.default) do |k,v|
110
110
  v.respond_to?(:call) ? v.bind(self).call : v
111
111
  end
112
-
112
+
113
113
  # Handle defaults
114
114
  headers = headers.reverse_merge(default_values)
115
- headers[:subject] ||= default_i18n_subject
116
-
115
+
117
116
  # Set configure delivery behavior
118
117
  wrap_delivery_behavior!(headers.delete(:delivery_method))
119
-
118
+
120
119
  # Assigning recipients
121
120
  m.arguments['recipients'] = headers.delete(:to)
122
-
121
+
123
122
  # Assign all headers except parts_order, content_type and body
124
123
  assignable = headers.except(:parts_order, :content_type, :body, :template_name, :template_path)
125
124
  m.headers.merge!(assignable)
126
-
125
+
127
126
  # Render the templates and blocks
128
127
  responses, explicit_order = collect_responses_and_parts_order(headers, &block)
129
128
  create_parts_from_responses(m, responses)
130
-
129
+
131
130
  m
132
131
  end
133
-
132
+
134
133
  protected
135
134
 
136
135
  def create_parts_from_responses(m, responses) #:nodoc:
@@ -139,16 +138,16 @@ protected
139
138
  content[part[:content_type]] = part[:body]
140
139
  end
141
140
  end
142
-
141
+
143
142
  end
144
143
 
145
144
  # A set of methods that are useful when request needs to behave as Mail
146
145
  class PostageApp::Request
147
-
146
+
148
147
  attr_accessor :delivery_handler,
149
148
  :perform_deliveries,
150
149
  :raise_delivery_errors
151
-
150
+
152
151
  # Either doing an actual send, or passing it along to Mail::TestMailer
153
152
  # Probably not the best way as we're skipping way too many intermediate methods
154
153
  def deliver
@@ -158,10 +157,10 @@ class PostageApp::Request
158
157
  self.send
159
158
  end
160
159
  end
161
-
160
+
162
161
  # Not 100% on this, but I need to assign this so I can properly handle deliver method
163
162
  def delivery_method(method = nil, settings = {})
164
163
  @delivery_method = method
165
164
  end
166
-
165
+
167
166
  end
@@ -112,7 +112,6 @@ class PostageApp::Mailer < ActionMailer::Base
112
112
 
113
113
  # Handle defaults
114
114
  headers = headers.reverse_merge(default_values)
115
- headers[:subject] ||= default_i18n_subject
116
115
 
117
116
  # Apply charset at the beginning so all fields are properly quoted
118
117
  charset = headers[:charset]
@@ -1,3 +1,3 @@
1
1
  module PostageApp
2
- VERSION = "1.0.21"
2
+ VERSION = "1.0.22"
3
3
  end
@@ -3,6 +3,6 @@ source 'http://rubygems.org'
3
3
  gem 'json'
4
4
 
5
5
  group :test do
6
- gem 'rails', '~> 4.0.0.rc2'
6
+ gem 'rails', '~> 4.0.0'
7
7
  gem 'mocha'
8
8
  end
@@ -1,38 +1,44 @@
1
1
  # Test mailer for ActionMailer 3
2
2
  class Notifier < PostageApp::Mailer
3
-
3
+
4
4
  self.append_view_path(File.expand_path('../', __FILE__))
5
-
5
+
6
6
  def blank
7
7
  # ... nothing to see here
8
8
  end
9
-
9
+
10
10
  def with_no_content
11
11
  mail(headers_hash)
12
12
  end
13
-
13
+
14
+ def with_no_subject
15
+ hash_without_subject = headers_hash
16
+ hash_without_subject.delete(:subject)
17
+ mail(hash_without_subject)
18
+ end
19
+
14
20
  def with_text_only_view
15
21
  mail(headers_hash)
16
22
  end
17
-
23
+
18
24
  def with_html_and_text_views
19
25
  mail(headers_hash) do |format|
20
26
  format.text
21
27
  format.html
22
28
  end
23
29
  end
24
-
30
+
25
31
  def with_simple_view
26
32
  mail(headers_hash)
27
33
  end
28
-
34
+
29
35
  def with_body_and_attachment_as_file
30
36
  attachments['sample_file.txt'] = 'File content'
31
37
  mail(headers_hash) do |format|
32
38
  format.html { render :text => 'manual body text'}
33
39
  end
34
40
  end
35
-
41
+
36
42
  def with_body_and_attachment_as_hash
37
43
  attachments['sample_file.txt'] = {
38
44
  :content_type => 'text/rich',
@@ -42,16 +48,16 @@ class Notifier < PostageApp::Mailer
42
48
  format.html { render :text => 'manual body text'}
43
49
  end
44
50
  end
45
-
51
+
46
52
  def with_custom_postage_variables
47
53
  headers['CustomHeader1'] = 'CustomValue1'
48
54
  headers 'CustomHeader2' => 'CustomValue2'
49
-
55
+
50
56
  postageapp_template 'test-template'
51
57
  postageapp_variables 'variable' => 'value'
52
58
  postageapp_api_key 'custom_api_key'
53
59
  postageapp_uid 'custom_uid'
54
-
60
+
55
61
  mail(
56
62
  :from => 'test@test.test',
57
63
  :subject => 'Test Message',
@@ -61,14 +67,14 @@ class Notifier < PostageApp::Mailer
61
67
  }
62
68
  )
63
69
  end
64
-
70
+
65
71
  private
66
-
72
+
67
73
  def headers_hash(options = {})
68
74
  { :from => 'sender@test.test',
69
75
  :subject => 'Test Message',
70
76
  :to => 'test@test.test'
71
77
  }.merge(options)
72
78
  end
73
-
79
+
74
80
  end
@@ -13,6 +13,11 @@ class Mailer3Test < Test::Unit::TestCase
13
13
  assert_equal ({}), mail.arguments['content']
14
14
  end
15
15
 
16
+ def test_create_with_no_subject
17
+ mail = Notifier.with_no_subject
18
+ assert mail.arguments['headers'][:subject].nil?
19
+ end
20
+
16
21
  def test_create_with_simple_view
17
22
  mail = Notifier.with_simple_view
18
23
  assert_equal 'with layout simple view content', mail.arguments['content']['text/html']
@@ -12,6 +12,11 @@ class Mailer4Test < Test::Unit::TestCase
12
12
  mail = Notifier.with_no_content
13
13
  assert_equal ({}), mail.arguments['content']
14
14
  end
15
+
16
+ def test_create_with_no_subject
17
+ mail = Notifier.with_no_subject
18
+ assert mail.arguments['headers'][:subject].nil?
19
+ end
15
20
 
16
21
  def test_create_with_simple_view
17
22
  mail = Notifier.with_simple_view
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postageapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.21
5
- prerelease:
4
+ version: 1.0.22
6
5
  platform: ruby
7
6
  authors:
8
7
  - Oleg Khabarov
@@ -10,22 +9,20 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-06-20 00:00:00.000000000 Z
12
+ date: 2013-09-24 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: json
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  description: Gem that interfaces with PostageApp.com service to send emails from web
@@ -99,26 +96,25 @@ files:
99
96
  - test/response_test.rb
100
97
  homepage: http://github.com/postageapp/postageapp-ruby
101
98
  licenses: []
99
+ metadata: {}
102
100
  post_install_message:
103
101
  rdoc_options: []
104
102
  require_paths:
105
103
  - lib
106
104
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
105
  requirements:
109
- - - ! '>='
106
+ - - '>='
110
107
  - !ruby/object:Gem::Version
111
108
  version: '0'
112
109
  required_rubygems_version: !ruby/object:Gem::Requirement
113
- none: false
114
110
  requirements:
115
- - - ! '>='
111
+ - - '>='
116
112
  - !ruby/object:Gem::Version
117
113
  version: '0'
118
114
  requirements: []
119
115
  rubyforge_project:
120
- rubygems_version: 1.8.23
116
+ rubygems_version: 2.0.3
121
117
  signing_key:
122
- specification_version: 3
118
+ specification_version: 4
123
119
  summary: Easier way to send email from web apps
124
120
  test_files: []