rrschedule 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.5
data/lib/rrschedule.rb CHANGED
@@ -203,10 +203,11 @@ module RRSchedule
203
203
  else
204
204
  #PS and GT stack empty... we go to the next rule
205
205
  if @cur_rule_index < @rules.size-1
206
+ last_rule=@cur_rule
206
207
  @cur_rule_index += 1
207
208
  @cur_rule = @rules[@cur_rule_index]
208
209
  #Go to the next date (except if the new rule is for the same weekday)
209
- @cur_date = next_game_date(@cur_date+=1,@cur_rule.wday) if @cur_rule.wday != @rules[@cur_rule_index].wday
210
+ @cur_date = next_game_date(@cur_date+=1,@cur_rule.wday) if last_rule.wday != @cur_rule.wday
210
211
  else
211
212
  @cur_rule_index = 0
212
213
  @cur_rule = @rules[@cur_rule_index]
@@ -98,22 +98,37 @@ class TestRrschedule < Test::Unit::TestCase
98
98
  :exclude_dates => [
99
99
  Date.parse("2011/02/02")
100
100
  ]
101
- ).generate
101
+ )
102
102
  end
103
103
 
104
104
  should "generate separate round-robins" do
105
+ @s.generate
105
106
  assert_equal 4, @s.flights.size
106
107
  4.times { |i| assert @s.round_robin?(i)}
107
108
  end
108
109
 
109
110
  should "have a correct total number of games" do
111
+ @s.generate
110
112
  assert_equal 112, @s.gamedays.collect{|gd| gd.games.size}.inject{|x,sum| x+sum}
111
113
  end
112
114
 
113
115
  should "not have games for a date that is excluded" do
116
+ @s.generate
114
117
  assert !@s.gamedays.collect{|gd| gd.date}.include?(Date.parse("2011/02/02"))
115
118
  assert @s.gamedays.collect{|gd| gd.date}.include?(Date.parse("2011/02/09"))
116
119
  end
120
+
121
+ should "respect rules" do
122
+ @s.teams << %w(E1 E2 E3 E4 E5 E6 E7 E8)
123
+ @s.rules << Rule.new(:wday => 4, :gt => "7:00PM", :ps => %w(one two))
124
+ @s.generate
125
+
126
+ wday = 3
127
+ @s.gamedays.each do |gd|
128
+ assert_equal wday, gd.date.wday
129
+ wday = (wday==3) ? 4 : 3
130
+ end
131
+ end
117
132
  end
118
133
 
119
134
  ##### RULES #######
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrschedule
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - flamontagne
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-18 00:00:00 -05:00
18
+ date: 2011-02-19 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency