cerberus 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -0
- data/lib/cerberus/builder/rake.rb +3 -37
- data/lib/cerberus/builder/rant.rb +5 -0
- data/lib/cerberus/builder/ruby_base.rb +40 -0
- data/lib/cerberus/helper/xchar.rb +61 -0
- data/lib/cerberus/manager.rb +13 -5
- data/lib/cerberus/publisher/mail.rb +5 -1
- data/lib/cerberus/publisher/netsmtp_tls_fix.rb +13 -11
- data/lib/cerberus/publisher/rss.rb +5 -3
- data/lib/cerberus/version.rb +1 -5
- data/test/rss_publisher_test.rb +5 -3
- metadata +7 -3
data/CHANGES
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
= Cerberus Changelog
|
2
2
|
|
3
|
+
== Version 0.2.4
|
4
|
+
Features release
|
5
|
+
|
6
|
+
* Fix problem with TLS hack. Now possible to send to SSL and vanilla mailservers without modifying code.
|
7
|
+
* Added rant support (http://make.rubyforge.org) [Xavier Shay]
|
8
|
+
* Fixed escaping of code in RSS publisher [Xavier Shay]
|
9
|
+
* If we have only builder or publisher in configuration then use it. Param :type made mandatory.
|
10
|
+
|
3
11
|
== Version 0.2.3
|
4
12
|
Features release
|
5
13
|
|
@@ -1,39 +1,5 @@
|
|
1
|
-
class Cerberus::Builder::Rake
|
2
|
-
include Cerberus::Utils
|
3
|
-
attr_reader :output
|
4
|
-
|
1
|
+
class Cerberus::Builder::Rake < Cerberus::Builder::RubyBase
|
5
2
|
def initialize(config)
|
6
|
-
|
3
|
+
super(config, "rake")
|
7
4
|
end
|
8
|
-
|
9
|
-
def run
|
10
|
-
Dir.chdir @config[:application_root]
|
11
|
-
@output = `#{@config[:bin_path]}#{choose_rake_exec()} #{@config[:builder, :rake, :task]} 2>&1`
|
12
|
-
successful?
|
13
|
-
end
|
14
|
-
|
15
|
-
def successful?
|
16
|
-
$?.exitstatus == 0 and not @output.include?('rake aborted!')
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
def choose_rake_exec
|
21
|
-
ext = ['']
|
22
|
-
|
23
|
-
if os() == :windows
|
24
|
-
ext << '.bat' << '.cmd'
|
25
|
-
end
|
26
|
-
|
27
|
-
silence_stream(STDERR) {
|
28
|
-
ext.each do |e|
|
29
|
-
begin
|
30
|
-
out = `#{@config[:bin_path]}rake#{e} --version`
|
31
|
-
return "rake#{e}" if out =~ /rake/
|
32
|
-
rescue
|
33
|
-
end
|
34
|
-
end
|
35
|
-
}
|
36
|
-
|
37
|
-
raise "Rake builder did not find. Make sure that such script exists and have executable permissions."
|
38
|
-
end
|
39
|
-
end
|
5
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Cerberus::Builder::RubyBase
|
2
|
+
include Cerberus::Utils
|
3
|
+
attr_reader :output
|
4
|
+
|
5
|
+
def initialize(config, cmd)
|
6
|
+
@config = config
|
7
|
+
@cmd = cmd
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
Dir.chdir @config[:application_root]
|
12
|
+
@output = `#{@config[:bin_path]}#{choose_exec()} #{@config[:builder, @cmd.to_sym, :task]} 2>&1`
|
13
|
+
successful?
|
14
|
+
end
|
15
|
+
|
16
|
+
def successful?
|
17
|
+
$?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!")
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def choose_exec
|
22
|
+
ext = ['']
|
23
|
+
|
24
|
+
if os() == :windows
|
25
|
+
ext << '.bat' << '.cmd'
|
26
|
+
end
|
27
|
+
|
28
|
+
silence_stream(STDERR) {
|
29
|
+
ext.each do |e|
|
30
|
+
begin
|
31
|
+
out = `#{@config[:bin_path]}#{@cmd}#{e} --version`
|
32
|
+
return "#{@cmd}#{e}" if out =~ /#{@cmd}/
|
33
|
+
rescue
|
34
|
+
end
|
35
|
+
end
|
36
|
+
}
|
37
|
+
|
38
|
+
raise "#{@cmd} builder did not find. Make sure that such script exists and have executable permissions."
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# http://www.intertwingly.net/blog/2005/09/28/XML-Cleansing
|
2
|
+
# Tests available at above
|
3
|
+
module XChar
|
4
|
+
# http://intertwingly.net/stories/2004/04/14/i18n.html#CleaningWindows
|
5
|
+
CP1252 = {
|
6
|
+
128 => 8364, # euro sign
|
7
|
+
130 => 8218, # single low-9 quotation mark
|
8
|
+
131 => 402, # latin small letter f with hook
|
9
|
+
132 => 8222, # double low-9 quotation mark
|
10
|
+
133 => 8230, # horizontal ellipsis
|
11
|
+
134 => 8224, # dagger
|
12
|
+
135 => 8225, # double dagger
|
13
|
+
136 => 710, # modifier letter circumflex accent
|
14
|
+
137 => 8240, # per mille sign
|
15
|
+
138 => 352, # latin capital letter s with caron
|
16
|
+
139 => 8249, # single left-pointing angle quotation mark
|
17
|
+
140 => 338, # latin capital ligature oe
|
18
|
+
142 => 381, # latin capital letter z with caron
|
19
|
+
145 => 8216, # left single quotation mark
|
20
|
+
146 => 8217, # right single quotation mark
|
21
|
+
147 => 8220, # left double quotation mark
|
22
|
+
148 => 8221, # right double quotation mark
|
23
|
+
149 => 8226, # bullet
|
24
|
+
150 => 8211, # en dash
|
25
|
+
151 => 8212, # em dash
|
26
|
+
152 => 732, # small tilde
|
27
|
+
153 => 8482, # trade mark sign
|
28
|
+
154 => 353, # latin small letter s with caron
|
29
|
+
155 => 8250, # single right-pointing angle quotation mark
|
30
|
+
156 => 339, # latin small ligature oe
|
31
|
+
158 => 382, # latin small letter z with caron
|
32
|
+
159 => 376} # latin capital letter y with diaeresis
|
33
|
+
|
34
|
+
# http://www.w3.org/TR/REC-xml/#dt-chardata
|
35
|
+
PREDEFINED = {
|
36
|
+
38 => '&', # ampersand
|
37
|
+
60 => '<', # left angle bracket
|
38
|
+
62 => '>'} # right angle bracket
|
39
|
+
|
40
|
+
# http://www.w3.org/TR/REC-xml/#charsets
|
41
|
+
VALID = [[0x9, 0xA, 0xD], (0x20..0xD7FF),
|
42
|
+
(0xE000..0xFFFD), (0x10000..0x10FFFF)]
|
43
|
+
end
|
44
|
+
|
45
|
+
class Fixnum
|
46
|
+
# xml escaped version of chr
|
47
|
+
def xchr
|
48
|
+
n = XChar::CP1252[self] || self
|
49
|
+
n = 42 unless XChar::VALID.find {|range| range.include? n}
|
50
|
+
XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class String
|
55
|
+
# xml escaped version of to_s
|
56
|
+
def to_xs
|
57
|
+
unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8
|
58
|
+
rescue
|
59
|
+
unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252
|
60
|
+
end
|
61
|
+
end
|
data/lib/cerberus/manager.rb
CHANGED
@@ -26,7 +26,8 @@ module Cerberus
|
|
26
26
|
|
27
27
|
BUILDER_TYPES = {
|
28
28
|
:maven2 => Cerberus::Builder::Maven2,
|
29
|
-
:rake => Cerberus::Builder::Rake
|
29
|
+
:rake => Cerberus::Builder::Rake,
|
30
|
+
:rant => Cerberus::Builder::Rant
|
30
31
|
}
|
31
32
|
|
32
33
|
class AddCommand
|
@@ -77,8 +78,6 @@ module Cerberus
|
|
77
78
|
attr_reader :builder, :success, :scm, :status
|
78
79
|
|
79
80
|
DEFAULT_CONFIG = {:scm => {:type => 'svn'},
|
80
|
-
:builder => {:type => 'rake'},
|
81
|
-
:publisher => {:active => 'mail'},
|
82
81
|
:log => {:enable => true}
|
83
82
|
}
|
84
83
|
|
@@ -98,7 +97,7 @@ module Cerberus
|
|
98
97
|
scm_type = @config[:scm, :type]
|
99
98
|
@scm = SCM_TYPES[scm_type.to_sym].new(@config[:application_root], @config)
|
100
99
|
|
101
|
-
builder_type = @config[:builder, :type
|
100
|
+
builder_type = get_configuration_option(@config[:builder], :type, :rake)
|
102
101
|
@builder = BUILDER_TYPES[builder_type.to_sym].new(@config)
|
103
102
|
end
|
104
103
|
|
@@ -141,7 +140,7 @@ module Cerberus
|
|
141
140
|
|
142
141
|
#send notifications
|
143
142
|
if [:failure, :broken, :revival, :setup].include?(state)
|
144
|
-
active_publishers = @config[:publisher, :active
|
143
|
+
active_publishers = get_configuration_option(@config[:publisher], :active, 'mail')
|
145
144
|
active_publishers.split(/\W+/).each do |pub|
|
146
145
|
raise "Publisher have no configuration: #{pub}" unless @config[:publisher, pub]
|
147
146
|
clazz = PUBLISHER_TYPES[pub.to_sym]
|
@@ -163,6 +162,15 @@ module Cerberus
|
|
163
162
|
end
|
164
163
|
end
|
165
164
|
end
|
165
|
+
|
166
|
+
private
|
167
|
+
def get_configuration_option(hash, defining_key = nil, default_option = nil)
|
168
|
+
if hash
|
169
|
+
return hash[defining_key] if hash[defining_key]
|
170
|
+
return hash.keys[0] if hash.size == 1
|
171
|
+
end
|
172
|
+
return default_option
|
173
|
+
end
|
166
174
|
end
|
167
175
|
|
168
176
|
class BuildAllCommand
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'action_mailer'
|
2
2
|
require 'cerberus/publisher/base'
|
3
|
-
|
3
|
+
|
4
|
+
if RUBY_VERSION > '1.8.2'
|
5
|
+
#This hack works only on 1.8.4
|
6
|
+
require 'cerberus/publisher/netsmtp_tls_fix'
|
7
|
+
end
|
4
8
|
|
5
9
|
class Cerberus::Publisher::Mail < Cerberus::Publisher::Base
|
6
10
|
def self.publish(state, manager, options)
|
@@ -10,20 +10,21 @@ Net::SMTP.class_eval do
|
|
10
10
|
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
|
11
11
|
@socket = Net::InternetMessageIO.new(sock)
|
12
12
|
@socket.read_timeout = 60 #@read_timeout
|
13
|
-
|
13
|
+
#@socket.debug_output = STDERR #@debug_output
|
14
14
|
|
15
15
|
check_response(critical { recv_response() })
|
16
16
|
do_helo(helodomain)
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
if starttls
|
19
|
+
raise 'openssl library not installed' unless defined?(OpenSSL)
|
20
|
+
ssl = OpenSSL::SSL::SSLSocket.new(sock)
|
21
|
+
ssl.sync_close = true
|
22
|
+
ssl.connect
|
23
|
+
@socket = Net::InternetMessageIO.new(ssl)
|
24
|
+
@socket.read_timeout = 60 #@read_timeout
|
25
|
+
#@socket.debug_output = STDERR #@debug_output
|
26
|
+
do_helo(helodomain)
|
27
|
+
end
|
27
28
|
|
28
29
|
authenticate user, secret, authtype if user
|
29
30
|
@started = true
|
@@ -53,7 +54,8 @@ Net::SMTP.class_eval do
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def starttls
|
56
|
-
getok('STARTTLS')
|
57
|
+
getok('STARTTLS') rescue return false
|
58
|
+
return true
|
57
59
|
end
|
58
60
|
|
59
61
|
def quit
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'cerberus/publisher/base'
|
2
|
+
require 'cerberus/helper/xchar.rb'
|
2
3
|
|
3
4
|
class Cerberus::Publisher::RSS < Cerberus::Publisher::Base
|
4
5
|
def self.publish(state, manager, options)
|
@@ -6,16 +7,17 @@ class Cerberus::Publisher::RSS < Cerberus::Publisher::Base
|
|
6
7
|
subject,body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
|
7
8
|
|
8
9
|
pub_date = Time.now.iso8601
|
10
|
+
description = "<pre>#{body}</pre>".to_xs
|
9
11
|
result = <<-END
|
10
12
|
<rss version="2.0">
|
11
13
|
<channel>
|
12
|
-
<title>Cerberus build feed for #{options[:application_name]}</title>
|
14
|
+
<title>Cerberus build feed for #{options[:application_name].to_xs}</title>
|
13
15
|
<pubDate>#{pub_date}</pubDate>
|
14
16
|
<generator>http://rubyforge.org/projects/cerberus</generator>
|
15
17
|
<item>
|
16
|
-
<title>#{subject}</title>
|
18
|
+
<title>#{subject.to_xs}</title>
|
17
19
|
<pubDate>#{pub_date}</pubDate>
|
18
|
-
<description
|
20
|
+
<description>#{description}</description>
|
19
21
|
</item>
|
20
22
|
</channel>
|
21
23
|
</rss>
|
data/lib/cerberus/version.rb
CHANGED
data/test/rss_publisher_test.rb
CHANGED
@@ -6,14 +6,16 @@ require 'tempfile'
|
|
6
6
|
|
7
7
|
class RSSPublisherTest < Test::Unit::TestCase
|
8
8
|
def test_publisher
|
9
|
-
rss_file =
|
10
|
-
options = Cerberus::Config.new(nil, :publisher => {:rss => {:file => rss_file.path}}, :application_name => '
|
9
|
+
rss_file = Tempfile.new('cerberus-rss')
|
10
|
+
options = Cerberus::Config.new(nil, :publisher => {:rss => {:file => rss_file.path}}, :application_name => 'RSS<App')
|
11
11
|
build = DummyManager.new('last message', 'this is output', 1235, 'anatol')
|
12
12
|
|
13
13
|
Cerberus::Publisher::RSS.publish(:setup, build, options)
|
14
14
|
|
15
15
|
xml = REXML::Document.new(IO.read(rss_file.path))
|
16
16
|
|
17
|
-
assert_equal '[
|
17
|
+
assert_equal '[RSS<App] Cerberus set up for project (#1235)', xml.elements["rss/channel/item/title/"].get_text.value
|
18
|
+
assert_match %r{<pre>last message\n\nthis is output\n\n--\nCerberus 0.\d.\d, http://cerberus.rubyforge.com/</pre>},
|
19
|
+
xml.elements["rss/channel/item/description/"].get_text.value
|
18
20
|
end
|
19
21
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0.
|
2
|
+
rubygems_version: 0.9.0.4
|
3
3
|
specification_version: 1
|
4
4
|
name: cerberus
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2006-09-
|
6
|
+
version: 0.2.4
|
7
|
+
date: 2006-09-23 00:00:00 +04:00
|
8
8
|
summary: Cerberus is a Continuous Integration tool that could be easily run from Cron.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- lib/cerberus/config.rb
|
38
38
|
- lib/cerberus/config_migration.rb
|
39
39
|
- lib/cerberus/constants.rb
|
40
|
+
- lib/cerberus/helper
|
40
41
|
- lib/cerberus/latch.rb
|
41
42
|
- lib/cerberus/manager.rb
|
42
43
|
- lib/cerberus/publisher
|
@@ -45,6 +46,9 @@ files:
|
|
45
46
|
- lib/cerberus/version.rb
|
46
47
|
- lib/cerberus/builder/maven2.rb
|
47
48
|
- lib/cerberus/builder/rake.rb
|
49
|
+
- lib/cerberus/builder/rant.rb
|
50
|
+
- lib/cerberus/builder/ruby_base.rb
|
51
|
+
- lib/cerberus/helper/xchar.rb
|
48
52
|
- lib/cerberus/publisher/base.rb
|
49
53
|
- lib/cerberus/publisher/irc.rb
|
50
54
|
- lib/cerberus/publisher/jabber.rb
|