monkey-mailer 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YWFiNTA4Y2M4ZTZkMmE1MDdhN2Y1NmI3NTNjNmI3Mzg3ZmJkNWQ0Nw==
5
- data.tar.gz: !binary |-
6
- MzI1ZTc4ZWZmYzU4ZGI1MDdlZjQwYjY5YmE5OWQyNjg3MWY2ZTQzMw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MjFiMjhhNjBjNDRmM2FkMWRjNzIzMjc4Njg3ODc1MmVlOGZkNTliMTcyYzdm
10
- ODRlMzc0NWMzMWI5ODY2Njk5ZDkzYzI5MzEyNmUzZTcyN2NhZDc2Y2U4ZDdi
11
- Yjg2YmZhNjY5NmJmM2M5MmUyOGZhNjIyNDQ2ZTdlOTRiN2RhZWY=
12
- data.tar.gz: !binary |-
13
- MGExYjFkZjAzY2I5OWZhZDc5YmRlM2JkZGJkNjNiMTk0MTM2NTY0YTI5NDQ0
14
- N2E0ZWU4NTdkZjUxZmNjMWNiNzdjYTY1NWZlMzQwNmZmYzQxZDczN2YzZWQw
15
- YjYxZjNjNzFkZGI4ZGE5YTk5OGEzMjRiYTUzZThmY2FlMDc5Zjg=
2
+ SHA1:
3
+ metadata.gz: f49aaca7c03f03c2b7971c52b316721b52098e8a
4
+ data.tar.gz: dc7a25557773dac945756a019ebb0f6b531fe349
5
+ SHA512:
6
+ metadata.gz: b764d4e89268629cf108ce2f7885dbd258e3a2e02c3ca75857026bd5fb70eb70cbe6eed5186f829fcba6454621831386c4851adc1c762f714a5c6fda717d83a8
7
+ data.tar.gz: d13a2099c0a980746636b2c4942f060f36568395eb9799f62d0f67881d7df0e738dcbfe19996a2c185a45580bf89e159a85a77470f146128b3c21e3c179fcc96
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  Gemfile.lock
2
+ tags
@@ -18,10 +18,7 @@ module MonkeyMailer
18
18
  request_body = {
19
19
  :key => @key,
20
20
  :message => {
21
- :to => [{
22
- :email => email.to_email,
23
- :name => email.to_name
24
- }],
21
+ :to => parse_recipients(email.to_email, email.to_name),
25
22
  :from_name => email.from_name,
26
23
  :from_email => email.from_email,
27
24
  :subject => email.subject,
@@ -59,6 +56,27 @@ module MonkeyMailer
59
56
  raise MonkeyMailer::DeliverError.new("Mandril response.code not equal to 200") unless response.code.to_i == 200
60
57
  puts "Response #{response.code} #{response.message}: #{response.body}"
61
58
  end
59
+
60
+ def parse_recipients(recipients_list, names_list = "")
61
+ recipients = recipients_list.split(",")
62
+ names = names_list.to_s.split(",")
63
+ to_list = []
64
+
65
+ raise RuntimeError.new("No recipients specified") if recipients.empty?
66
+
67
+ if names.any? && (names.count != recipients.count)
68
+ raise RuntimeError.new("Recipients and Names lists don't match")
69
+ end
70
+
71
+ recipients.each_with_index do |recipient, idx|
72
+ to_list << { "email" => recipient.strip,
73
+ "name" => names[idx] ? names[idx].strip : "",
74
+ "type" => "to" }
75
+ end
76
+
77
+ to_list
78
+ end
79
+
62
80
  end
63
81
  end
64
82
  end
@@ -1,3 +1,3 @@
1
1
  module MonkeyMailer
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,36 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe 'Mandrill Adapter' do
4
+ before do
5
+ @adapter = MonkeyMailer::Adapters::MandrilAPI.new({})
6
+ end
7
+
8
+ it 'should parse recipients' do
9
+ recipients = "eddie@pj.com, jeff@pj.com, mike@pj.com, stone@pj.com, matt@pj.com"
10
+
11
+ names = "Eddie, Jeff, Mike, Stone, Matt"
12
+
13
+ to_field = @adapter.parse_recipients(recipients, names)
14
+
15
+ to_field.should include({ "email" => "eddie@pj.com", "name" => "Eddie", "type" => "to" })
16
+ to_field.should include({ "email" => "jeff@pj.com", "name" => "Jeff", "type" => "to" })
17
+ to_field.should include({ "email" => "mike@pj.com", "name" => "Mike", "type" => "to" })
18
+ to_field.should include({ "email" => "stone@pj.com", "name" => "Stone", "type" => "to" })
19
+ to_field.should include({ "email" => "matt@pj.com", "name" => "Matt", "type" => "to" })
20
+ end
21
+
22
+ it 'should not allow an empty recipients list' do
23
+ expect {
24
+ @adapter.parse_recipients("")
25
+ }.to raise_error(RuntimeError, "No recipients specified")
26
+ end
27
+
28
+ it 'should not allow unmatched emails and names lists' do
29
+ recipients = "eddie@pj.com,jeff@pj.com"
30
+ names = "Eddie,Jeff,Stone"
31
+
32
+ expect {
33
+ @adapter.parse_recipients(recipients, names)
34
+ }.to raise_error(RuntimeError, "Recipients and Names lists don't match")
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkey-mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lautaro Orazi
@@ -9,86 +9,86 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-03 00:00:00.000000000 Z
12
+ date: 2015-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clap
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.0'
21
- - - ! '>='
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ~>
28
+ - - "~>"
29
29
  - !ruby/object:Gem::Version
30
30
  version: '1.0'
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.0
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: fallen
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.0'
41
- - - ! '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: 0.0.3
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ~>
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0.0'
51
- - - ! '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.0.3
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: mail
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ~>
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '2.4'
61
- - - ! '>='
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: 2.4.4
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '2.4'
71
- - - ! '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 2.4.4
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: rspec
76
76
  requirement: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ~>
78
+ - - "~>"
79
79
  - !ruby/object:Gem::Version
80
80
  version: '2.12'
81
- - - ! '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: 2.12.0
84
84
  type: :development
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ~>
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '2.12'
91
- - - ! '>='
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: 2.12.0
94
94
  description: Ruby email queueing system with priority handling
@@ -98,9 +98,9 @@ executables: []
98
98
  extensions: []
99
99
  extra_rdoc_files: []
100
100
  files:
101
- - .gems
102
- - .gitignore
103
- - .travis.yml
101
+ - ".gems"
102
+ - ".gitignore"
103
+ - ".travis.yml"
104
104
  - README.md
105
105
  - UNLICENSE
106
106
  - examples/dummy_postman.rb
@@ -117,6 +117,7 @@ files:
117
117
  - monkey-mailer.gemspec
118
118
  - spec/adapter_spec.rb
119
119
  - spec/loader_spec.rb
120
+ - spec/mandrill_adapter_spec.rb
120
121
  - spec/monkey_mailer_spec.rb
121
122
  - spec/spec_helper.rb
122
123
  - spec/support/angry_adapter.rb
@@ -133,23 +134,24 @@ require_paths:
133
134
  - lib
134
135
  required_ruby_version: !ruby/object:Gem::Requirement
135
136
  requirements:
136
- - - ! '>='
137
+ - - ">="
137
138
  - !ruby/object:Gem::Version
138
139
  version: '0'
139
140
  required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  requirements:
141
- - - ! '>='
142
+ - - ">="
142
143
  - !ruby/object:Gem::Version
143
144
  version: '0'
144
145
  requirements: []
145
146
  rubyforge_project:
146
- rubygems_version: 2.0.3
147
+ rubygems_version: 2.4.5
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: Ruby email queueing system with priority handling
150
151
  test_files:
151
152
  - spec/adapter_spec.rb
152
153
  - spec/loader_spec.rb
154
+ - spec/mandrill_adapter_spec.rb
153
155
  - spec/monkey_mailer_spec.rb
154
156
  - spec/spec_helper.rb
155
157
  - spec/support/angry_adapter.rb