rrschedule 0.2.7 → 0.2.8
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/VERSION +1 -1
- data/lib/rrschedule.rb +13 -0
- data/test/test_rrschedule.rb +28 -28
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.8
|
data/lib/rrschedule.rb
CHANGED
@@ -242,6 +242,19 @@ module RRSchedule
|
|
242
242
|
|
243
243
|
@cur_date ||= next_game_date(self.start_date,@cur_rule.wday)
|
244
244
|
@schedule ||= []
|
245
|
+
|
246
|
+
#if one of the team has already plays at this gamedate, we change rule
|
247
|
+
if @schedule.size>0
|
248
|
+
games_this_date = @schedule.select{|v| v[:gamedate] == @cur_date}
|
249
|
+
if games_this_date.select{|g| [game.team_a,game.team_b].include?(g[:team_a]) || [game.team_a,game.team_b].include?(g[:team_b])}.size >0
|
250
|
+
@cur_rule_index = (@cur_rule_index < @rules.size-1) ? @cur_rule_index+1 : 0
|
251
|
+
@cur_rule = @rules[@cur_rule_index]
|
252
|
+
reset_resource_availability
|
253
|
+
@cur_gt = get_best_gt(game)
|
254
|
+
@cur_ps = get_best_ps(game,@cur_gt)
|
255
|
+
@cur_date = next_game_date(@cur_date+=1,@cur_rule.wday)
|
256
|
+
end
|
257
|
+
end
|
245
258
|
|
246
259
|
@schedule << {:team_a => game.team_a, :team_b => game.team_b, :gamedate => @cur_date, :ps => @cur_ps, :gt => @cur_gt}
|
247
260
|
|
data/test/test_rrschedule.rb
CHANGED
@@ -47,34 +47,34 @@ class TestRrschedule < Test::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
50
|
+
context "extra available resources" do
|
51
|
+
setup do
|
52
|
+
@s = Schedule.new(
|
53
|
+
:teams => %w(a1 a2 a3 a4 a5),
|
54
|
+
:rules => [
|
55
|
+
Rule.new(
|
56
|
+
:wday => 3,
|
57
|
+
:gt => ["7:00PM", "9:00PM"],
|
58
|
+
:ps => %w(one two three four)
|
59
|
+
)
|
60
|
+
]
|
61
|
+
).generate
|
62
|
+
end
|
63
|
+
|
64
|
+
should "have a maximum of (teams/2) games per day" do
|
65
|
+
@s.gamedays.each do |gd|
|
66
|
+
assert gd.games.size <= @s.teams.size/2
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
should "not have a team that play more than once on a single day" do
|
71
|
+
@s.gamedays.each do |gd|
|
72
|
+
day_teams = gd.games.collect{|g| [g.team_a,g.team_b]}.flatten
|
73
|
+
unique_day_teams = day_teams.uniq
|
74
|
+
assert_equal day_teams.size, unique_day_teams.size
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
78
|
|
79
79
|
|
80
80
|
context "multi flights" do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rrschedule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- flamontagne
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-25 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|