cerberus 0.2.0 → 0.2.1

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.
data/CHANGES CHANGED
@@ -1,5 +1,11 @@
1
1
  = Cerberus Changelog
2
2
 
3
+ == Version 0.2.1
4
+ Minor fix release
5
+
6
+ * publisher -> active flag now not mandatory. Use 'mail' publisher as active if not set any
7
+
8
+
3
9
  == Version 0.2.0
4
10
  Config file was changed since 0.1.1 and you need regenerate config files.
5
11
  Or change it by hands: see doc/OPTIONS file to list of all avalable options.
data/README CHANGED
@@ -31,7 +31,7 @@ To use Cerberus it is very easy. First install it. Easiest way to do it through
31
31
 
32
32
  'gem install cerberus'
33
33
 
34
- or get Cerberus distribution package right from download page http://rubyforge.org/frs/?group_id=1794
34
+ or get Cerberus distribution package right from download page http://rubyforge.org/frs/?group_id=1794&release_id=6442
35
35
 
36
36
  then you need to add project that will be watched by Cerberus. Do it by
37
37
 
data/Rakefile CHANGED
@@ -14,8 +14,8 @@ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
14
14
 
15
15
  RELEASE_NAME = "REL #{PKG_VERSION}"
16
16
 
17
- RUBY_FORGE_PROJECT = "cerberus"
18
- RUBY_FORGE_USER = "anatol"
17
+ RUBYFORGE_PROJECT = "cerberus"
18
+ RUBYFORGE_USER = "anatol"
19
19
 
20
20
  task :default => [:test, :clean]
21
21
 
@@ -75,7 +75,7 @@ GEM_SPEC = Gem::Specification.new do |s|
75
75
  s.author = "Anatol Pomozov"
76
76
  s.email = "anatol.pomozov@gmail.com"
77
77
  s.homepage = "http://rubyforge.org/projects/cerberus"
78
- s.rubyforge_project = RUBY_FORGE_PROJECT
78
+ s.rubyforge_project = RUBYFORGE_PROJECT
79
79
  end
80
80
 
81
81
 
@@ -101,7 +101,7 @@ end
101
101
  task :reinstall => [:uninstall, :install]
102
102
 
103
103
  task :site_webgen do
104
- sh %{pushd doc/site; webgen; scp -r output/* #{RUBY_FORGE_USER}@rubyforge.org:/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}/; popd }
104
+ sh %{pushd doc/site; webgen; scp -r output/* #{RUBYFORGE_USER}@rubyforge.org:/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/; popd }
105
105
  end
106
106
 
107
107
  begin
@@ -115,12 +115,12 @@ rescue Object
115
115
  end
116
116
 
117
117
  task :site_coverage => [:rcov] do
118
- sh %{ scp -r test/coverage/* #{RUBY_FORGE_USER}@rubyforge.org:/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}/coverage/ }
118
+ sh %{ scp -r test/coverage/* #{RUBYFORGE_USER}@rubyforge.org:/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/coverage/ }
119
119
  end
120
120
 
121
121
  task :release_files => [:clean, :package] do
122
122
  require 'meta_project'
123
- project = MetaProject::Project::XForge::RubyForge.new(RUBY_FORGE_PROJECT)
123
+ project = MetaProject::Project::XForge::RubyForge.new(RUBYFORGE_PROJECT)
124
124
 
125
125
  release_files = FileList[
126
126
  "pkg/#{PKG_FILE_NAME}.gem",
@@ -129,7 +129,7 @@ task :release_files => [:clean, :package] do
129
129
  ]
130
130
 
131
131
  Rake::XForge::Release.new(project) do |release|
132
- release.user_name = RUBY_FORGE_USER
132
+ release.user_name = RUBYFORGE_USER
133
133
  release.password = ENV['RUBYFORGE_PASSWORD']
134
134
  release.files = release_files.to_a
135
135
  release.package_name = PKG_NAME
@@ -141,9 +141,9 @@ end
141
141
  task :publish_news do
142
142
  require 'meta_project'
143
143
 
144
- project = MetaProject::Project::XForge::RubyForge.new(RUBY_FORGE_PROJECT)
144
+ project = MetaProject::Project::XForge::RubyForge.new(RUBYFORGE_PROJECT)
145
145
  Rake::XForge::NewsPublisher.new(project) do |publisher|
146
- publisher.user_name = RUBY_FORGE_USER
146
+ publisher.user_name = RUBYFORGE_USER
147
147
  publisher.password = ENV['RUBYFORGE_PASSWORD']
148
148
  publisher.subject = "[ANN] Cerberus #{PKG_VERSION} Released"
149
149
  publisher.details = IO.read(File.dirname(__FILE__) + '/README')
@@ -2,16 +2,17 @@ require 'rubygems'
2
2
  require 'active_support'
3
3
 
4
4
  require 'cerberus/constants'
5
+ require 'cerberus/utils'
5
6
 
6
7
  module Cerberus
7
8
  class Config
8
- def initialize(app_name, cli_options = {})
9
+ def initialize(app_name = nil, cli_options = {})
9
10
  @config = HashWithIndifferentAccess.new
10
11
  if app_name
11
- @config.merge!(YAML.load(IO.read(CONFIG_FILE))) if test(?f, CONFIG_FILE)
12
- @config.merge!(YAML.load(IO.read(HOME + "/config/#{app_name}.yml")))
12
+ merge!(YAML.load(IO.read(CONFIG_FILE))) if test(?f, CONFIG_FILE)
13
+ merge!(YAML.load(IO.read(HOME + "/config/#{app_name}.yml")))
13
14
  end
14
- @config.merge!(cli_options)
15
+ merge!(cli_options)
15
16
  end
16
17
 
17
18
  def [](*path)
@@ -23,6 +24,14 @@ module Cerberus
23
24
  c
24
25
  end
25
26
 
27
+ def merge!(hash)
28
+ @config.deep_merge!(hash)
29
+ end
30
+
31
+ def inspect
32
+ @config.inspect
33
+ end
34
+
26
35
  private
27
36
  def symbolize_hash(hash)
28
37
  hash.each_pair{|k,v|
@@ -111,14 +111,13 @@ module Cerberus
111
111
  end
112
112
 
113
113
  if [:failure, :broken, :revival, :setup].include?(state)
114
- @config[:publisher, :active].split.each do |pub|
114
+ active_publishers = @config[:publisher, :active] || 'mail'
115
+ active_publishers.split(/\W+/).each do |pub|
116
+ raise "Publisher have no configuration: #{pub}" unless @config[:publisher, pub]
117
+ clazz = PUBLISHER_TYPES[pub.to_sym]
118
+ raise "There is no such publisher: #{pub}" unless clazz
115
119
  silence_stream(STDOUT) { #some of publishers like IRC very noisy
116
- clazz = PUBLISHER_TYPES[pub.to_sym]
117
- if clazz
118
- clazz.publish(state, self, @config)
119
- else
120
- raise "There is no such publisher: #{pub}"
121
- end
120
+ clazz.publish(state, self, @config)
122
121
  }
123
122
  end
124
123
  end
@@ -4,6 +4,7 @@ require 'cerberus/publisher/base'
4
4
  class Cerberus::Publisher::IRC < Cerberus::Publisher::Base
5
5
  def self.publish(state, build, options)
6
6
  irc_options = options[:publisher, :irc]
7
+ raise "There is no channel provided for IRC publisher" unless irc_options[:channel]
7
8
  subject,body = Cerberus::Publisher::Base.formatted_message(state, build, options)
8
9
  message = subject + "\n" + '*' * subject.length + "\n" + body
9
10
 
@@ -5,6 +5,8 @@ class Cerberus::Publisher::Jabber < Cerberus::Publisher::Base
5
5
  def self.publish(state, build, options)
6
6
  begin
7
7
  jabber_options = options[:publisher, :jabber]
8
+ raise "There is no recipients provided for Jabber publisher" unless jabber_options[:recipients]
9
+
8
10
  subject,body = Cerberus::Publisher::Base.formatted_message(state, build, options)
9
11
 
10
12
  session = login(jabber_options[:jid], jabber_options[:password])
@@ -3,7 +3,10 @@ require 'cerberus/publisher/base'
3
3
 
4
4
  class Cerberus::Publisher::Mail < Cerberus::Publisher::Base
5
5
  def self.publish(state, build, options)
6
- configure(options[:publisher, :mail].dup)
6
+ mail_opts = options[:publisher, :mail].dup
7
+ raise "There is no recipients provided for mail publisher" unless mail_opts[:recipients]
8
+
9
+ configure(mail_opts)
7
10
  ActionMailerPublisher.deliver_message(state, build, options)
8
11
  end
9
12
 
@@ -36,4 +36,16 @@ def `(cmd)
36
36
  rescue Exception => e
37
37
  raise "Unable to execute: #{cmd}"
38
38
  end
39
+ end
40
+
41
+ class Hash
42
+ def deep_merge!(second)
43
+ second.each_pair do |k,v|
44
+ if self[k].is_a?(Hash) and second[k].is_a?(Hash)
45
+ self[k].deep_merge!(second[k])
46
+ else
47
+ self[k] = second[k]
48
+ end
49
+ end
50
+ end
39
51
  end
@@ -2,7 +2,7 @@ module Cerberus
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -23,4 +23,16 @@ class ConfigTest < Test::Unit::TestCase
23
23
  assert_equal 'app', cfg['g']
24
24
  assert_equal 'conf', cfg['m']
25
25
  end
26
+
27
+ def test_deep_merge
28
+ cfg = Cerberus::Config.new
29
+ cfg.merge!(:hello => {'msg' => {:a202 => 'bye'}})
30
+ cfg.merge!(:hello => {:msg => {:a203 => 'hello'}})
31
+ cfg.merge!(:hello => {:msg => {:a204 => 'another'}})
32
+ cfg.merge!(:hello => {:bread => {:a204 => 'bread'}})
33
+
34
+ assert_equal 'bye', cfg[:hello, :msg, :a202]
35
+ assert_equal 'hello', cfg[:hello, :msg, :a203]
36
+ assert_equal 'bread', cfg[:hello, :bread, :a204]
37
+ end
26
38
  end
@@ -88,7 +88,7 @@ class FunctionalTest < Test::Unit::TestCase
88
88
  end
89
89
 
90
90
  def test_have_no_awkward_header
91
- add_application('myapp', SVN_URL)
91
+ add_application('myapp', SVN_URL, 'publisher' => {'active' => 'mail'})
92
92
 
93
93
  build = Cerberus::BuildCommand.new('myapp')
94
94
  build.run
@@ -97,6 +97,34 @@ class FunctionalTest < Test::Unit::TestCase
97
97
  assert_equal 0, build.scm.last_commit_message.index('-' * 72)
98
98
  end
99
99
 
100
+ def test_multiply_publishers_without_configuration
101
+ add_application('myapp', SVN_URL, 'publisher' => {'active' => 'mail , jabber , irc, dddd'})
102
+
103
+ build = Cerberus::BuildCommand.new('myapp')
104
+
105
+ begin
106
+ build.run
107
+ rescue RuntimeError => e
108
+ assert_equal 'Publisher have no configuration: jabber', e.message
109
+ else
110
+ assert false
111
+ end
112
+ end
113
+
114
+ def test_application_and_config_together
115
+ add_config('publisher' => {'active' => 'jabber'})
116
+ add_application('myapp', SVN_URL)
117
+ build = Cerberus::BuildCommand.new('myapp')
118
+
119
+ begin
120
+ build.run
121
+ rescue RuntimeError => e
122
+ assert_equal 'Publisher have no configuration: jabber', e.message
123
+ else
124
+ assert false
125
+ end
126
+ end
127
+
100
128
  def test_batch_running
101
129
  add_application('myapp1', SVN_URL)
102
130
  add_application('myapp2', SVN_URL)
@@ -50,15 +50,19 @@ end"
50
50
  end
51
51
 
52
52
  def add_application(app_name, url, options = {})
53
- opt = options.merge(
54
- 'scm'=>{'url'=>url},
55
- 'publisher'=>{
56
- 'active' => 'mail',
57
- 'mail'=>{'recipients'=>'somebody@com.com', 'delivery_method' => 'test'}
58
- })
53
+ opt = {'scm'=>{'url'=>url},
54
+ 'publisher'=>{
55
+ 'mail'=>{'recipients'=>'somebody@com.com', 'delivery_method' => 'test'}
56
+ }}
57
+
58
+ opt.deep_merge!(options)
59
59
 
60
60
  dump_yml(HOME + "/config/#{app_name}.yml", opt)
61
61
  end
62
+
63
+ def add_config(options)
64
+ dump_yml(HOME + "/config.yml", options)
65
+ end
62
66
  end
63
67
 
64
68
  require 'cerberus/config'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: cerberus
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.0
7
- date: 2006-08-11 00:00:00 +04:00
6
+ version: 0.2.1
7
+ date: 2006-08-14 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