michaelglass-integrity-shell 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,51 @@
1
+ Integrity
2
+ =========
3
+
4
+ [Integrity][] is your friendly automated Continuous Integration server.
5
+
6
+ Integrity Shell Notifier
7
+ ========================
8
+
9
+ This lets Integrity run shell scripts after each build is made.
10
+
11
+ Setup Instructions
12
+ ==================
13
+
14
+ Add github to your git sources `sudo gem sources -a http://gems.github.com`
15
+ Install this gem via `sudo gem install michaelglass-integrity-shell` and then in your
16
+ Rackup (ie, `config.ru`) file:
17
+
18
+ require "rubygems"
19
+ require "integrity/notifier/shell"
20
+
21
+ And badabing! Now you can set up your projects to send emails after
22
+ each build (just edit the project and the config options should be
23
+ there)
24
+
25
+ License
26
+ =======
27
+
28
+ (The MIT License)
29
+
30
+ Copyright (c) 2008, 2009 Michael Glass, Jonah Bloch-Johnson, Michael Geraci
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining
33
+ a copy of this software and associated documentation files (the
34
+ 'Software'), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50
+
51
+ [Integrity]: http://integrityapp.com
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ task :default => :test
2
+
3
+ task :test do
4
+ system 'spec spec'
5
+ end
@@ -0,0 +1,30 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "integrity-shell"
3
+ s.version = "0.1.0"
4
+ s.date = "2009-05-28"
5
+ s.summary = "Shell Script notifier for the Integrity continuous integration server"
6
+ s.description = "Easily let Integrity run a shell script after builds"
7
+ s.homepage = "http://integrityapp.com"
8
+ s.email = "info@thealmanac.org"
9
+ s.authors = ["Michael Glass", "Michael Geraci", "Jonah Bloch-Johnson"]
10
+ s.has_rdoc = false
11
+
12
+ s.add_dependency "integrity"
13
+
14
+
15
+ # s.rubyforge_project = "integrity"
16
+
17
+ s.files = %w[
18
+ README.markdown
19
+ Rakefile
20
+ integrity-shell.gemspec
21
+ lib/integrity/notifier/config.haml
22
+ lib/integrity/notifier/shell.rb
23
+ spec/rcov.opts
24
+ spec/spec.opts
25
+ spec/spec_helper.rb
26
+ spec/lib/integrity/notifier/shell_spec.rb
27
+ spec/lib/integrity/notifier/test_fail
28
+ spec/lib/integrity/notifier/test_pass
29
+ ]
30
+ end
@@ -0,0 +1,8 @@
1
+ %p.normal
2
+ %label{ :for => "shell_notifier_pass_script" } Passing Script
3
+ %input.text#shell_notifier_pass_script{ :name => "notifiers[Shell][pass_script]", :type => "text", :value => config["pass_script"] }
4
+
5
+ %p.normal
6
+ %label{ :for => "shell_notifier_fail_script" } Failing Script
7
+ %input.text#shell_notifier_fail_script{ :name => "notifiers[Shell][fail_script]", :type => "text", :value => config["fail_script"] }
8
+
@@ -0,0 +1,28 @@
1
+ require 'integrity'
2
+ module Integrity
3
+ class Notifier
4
+ class Shell < Notifier::Base
5
+ attr_reader :pass_script, :fail_script
6
+
7
+ def self.to_haml
8
+ File.read(File.dirname(__FILE__) + "/config.haml")
9
+ end
10
+
11
+ def initialize(commit, config={})
12
+ @pass_script = config["pass_script"]
13
+ @fail_script = config["fail_script"]
14
+ super(commit, config) # sets @config and @commit
15
+ end
16
+
17
+ def deliver!
18
+ #we have access to commit and to config
19
+ if @commit.failed?
20
+ `#{fail_script}`
21
+ else
22
+ `#{pass_script}`
23
+ end
24
+ end
25
+ end
26
+ register Shell
27
+ end
28
+ end
@@ -0,0 +1,69 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
2
+
3
+ describe Integrity::Notifier::Shell do
4
+ describe "#deliver!" do
5
+
6
+ context "a passing commit is pushed" do
7
+ before(:each) do
8
+ @passing = Integrity::Commit.gen(:successful)
9
+ end
10
+ context "if the passing script exist" do
11
+ before(:each) do
12
+ @config = {'pass_script' => File.expand_path(File.dirname(__FILE__)) + '/test_pass', 'fail_script' => ''}
13
+ @shell = Integrity::Notifier::Shell.new(@passing, @config)
14
+ end
15
+ it "should run the passing script" do
16
+ @shell.deliver!.should == "pass!\n"
17
+ end
18
+ end
19
+
20
+ context "if the passing script doesn't exist" do
21
+ context "if the passing script is blank" do
22
+ before(:each) do
23
+ @config = {'pass_script' => '', 'fail_script' => ''}
24
+ end
25
+ it "should not try to run the script"
26
+ end
27
+
28
+ context "if the passing script is not blank" do
29
+ before(:each) do
30
+ @config = {'pass_script' => File.expand_path(File.dirname(__FILE__)) +'/test_pass_fake', 'fail_script' => ''}
31
+ end
32
+ it "should log an error"
33
+ end
34
+ end
35
+ end
36
+
37
+ context "a failing commit is pushed" do
38
+ before(:each) do
39
+ @failing = Integrity::Commit.gen(:failed)
40
+ end
41
+ context "if the failing script exists" do
42
+ before(:each) do
43
+ @config = {'fail_script' => File.expand_path(File.dirname(__FILE__)) + '/test_fail', 'pass_script' => ''}
44
+ @shell = Integrity::Notifier::Shell.new(@failing, @config)
45
+ end
46
+ it "should run the failing script" do
47
+ @shell.deliver!.should == "fail!\n"
48
+ end
49
+ end
50
+
51
+ context "if the failing script does not exist" do
52
+ context "if the failing script is blank" do
53
+ before(:each) do
54
+ @config = {'pass_script' => '', 'fail_script' => ''}
55
+ end
56
+ it "should not try to run the script"
57
+ end
58
+
59
+ context "if the failing script is not blank" do
60
+ before(:each) do
61
+ @config = {'fail_script' => File.expand_path(File.dirname(__FILE__) + '/test_fail_fake'), 'pass_script' => ''}
62
+ end
63
+
64
+ it "should log an error"
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+ # this is a script that is used when testing the integrity-shell notifier
3
+
4
+ #right now, all we do is print something to stdout.
5
+ #Later we might confirm that we receive params from the notifier
6
+ echo 'fail!'
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+ # this is a script that is used when testing the integrity-shell notifier
3
+
4
+ #right now, all we do is print something to stdout.
5
+ #Later we might confirm that we receive params from the notifier
6
+ echo 'pass!'
data/spec/rcov.opts ADDED
@@ -0,0 +1 @@
1
+ --exclude "spec/*,gems/*"
data/spec/spec.opts ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,5 @@
1
+ require "integrity/notifier/test"
2
+ require File.dirname(__FILE__) + "/../lib/integrity/notifier/shell"
3
+ require 'spec/autorun'
4
+ include Integrity::Notifier::Test
5
+ setup_database
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: michaelglass-integrity-shell
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Glass
8
+ - Michael Geraci
9
+ - Jonah Bloch-Johnson
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2009-05-28 00:00:00 -07:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: integrity
19
+ type: :runtime
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: "0"
26
+ version:
27
+ description: Easily let Integrity run a shell script after builds
28
+ email: info@thealmanac.org
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - README.markdown
37
+ - Rakefile
38
+ - integrity-shell.gemspec
39
+ - lib/integrity/notifier/config.haml
40
+ - lib/integrity/notifier/shell.rb
41
+ - spec/rcov.opts
42
+ - spec/spec.opts
43
+ - spec/spec_helper.rb
44
+ - spec/lib/integrity/notifier/shell_spec.rb
45
+ - spec/lib/integrity/notifier/test_fail
46
+ - spec/lib/integrity/notifier/test_pass
47
+ has_rdoc: false
48
+ homepage: http://integrityapp.com
49
+ post_install_message:
50
+ rdoc_options: []
51
+
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.2.0
70
+ signing_key:
71
+ specification_version: 2
72
+ summary: Shell Script notifier for the Integrity continuous integration server
73
+ test_files: []
74
+