integrity-email 1.0.2
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 +31 -0
- data/lib/integrity/notifier/email.rb +59 -0
- data/test/integrity_email_test.rb +76 -0
- metadata +88 -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.2"
|
4
|
+
s.date = "2009-04-06"
|
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,31 @@
|
|
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 => "text" }
|
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" }
|
@@ -0,0 +1,59 @@
|
|
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
|
+
user = @config["user"] || ""
|
42
|
+
pass = @config["pass"] || ""
|
43
|
+
user = nil if user.empty?
|
44
|
+
pass = nil if pass.empty?
|
45
|
+
|
46
|
+
Sinatra::Mailer.delivery_method = "net_smtp"
|
47
|
+
|
48
|
+
Sinatra::Mailer.config = {
|
49
|
+
:host => @config["host"],
|
50
|
+
:port => @config["port"],
|
51
|
+
:user => user,
|
52
|
+
:pass => pass,
|
53
|
+
:auth => @config["auth"],
|
54
|
+
:domain => @config["domain"]
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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_form_have_option "to", "foo@example.org"
|
46
|
+
assert_form_have_option "from", "bar@example.org"
|
47
|
+
assert_form_have_option "host", "foobarhost.biz"
|
48
|
+
assert_form_have_option "user", "foobaruser"
|
49
|
+
assert_form_have_option "pass", "secret"
|
50
|
+
assert_form_have_option "auth", "plain"
|
51
|
+
assert_form_have_option "pass", "secret"
|
52
|
+
assert_form_have_option "domain","localhost"
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_it_sends_email_notification
|
56
|
+
config = { "host" => "127.0.0.1",
|
57
|
+
"port" => MAIL_SERVER_PORT,
|
58
|
+
"to" => "you@example.org",
|
59
|
+
"from" => "me@example.org" }
|
60
|
+
|
61
|
+
successful = commit(:successful)
|
62
|
+
failed = commit(:failed)
|
63
|
+
|
64
|
+
Integrity::Notifier::Email.new(successful, config.dup).deliver!
|
65
|
+
Integrity::Notifier::Email.new(failed, config).deliver!
|
66
|
+
|
67
|
+
mail = @mail_observer.messages.first
|
68
|
+
|
69
|
+
assert_equal ["you@example.org"], mail.destinations
|
70
|
+
assert_equal ["me@example.org"], mail.from
|
71
|
+
assert mail.subject.include?("successful")
|
72
|
+
assert mail.body.include?(successful.committed_at.to_s)
|
73
|
+
assert mail.body.include?(successful.author.name)
|
74
|
+
assert mail.body.include?(successful.output)
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: integrity-email
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
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-04-06 00:00:00 +02: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
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project: integrity
|
83
|
+
rubygems_version: 1.3.1
|
84
|
+
signing_key:
|
85
|
+
specification_version: 2
|
86
|
+
summary: Email notifier for the Integrity continuous integration server
|
87
|
+
test_files: []
|
88
|
+
|