cerberus 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,10 @@
1
1
  = Cerberus Changelog
2
2
 
3
+ == Version 0.4.3
4
+ Custom Builder Scheduling
5
+
6
+ * Added at_time project config option to schedule when project is built via "cerberus buildall" command
7
+
3
8
  == Version 0.4.2
4
9
  RSpec builder bugfixes
5
10
 
data/Rakefile CHANGED
@@ -27,9 +27,11 @@ end
27
27
 
28
28
  desc "Clean all generated files"
29
29
  task :clean => :clobber_package do
30
- rm_rf "#{File.dirname(__FILE__)}/test/__workdir"
31
- rm_rf "#{File.dirname(__FILE__)}/coverage"
32
- rm_rf "#{File.dirname(__FILE__)}/doc/site/output"
30
+ root = File.dirname(__FILE__)
31
+ rm_rf "#{root}/test/__workdir"
32
+ rm_rf "#{root}/coverage"
33
+ rm_rf "#{root}/doc/site/out"
34
+ rm_rf "#{root}/doc/site/webgen.cache"
33
35
  end
34
36
 
35
37
 
@@ -142,22 +144,19 @@ task :publish_news do
142
144
  publisher.user_name = RUBYFORGE_USER
143
145
  publisher.password = ENV['RUBYFORGE_PASSWORD']
144
146
  publisher.subject = "[ANN] Cerberus #{PKG_VERSION} Released"
145
- publisher.details = IO.read(File.dirname(__FILE__) + '/README')
147
+ publisher.details = IO.read(File.dirname(__FILE__) + '/CHANGES')
146
148
  end
147
149
  end
148
150
 
149
-
150
-
151
151
  require 'webgen/webgentask'
152
-
153
- task :www => :webgen
152
+ task :generate_site => :webgen
154
153
 
155
154
  Webgen::WebgenTask.new do |t|
156
155
  t.directory = File.join( File.dirname( __FILE__ ), 'doc/site')
157
156
  t.clobber_outdir = true
158
157
  end
159
158
 
160
- task :publish_site => :webgen do
159
+ task :publish_site => :generate_site do
161
160
  sh %{scp -r -q doc/site/out/* #{RUBYFORGE_USER}@rubyforge.org:/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/}
162
161
  end
163
162
 
@@ -4,5 +4,5 @@ module Cerberus
4
4
 
5
5
  LOCK_WAIT = 30 * 60 #30 minutes
6
6
 
7
- VERSION = '0.4.2'
7
+ VERSION = '0.4.3'
8
8
  end
@@ -81,7 +81,8 @@ module Cerberus
81
81
  attr_reader :builder, :success, :scm, :status
82
82
 
83
83
  DEFAULT_CONFIG = {:scm => {:type => 'svn'},
84
- :log => {:enable => true}
84
+ :log => {:enable => true},
85
+ :at_time => '* *',
85
86
  }
86
87
 
87
88
  def initialize(application_name, cli_options = {})
@@ -161,6 +162,15 @@ module Cerberus
161
162
  end
162
163
  end
163
164
  end
165
+
166
+ def run_time?(time)
167
+ minute, hour = @config[:at_time].split
168
+ say "Run time is configured wrong." if minute.nil? or hour.nil?
169
+ if hour.cron_match?(time.hour)
170
+ return minute.cron_match?(time.min)
171
+ end
172
+ return false
173
+ end
164
174
 
165
175
  private
166
176
  def get_configuration_option(hash, defining_key = nil, default_option = nil)
@@ -184,7 +194,7 @@ module Cerberus
184
194
  application_name = $1
185
195
 
186
196
  command = Cerberus::BuildCommand.new(application_name, @cli_options)
187
- threads << Thread.new { command.run }
197
+ threads << Thread.new { command.run } if command.run_time?(Time.now)
188
198
  end
189
199
 
190
200
  @already_waited = false
@@ -155,3 +155,33 @@ class IO
155
155
  File.open(filename, 'w'){|f| f.write str}
156
156
  end
157
157
  end
158
+
159
+ class String
160
+ def cron_match?(number)
161
+ return false if not number.is_a?(Integer)
162
+ return true if self == "*"
163
+ parts = self.split(",")
164
+ parts.each do |p|
165
+ match = p.match(/(\d+|\*)-?(\d+)?(\/(\d+))?$/)
166
+ return false if not match
167
+ if not match[2]
168
+ if match[1] == "*" and match[4]
169
+ return true if number % match[4].to_i == 0
170
+ end
171
+ return true if match[1].to_i == number
172
+ else
173
+ range = (match[1].to_i)..(match[2].to_i)
174
+ if not match[3]
175
+ return true if range.include?(number)
176
+ else
177
+ range.each do |r|
178
+ if (r - range.first) % match[4].to_i == 0
179
+ return true if r == number
180
+ end
181
+ end
182
+ end
183
+ end
184
+ end
185
+ return false
186
+ end
187
+ end
@@ -0,0 +1,94 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ require 'cerberus/utils'
4
+
5
+ class CronStringTest < Test::Unit::TestCase
6
+
7
+ def test_simple_number
8
+ assert "1".cron_match?(1)
9
+ end
10
+
11
+ def test_star
12
+ assert "*".cron_match?(0)
13
+ assert "*".cron_match?(1000)
14
+ end
15
+
16
+ def test_not_match_simple
17
+ assert_equal false, "1".cron_match?(2)
18
+ end
19
+
20
+ def test_separate_numbers
21
+ str = "1,3,5"
22
+ assert str.cron_match?(1)
23
+ assert str.cron_match?(3)
24
+ assert str.cron_match?(5)
25
+ assert(!str.cron_match?(0))
26
+ assert(!str.cron_match?(2))
27
+ assert(!str.cron_match?(4))
28
+ assert(!str.cron_match?(6))
29
+ end
30
+
31
+ def test_range
32
+ str = "2-4"
33
+ assert(!str.cron_match?(1))
34
+ assert str.cron_match?(2)
35
+ assert str.cron_match?(3)
36
+ assert str.cron_match?(4)
37
+ assert(!str.cron_match?(5))
38
+ end
39
+
40
+ def test_comma_and_range
41
+ str = "3-4,7-8"
42
+ assert(!str.cron_match?(2))
43
+ assert str.cron_match?(3)
44
+ assert str.cron_match?(4)
45
+ assert(!str.cron_match?(5))
46
+ assert(!str.cron_match?(6))
47
+ assert str.cron_match?(7)
48
+ assert str.cron_match?(8)
49
+ assert(!str.cron_match?(9))
50
+ end
51
+
52
+ def test_divisor
53
+ str = "1-6/2"
54
+ assert(!str.cron_match?(0))
55
+ assert str.cron_match?(1)
56
+ assert(!str.cron_match?(2))
57
+ assert str.cron_match?(3)
58
+ assert(!str.cron_match?(4))
59
+ assert str.cron_match?(5)
60
+ assert(!str.cron_match?(6))
61
+ end
62
+
63
+ def test_garble
64
+ assert(!"1,x".cron_match?(6))
65
+ assert(!",".cron_match?(6))
66
+ assert(!"x".cron_match?(6))
67
+ assert(!"1-10/x".cron_match?(6))
68
+ assert(!"~-10/2".cron_match?(6))
69
+ end
70
+
71
+ def test_star_and_divisor
72
+ str = "*/3"
73
+ assert str.cron_match?(0)
74
+ assert(!str.cron_match?(1))
75
+ assert(!str.cron_match?(2))
76
+ assert str.cron_match?(3)
77
+ assert(!str.cron_match?(4))
78
+ assert(!str.cron_match?(5))
79
+ assert str.cron_match?(6)
80
+ assert str.cron_match?(9)
81
+ assert str.cron_match?(12)
82
+ assert str.cron_match?(129)
83
+ end
84
+
85
+ def test_star_with_letters
86
+ assert(!"*".cron_match?('A'))
87
+ end
88
+
89
+ def test_star_in_wrong_place
90
+ assert(!"*-12".cron_match?('1'))
91
+ assert(!"*-12/2".cron_match?('2'))
92
+ end
93
+
94
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cerberus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatol Pomozov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-26 00:00:00 -05:00
12
+ date: 2009-02-13 00:00:00 -05:00
13
13
  default_executable: cerberus
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -128,6 +128,7 @@ files:
128
128
  - lib/cerberus/utils.rb
129
129
  - test/bjam_builder_test.rb
130
130
  - test/config_test.rb
131
+ - test/cron_string_test.rb
131
132
  - test/data
132
133
  - test/data/darcs.zip
133
134
  - test/data/git.zip
@@ -183,6 +184,7 @@ summary: Cerberus is a Continuous Integration tool that could be easily run from
183
184
  test_files:
184
185
  - test/bjam_builder_test.rb
185
186
  - test/config_test.rb
187
+ - test/cron_string_test.rb
186
188
  - test/functional_test.rb
187
189
  - test/integration_test.rb
188
190
  - test/irc_publisher_test.rb