From 206c04c21a9f1aca8a7b0c26d04c00edf3ab9c40 Mon Sep 17 00:00:00 2001 From: Michael Glass Date: Thu, 28 May 2009 16:09:37 -0400 Subject: [PATCH] documentation and gem created --- README.markdown | 13 ++-- Rakefile | 16 ++-- ...y-email.gemspec => integrity-shell.gemspec | 21 +++-- lib/integrity/notifier/email.rb | 61 --------------- test/integrity_email_test.rb | 76 ------------------- test/test_fail | 6 -- 6 files changed, 24 insertions(+), 169 deletions(-) rename integrity-email.gemspec => integrity-shell.gemspec (64%) delete mode 100644 lib/integrity/notifier/email.rb delete mode 100644 test/integrity_email_test.rb delete mode 100644 test/test_fail diff --git a/README.markdown b/README.markdown index 3f9bae8..22063b5 100644 --- a/README.markdown +++ b/README.markdown @@ -3,19 +3,20 @@ Integrity [Integrity][] is your friendly automated Continuous Integration server. -Integrity Email Notifier +Integrity Shell Notifier ======================== -This lets Integrity send emails after each build is made. +This lets Integrity run shell scripts after each build is made. Setup Instructions ================== -Just install this gem via `sudo gem install integrity-email` and then in your +Add github to your git sources `sudo gem sources -a http://gems.github.com` +Install this gem via `sudo gem install michaelglass-integrity-shell` and then in your Rackup (ie, `config.ru`) file: require "rubygems" - require "integrity/notifier/email" + require "integrity/notifier/shell" And badabing! Now you can set up your projects to send emails after each build (just edit the project and the config options should be @@ -47,6 +48,4 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -[Integrity]: http://integrityapp.com -[foca]: http://nicolassanguinetti.info -[entp]: http://entp.com +[Integrity]: http://integrityapp.com \ No newline at end of file diff --git a/Rakefile b/Rakefile index 0e244bc..380980b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,5 @@ -# task :default => :test -# -# task :test do -# ruby "test/integrity_email_test.rb" -# end -# -# begin -# require "mg" -# MG.new("integrity-email.gemspec") -# rescue LoadError -# end +task :default => :test + +task :test do + `spec spec` +end \ No newline at end of file diff --git a/integrity-email.gemspec b/integrity-shell.gemspec similarity index 64% rename from integrity-email.gemspec rename to integrity-shell.gemspec index 0109035..96df966 100644 --- a/integrity-email.gemspec +++ b/integrity-shell.gemspec @@ -13,12 +13,17 @@ Gem::Specification.new do |s| # s.rubyforge_project = "integrity" -# s.files = %w[ -# README.markdown -# Rakefile -# integrity-email.gemspec -# lib/integrity/notifier/config.haml -# lib/integrity/notifier/email.rb -# test/integrity_email_test.rb -# ] + s.files = %w[ + README.markdown + Rakefile + integrity-shell.gemspec + lib/integrity/notifier/config.haml + lib/integrity/notifier/shell.rb + spec/rcov.opts + spec/spec.opts + spec/spec_helper.rb + spec/lib/integrity/notifier/shell_spec.rb + spec/lib/integrity/notifier/test_fail + spec/lib/integrity/notifier/test_pass + ] end diff --git a/lib/integrity/notifier/email.rb b/lib/integrity/notifier/email.rb deleted file mode 100644 index 04a8829..0000000 --- a/lib/integrity/notifier/email.rb +++ /dev/null @@ -1,61 +0,0 @@ -require "integrity" -require "sinatra/ditties/mailer" - -module Integrity - class Notifier - class Email < Notifier::Base - attr_reader :to, :from - - def self.to_haml - File.read(File.dirname(__FILE__) + "/config.haml") - end - - def initialize(commit, config={}) - @to = config.delete("to") - @from = config.delete("from") - super(commit, config) - configure_mailer - end - - def deliver! - email.deliver! - end - - def email - @email ||= Sinatra::Mailer::Email.new( - :to => to, - :from => from, - :text => body, - :subject => subject - ) - end - - def subject - "[Integrity] #{commit.project.name}: #{short_message}" - end - - alias_method :body, :full_message - - private - def configure_mailer - user = @config["user"] || "" - pass = @config["pass"] || "" - user = nil if user.empty? - pass = nil if pass.empty? - - Sinatra::Mailer.delivery_method = "net_smtp" - - Sinatra::Mailer.config = { - :host => @config["host"], - :port => @config["port"], - :user => user, - :pass => pass, - :auth => @config["auth"], - :domain => @config["domain"] - } - end - end - - register Email - end -end diff --git a/test/integrity_email_test.rb b/test/integrity_email_test.rb deleted file mode 100644 index 0b7c98f..0000000 --- a/test/integrity_email_test.rb +++ /dev/null @@ -1,76 +0,0 @@ -require "test/unit" -require "rumbster" -require "message_observers" -require "integrity/notifier/test" - -begin - require "redgreen" -rescue LoadError -end - -require File.dirname(__FILE__) + "/../lib/integrity/notifier/email" - -class IntegrityEmailTest < Test::Unit::TestCase - include Integrity::Notifier::Test - - MAIL_SERVER_PORT = 10_000 - - def notifier - "Email" - end - - def setup - Net::SMTP.disable_tls - - @server = Rumbster.new(MAIL_SERVER_PORT) - @mail_observer = MailMessageObserver.new - @server.add_observer(@mail_observer) - - @server.start - - setup_database - end - - def commit(status=:successful) - Integrity::Commit.gen(status) - end - - def teardown - @server.stop - end - - def test_configuration_form - assert_form_have_tag "h3", :content => "SMTP Server Configuration" - - assert_form_have_option "to", "foo@example.org" - assert_form_have_option "from", "bar@example.org" - assert_form_have_option "host", "foobarhost.biz" - assert_form_have_option "user", "foobaruser" - assert_form_have_option "pass", "secret" - # TODO assert_form_have_option "auth", "plain" - assert_form_have_option "pass", "secret" - assert_form_have_option "domain","localhost" - end - - def test_it_sends_email_notification - config = { "host" => "127.0.0.1", - "port" => MAIL_SERVER_PORT, - "to" => "you@example.org", - "from" => "me@example.org" } - - successful = commit(:successful) - failed = commit(:failed) - - Integrity::Notifier::Email.new(successful, config.dup).deliver! - Integrity::Notifier::Email.new(failed, config).deliver! - - mail = @mail_observer.messages.first - - assert_equal ["you@example.org"], mail.destinations - assert_equal ["me@example.org"], mail.from - assert mail.subject.include?("successful") - assert mail.body.include?(successful.committed_at.to_s) - assert mail.body.include?(successful.author.name) - assert mail.body.include?(successful.output) - end -end diff --git a/test/test_fail b/test/test_fail deleted file mode 100644 index 7f8cfb8..0000000 --- a/test/test_fail +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# this is a script that is used when testing the integrity-shell notifier - -#right now, all we do is print something to stdout. -#Later we might confirm that we receive params from the notifier -echo 'fail!' \ No newline at end of file