mail-single_file_delivery 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.mkd +26 -0
- data/Rakefile +1 -0
- data/lib/mail-single_file_delivery.rb +22 -0
- data/lib/mail-single_file_delivery/version.rb +5 -0
- data/mail-single_file_delivery.gemspec +48 -0
- data/spec/single_file_delivery_spec.rb +66 -0
- metadata +85 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.mkd
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Single File Delivery Method for Mail gem
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
This gem is a delivery-method plug-in for [mail](https://github.com/mikel/mail)
|
5
|
+
that delivers all mail to a single file for testing.
|
6
|
+
|
7
|
+
The Mail gem already provides a file delivery-method that appends a copy of each message
|
8
|
+
to a file named after each message recipient,
|
9
|
+
but I want them to all go to a single file
|
10
|
+
so that I can monitor them from another window with `tail -f my-file`,
|
11
|
+
or `cat my-named-pipe` while I hand-test the web interface from a browser.
|
12
|
+
|
13
|
+
Of course this is _in addition to_ running automated tests with Rspec and Cucumber.
|
14
|
+
At some point in development, I want to actually see the pages and enter my own inputs
|
15
|
+
and perhaps display the mail messages in an HTML reader.
|
16
|
+
|
17
|
+
## Synopsis
|
18
|
+
|
19
|
+
Mail.defaults do
|
20
|
+
delivery_method SingleFileDelivery => '/tmp/my-file.txt'
|
21
|
+
end
|
22
|
+
|
23
|
+
## See Also
|
24
|
+
|
25
|
+
* https://github.com/mikel/mail
|
26
|
+
* https://github.com/lsiden/mail-store-agent
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "mail-single_file_delivery/version"
|
2
|
+
|
3
|
+
module Mail
|
4
|
+
module SingleFileDelivery
|
5
|
+
class Agent
|
6
|
+
attr_accessor :settings
|
7
|
+
|
8
|
+
def initialize(settings={})
|
9
|
+
self.settings = {:filename => '/tmp/mail-single_file'}.merge! settings
|
10
|
+
filename = self.settings[:filename]
|
11
|
+
mode = File.pipe?(filename) ? 'a+' : 'w'
|
12
|
+
@fd = File.open(filename, mode) \
|
13
|
+
or raise "Cannot open #{filename} for writing" # just being safe
|
14
|
+
end
|
15
|
+
|
16
|
+
def deliver!(mail)
|
17
|
+
@fd.write mail.encoded + "\r\n\r\n"
|
18
|
+
@fd.flush
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "mail-single_file_delivery/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "mail-single_file_delivery"
|
7
|
+
s.version = Mail::SingleFileDelivery::VERSION
|
8
|
+
s.authors = ["Larry Siden, Westside Consulting LLC"]
|
9
|
+
s.email = ["lsiden@westside-consulting.com"]
|
10
|
+
s.homepage = "https://github.com/lsiden/mail-single_file_delivery"
|
11
|
+
s.summary = %q{
|
12
|
+
Delivery all mail to a single file for testing.
|
13
|
+
}
|
14
|
+
s.description = %q{
|
15
|
+
# Single File Delivery Method for Mail gem
|
16
|
+
|
17
|
+
## Summary
|
18
|
+
This gem is a delivery-method plug-in for [mail](https://github.com/mikel/mail)
|
19
|
+
that delivers all mail to a single file for testing.
|
20
|
+
|
21
|
+
The Mail gem already provides a file delivery-method that appends a copy of each message
|
22
|
+
to a file named after each message recipient,
|
23
|
+
but I want them to all go to a single file
|
24
|
+
so that I can monitor them from another window with `tail -f my-file`,
|
25
|
+
or `cat my-named-pipe` while I hand-test the web interface from a browser.
|
26
|
+
|
27
|
+
Of course this is _in addition to_ running automated tests with Rspec and Cucumber.
|
28
|
+
At some point in development, I want to actually see the pages and enter my own inputs
|
29
|
+
and perhaps display the mail messages in an HTML reader.
|
30
|
+
|
31
|
+
## Synopsis
|
32
|
+
|
33
|
+
Mail.defaults do
|
34
|
+
delivery_method SingleFileDelivery => '/tmp/my-file.txt'
|
35
|
+
end
|
36
|
+
}
|
37
|
+
|
38
|
+
s.rubyforge_project = "mail-single_file_delivery"
|
39
|
+
|
40
|
+
s.files = `git ls-files`.split("\n")
|
41
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
42
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
|
45
|
+
# specify any dependencies here; for example:
|
46
|
+
s.add_development_dependency "rspec"
|
47
|
+
s.add_runtime_dependency "mail"
|
48
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'mail-single_file_delivery'
|
4
|
+
require 'mail'
|
5
|
+
|
6
|
+
describe Mail::SingleFileDelivery::Agent do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
# Reset all defaults back to an original state
|
10
|
+
Mail.defaults do
|
11
|
+
delivery_method :smtp, { :address => "localhost",
|
12
|
+
:port => 25,
|
13
|
+
:domain => 'localhost.localdomain',
|
14
|
+
:user_name => nil,
|
15
|
+
:password => nil,
|
16
|
+
:authentication => nil,
|
17
|
+
:enable_starttls_auto => true }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should respond to #settings() and #settings=()" do
|
22
|
+
subject.should respond_to :settings
|
23
|
+
subject.should respond_to :settings=
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should respond to #deliver!()" do
|
27
|
+
subject.should respond_to :deliver!
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "general usage" do
|
31
|
+
the_file = '/tmp/mail-single_file'
|
32
|
+
sep = "\r\n\r\n"
|
33
|
+
|
34
|
+
before(:all) do
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should send an email to a single file" do
|
38
|
+
Mail.defaults do
|
39
|
+
delivery_method Mail::SingleFileDelivery::Agent, :filename => the_file
|
40
|
+
end
|
41
|
+
mail = Mail.deliver do
|
42
|
+
from 'roger@moore.com'
|
43
|
+
to 'marcel@amont.com'
|
44
|
+
subject 'invalid RFC2822'
|
45
|
+
end
|
46
|
+
File.read(the_file).should == mail.encoded + sep
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should send multiple emails to a single file" do
|
50
|
+
Mail.defaults do
|
51
|
+
delivery_method Mail::SingleFileDelivery::Agent, :filename => the_file
|
52
|
+
end
|
53
|
+
mail = Mail.deliver do
|
54
|
+
from 'roger@moore.com'
|
55
|
+
to 'marcel@amont.com, bob@me.com'
|
56
|
+
subject 'invalid RFC2822'
|
57
|
+
end
|
58
|
+
mail2 = Mail.deliver do
|
59
|
+
from 'roger@moore.com'
|
60
|
+
to 'marcel@amont.com, bob@me.com'
|
61
|
+
subject 'invalid RFC2822'
|
62
|
+
end
|
63
|
+
File.read(the_file).should == mail.encoded + sep + mail2.encoded + sep
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mail-single_file_delivery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Larry Siden, Westside Consulting LLC
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-01 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &85054000 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *85054000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mail
|
27
|
+
requirement: &85053690 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *85053690
|
36
|
+
description: ! "\n# Single File Delivery Method for Mail gem\n\n## Summary\nThis gem
|
37
|
+
is a delivery-method plug-in for [mail](https://github.com/mikel/mail)\nthat delivers
|
38
|
+
all mail to a single file for testing.\n\nThe Mail gem already provides a file delivery-method
|
39
|
+
that appends a copy of each message\nto a file named after each message recipient,\nbut
|
40
|
+
I want them to all go to a single file \nso that I can monitor them from another
|
41
|
+
window with `tail -f my-file`,\nor `cat my-named-pipe` while I hand-test the web
|
42
|
+
interface from a browser.\n\nOf course this is _in addition to_ running automated
|
43
|
+
tests with Rspec and Cucumber.\nAt some point in development, I want to actually
|
44
|
+
see the pages and enter my own inputs\nand perhaps display the mail messages in
|
45
|
+
an HTML reader.\n\n## Synopsis\n\n Mail.defaults do\n delivery_method SingleFileDelivery
|
46
|
+
=> '/tmp/my-file.txt'\n end\n "
|
47
|
+
email:
|
48
|
+
- lsiden@westside-consulting.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- README.mkd
|
56
|
+
- Rakefile
|
57
|
+
- lib/mail-single_file_delivery.rb
|
58
|
+
- lib/mail-single_file_delivery/version.rb
|
59
|
+
- mail-single_file_delivery.gemspec
|
60
|
+
- spec/single_file_delivery_spec.rb
|
61
|
+
homepage: https://github.com/lsiden/mail-single_file_delivery
|
62
|
+
licenses: []
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project: mail-single_file_delivery
|
81
|
+
rubygems_version: 1.8.10
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Delivery all mail to a single file for testing.
|
85
|
+
test_files: []
|