Rodreegez-integrity-email 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +52 -0
- data/Rakefile +11 -0
- data/integrity-email.gemspec +29 -0
- data/lib/integrity/notifier/config.haml +38 -0
- data/lib/integrity/notifier/email.rb +71 -0
- data/test/integrity_email_test.rb +93 -0
- metadata +89 -0
data/README.markdown
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
Integrity
|
2
|
+
=========
|
3
|
+
|
4
|
+
[Integrity][] is your friendly automated Continuous Integration server.
|
5
|
+
|
6
|
+
Integrity Email Notifier
|
7
|
+
========================
|
8
|
+
|
9
|
+
This lets Integrity send emails after each build is made.
|
10
|
+
|
11
|
+
Setup Instructions
|
12
|
+
==================
|
13
|
+
|
14
|
+
Just install this gem via `sudo gem install integrity-email` and then in your
|
15
|
+
Rackup (ie, `config.ru`) file:
|
16
|
+
|
17
|
+
require "rubygems"
|
18
|
+
require "integrity/notifier/email"
|
19
|
+
|
20
|
+
And badabing! Now you can set up your projects to send emails after
|
21
|
+
each build (just edit the project and the config options should be
|
22
|
+
there)
|
23
|
+
|
24
|
+
License
|
25
|
+
=======
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2008, 2009 [Nicolás Sanguinetti][foca], [entp][]
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
49
|
+
|
50
|
+
[Integrity]: http://integrityapp.com
|
51
|
+
[foca]: http://nicolassanguinetti.info
|
52
|
+
[entp]: http://entp.com
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "integrity-email"
|
3
|
+
s.version = "1.0.5"
|
4
|
+
s.date = "2009-06-01"
|
5
|
+
s.summary = "Email notifier for the Integrity continuous integration server"
|
6
|
+
s.description = "Easily let Integrity send emails after each build"
|
7
|
+
s.homepage = "http://integrityapp.com"
|
8
|
+
s.email = "info@integrityapp.com"
|
9
|
+
s.authors = ["Nicolás Sanguinetti", "Simon Rozet"]
|
10
|
+
s.has_rdoc = false
|
11
|
+
|
12
|
+
s.add_dependency "integrity"
|
13
|
+
s.add_dependency "sinatra-ditties", [">= 0.0.2"]
|
14
|
+
|
15
|
+
if s.respond_to?(:add_development_dependency)
|
16
|
+
s.add_development_dependency "rumbster"
|
17
|
+
end
|
18
|
+
|
19
|
+
s.rubyforge_project = "integrity"
|
20
|
+
|
21
|
+
s.files = %w[
|
22
|
+
README.markdown
|
23
|
+
Rakefile
|
24
|
+
integrity-email.gemspec
|
25
|
+
lib/integrity/notifier/config.haml
|
26
|
+
lib/integrity/notifier/email.rb
|
27
|
+
test/integrity_email_test.rb
|
28
|
+
]
|
29
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
%p.normal
|
2
|
+
%label{ :for => "email_notifier_to" } Send to
|
3
|
+
%input.text#email_notifier_to{ :name => "notifiers[Email][to]", :type => "text", :value => config["to"] }
|
4
|
+
|
5
|
+
%p.normal
|
6
|
+
%label{ :for => "email_notifier_from" } Send from
|
7
|
+
%input.text#email_notifier_from{ :name => "notifiers[Email][from]", :type => "text", :value => config["from"] }
|
8
|
+
|
9
|
+
%h3 SMTP Server Configuration
|
10
|
+
|
11
|
+
%p.normal
|
12
|
+
%label{ :for => "email_notifier_host" } Host : Port
|
13
|
+
= succeed " : " do
|
14
|
+
%input.text#email_notifier_host{ :name => "notifiers[Email][host]", :value => config["host"], :style => "width: 24.5em;", :type => "text" }
|
15
|
+
%input.text#email_notifier_port{ :name => "notifiers[Email][port]", :value => config["port"], :style => "width: 3.5em;", :type => "text" }
|
16
|
+
|
17
|
+
%p.normal
|
18
|
+
%label{ :for => "email_notifier_user" } User
|
19
|
+
%input.text#email_notifier_user{ :name => "notifiers[Email][user]", :value => config["user"], :type => "text" }
|
20
|
+
|
21
|
+
%p.normal
|
22
|
+
%label{ :for => "email_notifier_pass" } Password
|
23
|
+
%input.text#email_notifier_pass{ :name => "notifiers[Email][pass]", :value => config["pass"], :type => "password" }
|
24
|
+
|
25
|
+
%p.normal
|
26
|
+
%label{ :for => "email_notifier_auth" } Auth type
|
27
|
+
%input.text#email_notifier_auth{ :name => "notifiers[Email][auth]", :value => (config["auth"] || "plain"), :type => "text" }
|
28
|
+
|
29
|
+
%p.normal
|
30
|
+
%label{ :for => "email_notifier_domain" } Domain
|
31
|
+
%input.text#email_notifier_domain{ :name => "notifiers[Email][domain]", :value => config["domain"], :type => "text" }
|
32
|
+
|
33
|
+
|
34
|
+
%h3 Or, enter the path to sendmail:
|
35
|
+
|
36
|
+
%p.normal
|
37
|
+
%label{ :for => "email_notifier_sendmail" } Sendmail path (often /usr/sbin/sendmail)
|
38
|
+
%input.text#email_notifier_sendmail{ :name => "notifiers[Email][sendmail]", :value => config["sendmail"], :type => "text" }
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "integrity"
|
2
|
+
require "sinatra/ditties/mailer"
|
3
|
+
|
4
|
+
module Integrity
|
5
|
+
class Notifier
|
6
|
+
class Email < Notifier::Base
|
7
|
+
attr_reader :to, :from
|
8
|
+
|
9
|
+
def self.to_haml
|
10
|
+
File.read(File.dirname(__FILE__) + "/config.haml")
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(commit, config={})
|
14
|
+
@to = config.delete("to")
|
15
|
+
@from = config.delete("from")
|
16
|
+
super(commit, config)
|
17
|
+
configure_mailer
|
18
|
+
end
|
19
|
+
|
20
|
+
def deliver!
|
21
|
+
email.deliver!
|
22
|
+
end
|
23
|
+
|
24
|
+
def email
|
25
|
+
@email ||= Sinatra::Mailer::Email.new(
|
26
|
+
:to => to,
|
27
|
+
:from => from,
|
28
|
+
:text => body,
|
29
|
+
:subject => subject
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def subject
|
34
|
+
"[Integrity] #{commit.project.name}: #{short_message}"
|
35
|
+
end
|
36
|
+
|
37
|
+
alias_method :body, :full_message
|
38
|
+
|
39
|
+
private
|
40
|
+
def configure_mailer
|
41
|
+
return configure_sendmail unless @config["sendmail"].blank?
|
42
|
+
configure_smtp
|
43
|
+
end
|
44
|
+
|
45
|
+
def configure_smtp
|
46
|
+
user = @config["user"] || ""
|
47
|
+
pass = @config["pass"] || ""
|
48
|
+
user = nil if user.empty?
|
49
|
+
pass = nil if pass.empty?
|
50
|
+
|
51
|
+
Sinatra::Mailer.delivery_method = "net_smtp"
|
52
|
+
|
53
|
+
Sinatra::Mailer.config = {
|
54
|
+
:host => @config["host"],
|
55
|
+
:port => @config["port"],
|
56
|
+
:user => user,
|
57
|
+
:pass => pass,
|
58
|
+
:auth => @config["auth"],
|
59
|
+
:domain => @config["domain"]
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def configure_sendmail
|
64
|
+
Sinatra::Mailer.delivery_method = :sendmail
|
65
|
+
Sinatra::Mailer.config = {:sendmail_path => @config['sendmail']}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
register Email
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "rumbster"
|
3
|
+
require "message_observers"
|
4
|
+
require "integrity/notifier/test"
|
5
|
+
|
6
|
+
begin
|
7
|
+
require "redgreen"
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + "/../lib/integrity/notifier/email"
|
12
|
+
|
13
|
+
class IntegrityEmailTest < Test::Unit::TestCase
|
14
|
+
include Integrity::Notifier::Test
|
15
|
+
|
16
|
+
MAIL_SERVER_PORT = 10_000
|
17
|
+
|
18
|
+
def notifier
|
19
|
+
"Email"
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup
|
23
|
+
Net::SMTP.disable_tls
|
24
|
+
|
25
|
+
@server = Rumbster.new(MAIL_SERVER_PORT)
|
26
|
+
@mail_observer = MailMessageObserver.new
|
27
|
+
@server.add_observer(@mail_observer)
|
28
|
+
|
29
|
+
@server.start
|
30
|
+
|
31
|
+
setup_database
|
32
|
+
end
|
33
|
+
|
34
|
+
def commit(status=:successful)
|
35
|
+
Integrity::Commit.gen(status)
|
36
|
+
end
|
37
|
+
|
38
|
+
def teardown
|
39
|
+
@server.stop
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_configuration_form
|
43
|
+
assert form_have_tag?("h3", :content => "SMTP Server Configuration")
|
44
|
+
|
45
|
+
assert provides_option? "to", "foo@example.org"
|
46
|
+
assert provides_option? "from", "bar@example.org"
|
47
|
+
assert provides_option? "host", "foobarhost.biz"
|
48
|
+
assert provides_option? "user", "foobaruser"
|
49
|
+
assert provides_option? "pass", "secret"
|
50
|
+
assert provides_option? "auth", "plain"
|
51
|
+
assert provides_option? "pass", "secret"
|
52
|
+
assert provides_option? "domain","localhost"
|
53
|
+
assert provides_option? "sendmail","/usr/sbin/sendmail"
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_it_sends_email_notification
|
57
|
+
config = { "host" => "127.0.0.1",
|
58
|
+
"port" => MAIL_SERVER_PORT,
|
59
|
+
"to" => "you@example.org",
|
60
|
+
"from" => "me@example.org" }
|
61
|
+
|
62
|
+
successful = commit(:successful)
|
63
|
+
failed = commit(:failed)
|
64
|
+
|
65
|
+
Integrity::Notifier::Email.new(successful, config.dup).deliver!
|
66
|
+
Integrity::Notifier::Email.new(failed, config).deliver!
|
67
|
+
|
68
|
+
assert_equal "net_smtp", Sinatra::Mailer.delivery_method
|
69
|
+
|
70
|
+
mail = @mail_observer.messages.first
|
71
|
+
|
72
|
+
assert_equal ["you@example.org"], mail.destinations
|
73
|
+
assert_equal ["me@example.org"], mail.from
|
74
|
+
assert mail.subject.include?("successful")
|
75
|
+
assert mail.body.include?(successful.committed_at.to_s)
|
76
|
+
assert mail.body.include?(successful.author.name)
|
77
|
+
assert mail.body.include?(successful.output)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_it_configures_email_notification_with_sendmail
|
81
|
+
sendmail_path = "/usr/sbin/sendmail"
|
82
|
+
|
83
|
+
config = { "sendmail" => sendmail_path,
|
84
|
+
"to" => "sendmail@example.org",
|
85
|
+
"from" => "me@example.org" }
|
86
|
+
successful = commit(:successful)
|
87
|
+
|
88
|
+
Integrity::Notifier::Email.new(successful, config)
|
89
|
+
|
90
|
+
assert_equal :sendmail, Sinatra::Mailer.delivery_method
|
91
|
+
assert_equal sendmail_path, Sinatra::Mailer.config[:sendmail_path]
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Rodreegez-integrity-email
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Nicol\xC3\xA1s Sanguinetti"
|
8
|
+
- Simon Rozet
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-06-01 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: integrity
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: sinatra-ditties
|
28
|
+
type: :runtime
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.0.2
|
35
|
+
version:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rumbster
|
38
|
+
type: :development
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
description: Easily let Integrity send emails after each build
|
47
|
+
email: info@integrityapp.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files: []
|
53
|
+
|
54
|
+
files:
|
55
|
+
- README.markdown
|
56
|
+
- Rakefile
|
57
|
+
- integrity-email.gemspec
|
58
|
+
- lib/integrity/notifier/config.haml
|
59
|
+
- lib/integrity/notifier/email.rb
|
60
|
+
- test/integrity_email_test.rb
|
61
|
+
has_rdoc: false
|
62
|
+
homepage: http://integrityapp.com
|
63
|
+
licenses:
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project: integrity
|
84
|
+
rubygems_version: 1.3.5
|
85
|
+
signing_key:
|
86
|
+
specification_version: 2
|
87
|
+
summary: Email notifier for the Integrity continuous integration server
|
88
|
+
test_files: []
|
89
|
+
|