integrity-campfire 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ Integrity
2
+ =========
3
+
4
+ [Integrity][] is your friendly automated Continuous Integration server.
5
+
6
+ Integrity Campfire Notifier
7
+ ===========================
8
+
9
+ This lets Integrity alert Campfire after each build is made.
10
+
11
+ Setup Instructions
12
+ ==================
13
+
14
+ Just install this gem via `sudo gem install -s http://gems.github.com
15
+ defunkt-integrity-campfire` and then in your Rackup (ie, `config.ru`) file:
16
+
17
+ require "rubygems"
18
+ require "integrity/notifier/campfire"
19
+
20
+ And badabing! Now you can set up your projects to alert Campfire 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 Chris Wanstrath
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
@@ -0,0 +1,11 @@
1
+ task :default => :test
2
+
3
+ task :test do
4
+ ruby "test/campfire_test.rb"
5
+ end
6
+
7
+ begin
8
+ require "mg"
9
+ MG.new("integrity-campfire.gemspec")
10
+ rescue LoadError
11
+ end
@@ -0,0 +1,31 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "integrity-campfire"
3
+ s.version = "1.2.0"
4
+ s.date = "2009-3-26"
5
+ s.summary = "Campfire notifier for the Integrity continuous integration server"
6
+ s.description = "Easily let Integrity alert Campfire after each build"
7
+ s.homepage = "http://integrityapp.com"
8
+ s.email = "chris@ozmm.org"
9
+ s.authors = ["Chris Wanstrath"]
10
+ s.has_rdoc = false
11
+
12
+ s.rubyforge_project = "integrity"
13
+
14
+ s.add_dependency "integrity"
15
+ s.add_dependency "tinder"
16
+
17
+ if s.respond_to?(:add_development_dependency)
18
+ s.add_development_dependency "mocha"
19
+ s.add_development_dependency "sr-mg"
20
+ end
21
+
22
+ s.files = %w[
23
+ README.markdown
24
+ Rakefile
25
+ integrity-campfire.gemspec
26
+ lib/integrity/notifier/campfire.rb
27
+ lib/integrity/notifier/config.haml
28
+ test/campfire_test.rb
29
+ test/helper.rb
30
+ ]
31
+ end
@@ -0,0 +1,47 @@
1
+ require "integrity"
2
+ require "tinder"
3
+
4
+ module Integrity
5
+ class Notifier
6
+ class Campfire < Notifier::Base
7
+ attr_reader :config
8
+
9
+ def self.to_haml
10
+ File.read File.dirname(__FILE__) / "config.haml"
11
+ end
12
+
13
+ def deliver!
14
+ room.speak "#{short_message}. #{commit_url}"
15
+ room.paste full_message if commit.failed?
16
+ room.leave
17
+ end
18
+
19
+ private
20
+ def room
21
+ @room ||= begin
22
+ options = {}
23
+ options[:ssl] = config["use_ssl"] ? true : false
24
+ campfire = Tinder::Campfire.new(config["account"], options)
25
+ campfire.login(config["user"], config["pass"])
26
+ campfire.find_room_by_name(config["room"])
27
+ end
28
+ end
29
+
30
+ def short_message
31
+ "Build #{commit.short_identifier} of #{commit.project.name} #{commit.successful? ? "was successful" : "failed"}"
32
+ end
33
+
34
+ def full_message
35
+ <<-EOM
36
+ Commit Message: #{commit.message}
37
+ Commit Date: #{commit.committed_at}
38
+ Commit Author: #{commit.author.name}
39
+
40
+ #{stripped_commit_output}
41
+ EOM
42
+ end
43
+ end
44
+
45
+ register Campfire
46
+ end
47
+ end
@@ -0,0 +1,19 @@
1
+ %p.normal
2
+ %label{ :for => "campfire_notifier_account" } Subdomain
3
+ %input.text#campfire_notifier_account{ :name => "notifiers[Campfire][account]", :type => "text", :value => config["account"] }
4
+
5
+ %p.normal
6
+ %label{ :for => "campfire_notifier_use_ssl" } SSL?
7
+ %input#campfire_notifier_use_ssl{ :name => "notifiers[Campfire][use_ssl]", :type => "checkbox", :checked => config["use_ssl"], :value => "1" }
8
+
9
+ %p.normal
10
+ %label{ :for => "campfire_notifier_room" } Room Name
11
+ %input.text#campfire_notifier_room{ :name => "notifiers[Campfire][room]", :type => "text", :value => config["room"] }
12
+
13
+ %p.normal
14
+ %label{ :for => "campfire_notifier_user" } User
15
+ %input.text#campfire_notifier_user{ :name => "notifiers[Campfire][user]", :value => config["user"], :type => "text" }
16
+
17
+ %p.normal
18
+ %label{ :for => "campfire_notifier_pass" } Password
19
+ %input.text#campfire_notifier_pass{ :name => "notifiers[Campfire][pass]", :value => config["pass"], :type => "text" }
@@ -0,0 +1,63 @@
1
+ require File.dirname(__FILE__) + "/helper"
2
+
3
+ context "The Campfire notifier" do
4
+ setup do
5
+ setup_database
6
+
7
+ @config = { "account" => "integrity",
8
+ "use_ssl" => false,
9
+ "room" => "ci",
10
+ "user" => "foo",
11
+ "pass" => "bar" }
12
+ @notifier = Integrity::Notifier::Campfire
13
+ @room = stub(:speak => nil, :paste => nil, :leave => nil)
14
+ end
15
+
16
+ def notifier
17
+ "Campfire"
18
+ end
19
+
20
+ test "it registers itself" do
21
+ assert_equal @notifier, Integrity::Notifier.available["Campfire"]
22
+ end
23
+
24
+ test "configuration form" do
25
+ assert_form_have_option "account", @config["account"]
26
+ assert_form_have_option "use_ssl", @config["use_ssl"]
27
+ assert_form_have_option "room", @config["room"]
28
+ assert_form_have_option "user", @config["user"]
29
+ assert_form_have_option "pass", @config["pass"]
30
+ end
31
+
32
+ test "ssl" do
33
+ @config["use_ssl"] = true
34
+
35
+ Tinder::Campfire.expects(:new).with(@config["account"], { :ssl => true }).
36
+ returns(stub(:login => true, :find_room_by_name => @room))
37
+
38
+ @notifier.notify_of_build(Integrity::Build.gen, @config)
39
+ end
40
+
41
+ test "successful build" do
42
+ build = Integrity::Build.gen(:successful)
43
+
44
+ @notifier.any_instance.stubs(:room).at_least_once.returns(@room)
45
+ @room.expects(:speak).with { |value| value.include?(build.commit.identifier) }
46
+ @room.expects(:paste).never
47
+
48
+ @notifier.notify_of_build(build, @config)
49
+ end
50
+
51
+ test "failed build" do
52
+ build = Integrity::Build.gen(:failed)
53
+
54
+ @notifier.any_instance.stubs(:room).at_least_once.returns(@room)
55
+ @room.expects(:speak).with { |value| value.include?(build.commit.identifier) }
56
+ @room.expects(:paste).with { |value|
57
+ value.include?(build.commit.message) &&
58
+ value.include?(build.output)
59
+ }
60
+
61
+ @notifier.notify_of_build(build, @config)
62
+ end
63
+ end
@@ -0,0 +1,38 @@
1
+ require "test/unit"
2
+ require "mocha"
3
+ require "integrity/notifier/test"
4
+ require File.dirname(__FILE__) + "/../lib/integrity/notifier/campfire"
5
+
6
+ begin
7
+ require "redgreen"
8
+ rescue LoadError
9
+ end
10
+
11
+ class Test::Unit::TestCase
12
+ include Integrity::Notifier::Test
13
+ end
14
+
15
+ # NOTE: Because of a bug in integrity/notifier/test/fixtures
16
+ class Array
17
+ def pick
18
+ slice(Kernel.rand(size))
19
+ end
20
+ end
21
+
22
+ ##
23
+ # test/spec/mini 2
24
+ # http://gist.github.com/25455
25
+ # chris@ozmm.org
26
+ #
27
+ def context(*args, &block)
28
+ return super unless (name = args.first) && block
29
+ klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
30
+ def self.test(name, &block)
31
+ define_method("test_#{name.gsub(/\W/,"_")}", &block) if block
32
+ end
33
+ def self.xtest(*args) end
34
+ def self.setup(&block) define_method(:setup, &block) end
35
+ def self.teardown(&block) define_method(:teardown, &block) end
36
+ end
37
+ klass.class_eval &block
38
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: integrity-campfire
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Wanstrath
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-26 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: integrity
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: tinder
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: mocha
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: sr-mg
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: Easily let Integrity alert Campfire after each build
56
+ email: chris@ozmm.org
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files: []
62
+
63
+ files:
64
+ - README.markdown
65
+ - Rakefile
66
+ - integrity-campfire.gemspec
67
+ - lib/integrity/notifier/campfire.rb
68
+ - lib/integrity/notifier/config.haml
69
+ - test/campfire_test.rb
70
+ - test/helper.rb
71
+ has_rdoc: false
72
+ homepage: http://integrityapp.com
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project: integrity
93
+ rubygems_version: 1.3.1
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: Campfire notifier for the Integrity continuous integration server
97
+ test_files: []
98
+