nakajima-integrity-twitter 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +56 -0
- data/Rakefile +12 -0
- data/integrity-twitter.gemspec +43 -0
- data/lib/notifier/config.haml +7 -0
- data/lib/notifier/twitter.rb +33 -0
- data/spec/integrity_twitter_spec.rb +85 -0
- data/spec/spec_helper.rb +5 -0
- metadata +76 -0
data/README.markdown
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Integrity (forked by pat nakajima for purely aesthetic reasons)
|
2
|
+
=========
|
3
|
+
|
4
|
+
TODO: add confit option for twitter names of people to DM or @reply when the build goes red.
|
5
|
+
|
6
|
+
[Integrity][] is your friendly automated Continuous Integration server.
|
7
|
+
|
8
|
+
Integrity Twitter Notifier
|
9
|
+
===========================
|
10
|
+
|
11
|
+
This lets Integrity send a tweet after each build is made.
|
12
|
+
|
13
|
+
Setup Instructions
|
14
|
+
==================
|
15
|
+
|
16
|
+
Step 1. Install this gem via `sudo gem install -s http://gems.github.com
|
17
|
+
cwsaylor-integrity-twitter`
|
18
|
+
|
19
|
+
Step 2. Add the following lines to your Rackup (ie, `config.ru`) file:
|
20
|
+
|
21
|
+
require "rubygems"
|
22
|
+
require "notifier/twitter"
|
23
|
+
|
24
|
+
Step 3. Profit! Just kidding. Edit the project and update your twitter email
|
25
|
+
address and password.
|
26
|
+
|
27
|
+
Run the tests
|
28
|
+
==================
|
29
|
+
|
30
|
+
rake spec
|
31
|
+
|
32
|
+
License
|
33
|
+
=======
|
34
|
+
|
35
|
+
(The MIT License)
|
36
|
+
|
37
|
+
Copyright (c) 2008 Chris Saylor
|
38
|
+
|
39
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
40
|
+
a copy of this software and associated documentation files (the
|
41
|
+
'Software'), to deal in the Software without restriction, including
|
42
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
43
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
44
|
+
permit persons to whom the Software is furnished to do so, subject to
|
45
|
+
the following conditions:
|
46
|
+
|
47
|
+
The above copyright notice and this permission notice shall be
|
48
|
+
included in all copies or substantial portions of the Software.
|
49
|
+
|
50
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
51
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
52
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
53
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
54
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
55
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
56
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{integrity-twitter}
|
5
|
+
s.version = "1.0.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Chris Saylor"]
|
9
|
+
s.date = %q{2008-12-15}
|
10
|
+
s.description = %q{Easily let Integrity tweet after each build}
|
11
|
+
s.email = %q{chris@justhack.com}
|
12
|
+
s.files = [
|
13
|
+
"integrity-twitter.gemspec",
|
14
|
+
"lib/notifier/config.haml",
|
15
|
+
"lib/notifier/twitter.rb",
|
16
|
+
"Rakefile",
|
17
|
+
"README.markdown",
|
18
|
+
"spec/integrity_twitter_spec.rb",
|
19
|
+
"spec/spec_helper.rb"
|
20
|
+
]
|
21
|
+
|
22
|
+
s.homepage = %q{http://integrityapp.com}
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
s.rubyforge_project = %q{integrity-twitter}
|
25
|
+
s.rubygems_version = %q{1.3.1}
|
26
|
+
s.summary = %q{Twitter notifier for the Integrity continuous integration server}
|
27
|
+
|
28
|
+
if s.respond_to? :specification_version then
|
29
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
30
|
+
s.specification_version = 2
|
31
|
+
|
32
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
33
|
+
s.add_runtime_dependency(%q<foca-integrity>, [">= 0"])
|
34
|
+
s.add_runtime_dependency(%q<twitter>, [">= 0"])
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<foca-integrity>, [">= 0"])
|
37
|
+
s.add_dependency(%q<twitter>, [">= 0"])
|
38
|
+
end
|
39
|
+
else
|
40
|
+
s.add_dependency(%q<foca-integrity>, [">= 0"])
|
41
|
+
s.add_dependency(%q<twitter>, [">= 0"])
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
%p.normal
|
2
|
+
%label{ :for => "integrity_twitter_notifier_email" } Email Address
|
3
|
+
%input.text#integrity_twitter_notifier_email{ :name => "notifiers[IntegrityTwitter][email]", :value => config["email"], :type => "text" }
|
4
|
+
|
5
|
+
%p.normal
|
6
|
+
%label{ :for => "integrity_twitter_notifier_pass" } Password
|
7
|
+
%input.text#integrity_twitter_notifier_pass{ :name => "notifiers[IntegrityTwitter][pass]", :value => config["pass"], :type => "text" }
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'integrity'
|
3
|
+
require 'twitter'
|
4
|
+
|
5
|
+
module Integrity
|
6
|
+
class Notifier
|
7
|
+
class IntegrityTwitter < Notifier::Base
|
8
|
+
|
9
|
+
def self.to_haml
|
10
|
+
File.read File.dirname(__FILE__) / "config.haml"
|
11
|
+
end
|
12
|
+
|
13
|
+
def deliver!
|
14
|
+
@tweet = Twitter::Base.new(@config["email"], @config["pass"])
|
15
|
+
@tweet.post(message)
|
16
|
+
end
|
17
|
+
|
18
|
+
def message
|
19
|
+
"#{build_status} | #{project.name}, commit #{build.short_commit_identifier} - [committer: #{build.commit_author.name}]"
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def build_status
|
25
|
+
build.successful? ? 'GREEN' : 'FAIL!'
|
26
|
+
end
|
27
|
+
|
28
|
+
def project
|
29
|
+
@project ||= build.project
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
+
|
3
|
+
describe Integrity::Notifier::IntegrityTwitter do
|
4
|
+
include AppSpecHelper
|
5
|
+
include NotifierSpecHelper
|
6
|
+
|
7
|
+
it_should_behave_like "A notifier"
|
8
|
+
|
9
|
+
def klass
|
10
|
+
Integrity::Notifier::IntegrityTwitter
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "notifying the world of a build" do
|
14
|
+
before { klass.stub!(:new).and_return(notifier) }
|
15
|
+
|
16
|
+
it "should instantiate a notifier with the given build and config" do
|
17
|
+
klass.should_receive(:new).with(mock_build, anything).and_return(notifier)
|
18
|
+
klass.notify_of_build(mock_build, notifier_config)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should pass the notifier options to the notifier" do
|
22
|
+
klass.should_receive(:new).with(anything, notifier_config).and_return(notifier)
|
23
|
+
klass.notify_of_build(mock_build, notifier_config)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should deliver the notification" do
|
27
|
+
notifier.should_receive(:deliver!)
|
28
|
+
klass.notify_of_build(mock_build, notifier_config)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "message" do
|
33
|
+
attr_reader :build
|
34
|
+
|
35
|
+
before(:each) do
|
36
|
+
@build = mock_build :commit_author => stub("author", :name => "nakajima")
|
37
|
+
@notifier = Integrity::Notifier::IntegrityTwitter.new(build, { })
|
38
|
+
end
|
39
|
+
|
40
|
+
context "on a green build" do
|
41
|
+
before(:each) do
|
42
|
+
build.stub!(:successful?).and_return(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "returns a success message" do
|
46
|
+
@notifier.message.should == "GREEN | Integrity, commit e7e02b - [committer: nakajima]"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "on a red build" do
|
51
|
+
before(:each) do
|
52
|
+
build.stub!(:successful?).and_return(false)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns a fail message" do
|
56
|
+
@notifier.message.should == "FAIL! | Integrity, commit e7e02b - [committer: nakajima]"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "generating a form for configuration" do
|
62
|
+
describe "with a field for the email" do
|
63
|
+
it "should have the proper name, id and label" do
|
64
|
+
the_form.should have_textfield("integrity_twitter_notifier_email").named("notifiers[IntegrityTwitter][email]").with_label("Email Address").with_value(nil)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should use the config's 'email' value if available" do
|
68
|
+
the_form(:config => { 'email' => 'test@example.com' }).should have_textfield("integrity_twitter_notifier_email").with_value("test@example.com")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "with a field for the pass" do
|
73
|
+
it "should have the proper name, id and label" do
|
74
|
+
the_form.should have_textfield("integrity_twitter_notifier_pass").named("notifiers[IntegrityTwitter][pass]").with_label("Password").with_value(nil)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should use the config's 'pass' value if available" do
|
78
|
+
the_form(:config => { 'pass' => 'mypass' }).should have_textfield("integrity_twitter_notifier_pass").with_value("mypass")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nakajima-integrity-twitter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Saylor
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-15 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: foca-integrity
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: twitter
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
33
|
+
description: Easily let Integrity tweet after each build
|
34
|
+
email: chris@justhack.com
|
35
|
+
executables: []
|
36
|
+
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files: []
|
40
|
+
|
41
|
+
files:
|
42
|
+
- integrity-twitter.gemspec
|
43
|
+
- lib/notifier/config.haml
|
44
|
+
- lib/notifier/twitter.rb
|
45
|
+
- Rakefile
|
46
|
+
- README.markdown
|
47
|
+
- spec/integrity_twitter_spec.rb
|
48
|
+
- spec/spec_helper.rb
|
49
|
+
has_rdoc: false
|
50
|
+
homepage: http://integrityapp.com
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "1.2"
|
67
|
+
version:
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: integrity-twitter
|
71
|
+
rubygems_version: 1.2.0
|
72
|
+
signing_key:
|
73
|
+
specification_version: 2
|
74
|
+
summary: Twitter notifier for the Integrity continuous integration server
|
75
|
+
test_files: []
|
76
|
+
|