cerberus 0.3.5 → 0.3.6

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.
Files changed (42) hide show
  1. data/CHANGES +159 -129
  2. data/LICENSE +21 -21
  3. data/README +75 -75
  4. data/Rakefile +161 -159
  5. data/bin/cerberus +2 -2
  6. data/lib/cerberus/builder/maven2.rb +38 -38
  7. data/lib/cerberus/builder/rake.rb +7 -7
  8. data/lib/cerberus/builder/rant.rb +7 -7
  9. data/lib/cerberus/builder/rspec.rb +13 -0
  10. data/lib/cerberus/builder/ruby_base.rb +48 -47
  11. data/lib/cerberus/cli.rb +73 -70
  12. data/lib/cerberus/component_lazy_loader.rb +2 -0
  13. data/lib/cerberus/config.example.yml +28 -28
  14. data/lib/cerberus/config.rb +47 -46
  15. data/lib/cerberus/constants.rb +8 -8
  16. data/lib/cerberus/latch.rb +26 -26
  17. data/lib/cerberus/manager.rb +296 -267
  18. data/lib/cerberus/publisher/base.rb +47 -47
  19. data/lib/cerberus/publisher/gmailer.rb +17 -0
  20. data/lib/cerberus/publisher/irc.rb +27 -27
  21. data/lib/cerberus/publisher/jabber.rb +25 -25
  22. data/lib/cerberus/publisher/mail.rb +36 -36
  23. data/lib/cerberus/publisher/netsmtp_tls_fix.rb +66 -66
  24. data/lib/cerberus/publisher/rss.rb +27 -28
  25. data/lib/cerberus/scm/cvs.rb +48 -48
  26. data/lib/cerberus/scm/darcs.rb +70 -70
  27. data/lib/cerberus/scm/svn.rb +83 -83
  28. data/lib/cerberus/utils.rb +156 -156
  29. data/test/config_test.rb +45 -45
  30. data/test/functional_test.rb +288 -287
  31. data/test/integration_test.rb +104 -104
  32. data/test/irc_publisher_test.rb +18 -18
  33. data/test/jabber_publisher_test.rb +21 -21
  34. data/test/mail_publisher_test.rb +25 -25
  35. data/test/maven2_builer_test.rb +81 -81
  36. data/test/mock/irc.rb +20 -20
  37. data/test/mock/manager.rb +10 -10
  38. data/test/mock/xmpp4r.rb +19 -19
  39. data/test/rss_publisher_test.rb +21 -21
  40. data/test/test_helper.rb +105 -105
  41. metadata +58 -40
  42. data/lib/cerberus/helper/xchar.rb +0 -61
@@ -1,47 +1,48 @@
1
- require 'cerberus/builder/base'
2
-
3
- class Cerberus::Builder::RubyBase
4
- attr_reader :output
5
-
6
- def initialize(config, cmd)
7
- @config = config
8
- @cmd = cmd
9
- end
10
-
11
- def run
12
- Dir.chdir @config[:application_root]
13
- @output = `#{@config[:bin_path]}#{choose_exec()} #{@config[:builder, @cmd.to_sym, :task]} 2>&1`
14
- successful?
15
- end
16
-
17
- def successful?
18
- $?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!")
19
- end
20
-
21
- def brokeness
22
- if @output =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
23
- $1.to_i + $2.to_i
24
- end
25
- end
26
-
27
- private
28
- def choose_exec
29
- ext = ['']
30
-
31
- if os() == :windows
32
- ext << '.bat' << '.cmd'
33
- end
34
-
35
- silence_stream(STDERR) {
36
- ext.each do |e|
37
- begin
38
- out = `#{@config[:bin_path]}#{@cmd}#{e} --version 2>&1`
39
- return "#{@cmd}#{e}" if out =~ /#{@cmd}/
40
- rescue
41
- end
42
- end
43
- }
44
-
45
- raise "#{@cmd} builder did not find. Make sure that such script exists and have executable permissions."
46
- end
47
- end
1
+ require 'cerberus/builder/base'
2
+
3
+ class Cerberus::Builder::RubyBase
4
+ attr_reader :output
5
+
6
+ def initialize(config, name, cmd = name)
7
+ @config = config
8
+ @cmd = cmd
9
+ @name = name
10
+ end
11
+
12
+ def run
13
+ Dir.chdir @config[:application_root]
14
+ @output = `#{@config[:bin_path]}#{choose_exec()} #{@config[:builder, @name.to_sym, :task]} 2>&1`
15
+ successful?
16
+ end
17
+
18
+ def successful?
19
+ $?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!")
20
+ end
21
+
22
+ def brokeness
23
+ if @output =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
24
+ $1.to_i + $2.to_i
25
+ end
26
+ end
27
+
28
+ private
29
+ def choose_exec
30
+ ext = ['']
31
+
32
+ if os() == :windows
33
+ ext << '.bat' << '.cmd'
34
+ end
35
+
36
+ silence_stream(STDERR) {
37
+ ext.each do |e|
38
+ begin
39
+ out = `#{@config[:bin_path]}#{@cmd}#{e} --version 2>&1`
40
+ return "#{@cmd}#{e}" if out =~ /#{@cmd}/
41
+ rescue
42
+ end
43
+ end
44
+ }
45
+
46
+ raise "#{@cmd} builder did not find. Make sure that such script exists and have executable permissions."
47
+ end
48
+ end
data/lib/cerberus/cli.rb CHANGED
@@ -1,70 +1,73 @@
1
- require 'cerberus/manager'
2
- require 'cerberus/utils'
3
- require 'cerberus/constants'
4
-
5
- module Cerberus
6
- class CLI
7
- def initialize(*args)
8
- say HELP if args.empty?
9
-
10
- command = args.shift
11
- say HELP unless %w(add build buildall list).include?(command)
12
-
13
- cli_options = extract_options(args)
14
-
15
- case command
16
- when 'add'
17
- path = args.shift || Dir.pwd
18
-
19
- command = Cerberus::AddCommand.new(path, cli_options)
20
- command.run
21
- when 'build'
22
- say HELP if args.empty?
23
-
24
- application_name = args.shift
25
-
26
- command = Cerberus::BuildCommand.new(application_name, cli_options)
27
- command.run
28
- when 'buildall'
29
- command = Cerberus::BuildAllCommand.new(cli_options)
30
- command.run
31
- when 'list'
32
- command = Cerberus::ListCommand.new(cli_options)
33
- command.run
34
- end
35
- end
36
-
37
- private
38
- def extract_options(args)
39
- result = {}
40
- args_copy = args.dup
41
- args_copy.each do |arg|
42
- case arg
43
- when /^(\w+)=(.*)$/
44
- result[$1.downcase.to_sym] = $2
45
- args.delete(arg)
46
- when '--force'
47
- result[:force] = true
48
- args.delete(arg)
49
- end
50
- end
51
-
52
- result
53
- end
54
- end
55
-
56
- HELP = %{
57
- Cerberus is a lightweight command-line Continuous Integration tool for Ruby.
58
-
59
- Usage:
60
- cerberus add <URL> --- add project from svn repository to list watched of applications
61
- cerberus add <PATH> --- add project from local path to list of watched applications
62
- cerberus build <NAME> --- build watched application
63
- cerberus buildall --- build all watched applications
64
- cerberus list --- see the list of all watched applications
65
-
66
- Version: #{Cerberus::VERSION}
67
- Cerberus Path: "#{Cerberus::HOME}"
68
- Cerberus Homepage: http://cerberus.rubyforge.org
69
- }.gsub("\n ","\n")
70
- end
1
+ require 'cerberus/manager'
2
+ require 'cerberus/utils'
3
+ require 'cerberus/constants'
4
+
5
+ module Cerberus
6
+ class CLI
7
+ def initialize(*args)
8
+ say HELP if args.empty?
9
+
10
+ command = args.shift
11
+ say HELP unless %w(add remove build buildall list).include?(command)
12
+
13
+ cli_options = extract_options(args)
14
+
15
+ case command
16
+ when 'add'
17
+ path = args.shift || Dir.pwd
18
+ command = Cerberus::AddCommand.new(path, cli_options)
19
+ command.run
20
+ when 'remove'
21
+ command = Cerberus::RemoveCommand.new(args.shift, cli_options)
22
+ command.run
23
+ when 'build'
24
+ say HELP if args.empty?
25
+
26
+ application_name = args.shift
27
+
28
+ command = Cerberus::BuildCommand.new(application_name, cli_options)
29
+ command.run
30
+ when 'buildall'
31
+ command = Cerberus::BuildAllCommand.new(cli_options)
32
+ command.run
33
+ when 'list'
34
+ command = Cerberus::ListCommand.new(cli_options)
35
+ command.run
36
+ end
37
+ end
38
+
39
+ private
40
+ def extract_options(args)
41
+ result = {}
42
+ args_copy = args.dup
43
+ args_copy.each do |arg|
44
+ case arg
45
+ when /^(\w+)=(.*)$/
46
+ result[$1.downcase.to_sym] = $2
47
+ args.delete(arg)
48
+ when '--force'
49
+ result[:force] = true
50
+ args.delete(arg)
51
+ end
52
+ end
53
+
54
+ result
55
+ end
56
+ end
57
+
58
+ HELP = %{
59
+ Cerberus is a lightweight command-line Continuous Integration tool for Ruby.
60
+
61
+ Usage:
62
+ cerberus add <URL> --- add project from svn repository to list watched of applications
63
+ cerberus add <PATH> --- add project from local path to list of watched applications
64
+ cerberus remove <NAME> --- remove given project from cerberus
65
+ cerberus build <NAME> --- build watched application
66
+ cerberus buildall --- build all watched applications
67
+ cerberus list --- see the list of all watched applications
68
+
69
+ Version: #{Cerberus::VERSION}
70
+ Cerberus Path: "#{Cerberus::HOME}"
71
+ Cerberus Homepage: http://cerberus.rubyforge.org
72
+ }.gsub("\n ","\n")
73
+ end
@@ -38,6 +38,7 @@ module Cerberus
38
38
  module Publisher
39
39
  TYPES = {
40
40
  :mail => 'Mail', #Cerberus::Publisher
41
+ :gmailer => 'Gmailer',
41
42
  :jabber => 'Jabber',
42
43
  :irc => 'IRC',
43
44
  :rss => 'RSS',
@@ -56,6 +57,7 @@ module Cerberus
56
57
  TYPES = {
57
58
  :maven2 => 'Maven2', #Cerberus::Builder
58
59
  :rake => 'Rake',
60
+ :rspec => 'RSpec',
59
61
  :rant => 'Rant',
60
62
  :bjam => 'Bjam'
61
63
  }
@@ -1,29 +1,29 @@
1
- publisher:
2
- # active: mail jabber rss campfire
3
- mail:
4
- address: smtp.gmail.com
5
- port: 587
6
- domain: gmail.com
7
- authentication: plain
8
- user_name: someuser
9
- password: somepassword
10
- # on_event: all
11
- # jabber:
12
- # jid: somemailbox@gmail.com/cerberus
13
- # password: somepassword
14
- # irc:
15
- # nick: cerb
16
- # server: irc.freenode.net
17
- # channel: cerberus
18
- # campfire:
19
- # url: http://someemail:password@cerberustool.campfirenow.com/room/51660
20
- # rss:
21
- # file: /usr/www/rss.xml
22
- #builder:
23
- # rake:
24
- # task: migrate test
25
- #changeset_url: POINT_TO_YOUR_TRAC/changeset/
26
- #hook:
27
- # rcov:
28
- # on_event: successful, setup #by default - run hook for any state
1
+ publisher:
2
+ # active: mail jabber rss campfire
3
+ mail:
4
+ address: smtp.gmail.com
5
+ port: 587
6
+ domain: gmail.com
7
+ authentication: plain
8
+ user_name: someuser
9
+ password: somepassword
10
+ # on_event: all
11
+ # jabber:
12
+ # jid: somemailbox@gmail.com/cerberus
13
+ # password: somepassword
14
+ # irc:
15
+ # nick: cerb
16
+ # server: irc.freenode.net
17
+ # channel: cerberus
18
+ # campfire:
19
+ # url: http://someemail:password@cerberustool.campfirenow.com/room/51660
20
+ # rss:
21
+ # file: /usr/www/rss.xml
22
+ #builder:
23
+ # rake:
24
+ # task: migrate test
25
+ #changeset_url: POINT_TO_YOUR_TRAC/changeset/
26
+ #hook:
27
+ # rcov:
28
+ # on_event: successful, setup #by default - run hook for any state
29
29
  # action: 'export CERBERUS_HOME=/home/anatol && sudo chown www-data -R /home/anatol/cerberus && rcov' #Add here any hook you want
@@ -1,47 +1,48 @@
1
- require 'cerberus/constants'
2
- require 'cerberus/utils'
3
-
4
- module Cerberus
5
- class Config
6
- def initialize(app_name = nil, cli_options = {})
7
- @config = HashWithIndifferentAccess.new
8
- if app_name
9
- merge!(YAML.load(IO.read(CONFIG_FILE))) if test(?f, CONFIG_FILE)
10
- merge!(YAML.load(IO.read(HOME + "/config/#{app_name}.yml")))
11
- end
12
- merge!(cli_options)
13
- end
14
-
15
- def [](*path)
16
- c = @config
17
- path.each{|p|
18
- c = c[p]
19
- return if c.nil?
20
- }
21
- c
22
- end
23
-
24
- def merge!(hash, overwrite = true)
25
- if overwrite
26
- @config.deep_merge!(hash)
27
- else
28
- d = HashWithIndifferentAccess.new(hash)
29
- d.deep_merge!(@config)
30
- @config = d
31
- end
32
- end
33
-
34
- def inspect
35
- @config.inspect
36
- end
37
-
38
- private
39
- def symbolize_hash(hash)
40
- hash.each_pair{|k,v|
41
- if v === Hash
42
- hash[k] = HashWithIndifferentAccess.new(symbolize_hash(v))
43
- end
44
- }
45
- end
46
- end
1
+ require 'cerberus/constants'
2
+ require 'cerberus/utils'
3
+ require 'erb'
4
+
5
+ module Cerberus
6
+ class Config
7
+ def initialize(app_name = nil, cli_options = {})
8
+ @config = HashWithIndifferentAccess.new
9
+ if app_name
10
+ merge!(YAML.load(ERB.new(IO.read(CONFIG_FILE)).result)) if test(?f, CONFIG_FILE)
11
+ merge!(YAML.load(ERB.new(IO.read(HOME + "/config/#{app_name}.yml")).result))
12
+ end
13
+ merge!(cli_options)
14
+ end
15
+
16
+ def [](*path)
17
+ c = @config
18
+ path.each{|p|
19
+ c = c[p]
20
+ return if c.nil?
21
+ }
22
+ c
23
+ end
24
+
25
+ def merge!(hash, overwrite = true)
26
+ if overwrite
27
+ @config.deep_merge!(hash)
28
+ else
29
+ d = HashWithIndifferentAccess.new(hash)
30
+ d.deep_merge!(@config)
31
+ @config = d
32
+ end
33
+ end
34
+
35
+ def inspect
36
+ @config.inspect
37
+ end
38
+
39
+ private
40
+ def symbolize_hash(hash)
41
+ hash.each_pair{|k,v|
42
+ if v === Hash
43
+ hash[k] = HashWithIndifferentAccess.new(symbolize_hash(v))
44
+ end
45
+ }
46
+ end
47
+ end
47
48
  end
@@ -1,8 +1,8 @@
1
- module Cerberus
2
- HOME = File.expand_path(ENV['CERBERUS_HOME'] || '~/.cerberus')
3
- CONFIG_FILE = "#{HOME}/config.yml"
4
-
5
- LOCK_WAIT = 30 * 60 #30 minutes
6
-
7
- VERSION = '0.3.5'
8
- end
1
+ module Cerberus
2
+ HOME = File.expand_path(ENV['CERBERUS_HOME'] || '~/.cerberus')
3
+ CONFIG_FILE = "#{HOME}/config.yml"
4
+
5
+ LOCK_WAIT = 30 * 60 #30 minutes
6
+
7
+ VERSION = '0.3.6'
8
+ end
@@ -1,27 +1,27 @@
1
- require 'fileutils'
2
-
3
- module Cerberus
4
- class Latch
5
- #Emulate File.flock
6
- def self.lock(lock_file, options = {})
7
- if File.exists?(lock_file)
8
- modif_time = File::Stat.new(lock_file).mtime
9
- ttl = options[:lock_ttl]
10
-
11
- if ttl and modif_time + ttl < Time.now
12
- File.delete(lock_file)
13
- else
14
- return
15
- end
16
- end
17
-
18
- begin
19
- FileUtils.mkpath(File.dirname(lock_file))
20
- File.new(lock_file, 'w').close
21
- yield
22
- ensure
23
- File.delete(lock_file)
24
- end
25
- end
26
- end
1
+ require 'fileutils'
2
+
3
+ module Cerberus
4
+ class Latch
5
+ #Emulate File.flock
6
+ def self.lock(lock_file, options = {})
7
+ if File.exists?(lock_file)
8
+ modif_time = File::Stat.new(lock_file).mtime
9
+ ttl = options[:lock_ttl]
10
+
11
+ if ttl and modif_time + ttl < Time.now
12
+ File.delete(lock_file)
13
+ else
14
+ return
15
+ end
16
+ end
17
+
18
+ begin
19
+ FileUtils.mkpath(File.dirname(lock_file))
20
+ File.new(lock_file, 'w').close
21
+ yield
22
+ ensure
23
+ File.delete(lock_file)
24
+ end
25
+ end
26
+ end
27
27
  end