rrschedule 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rrschedule.rb +47 -14
- metadata +33 -37
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/lib/rrschedule.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
module RRSchedule
|
5
5
|
class Schedule
|
6
6
|
attr_reader :flights, :rounds, :gamedays
|
7
|
-
attr_accessor :teams, :rules, :cycles, :start_date, :exclude_dates,:shuffle, :balanced_gt, :balanced_ps
|
7
|
+
attr_accessor :teams, :rules, :cycles, :start_date, :exclude_dates,:shuffle, :group_flights, :balanced_gt, :balanced_ps
|
8
8
|
|
9
9
|
def initialize(params={})
|
10
10
|
@gamedays = []
|
@@ -15,6 +15,7 @@ module RRSchedule
|
|
15
15
|
self.balanced_ps = params[:balanced_ps].nil? ? true : params[:balanced_ps]
|
16
16
|
self.exclude_dates = params[:exclude_dates] || []
|
17
17
|
self.start_date = params[:start_date] || Date.today
|
18
|
+
self.group_flights = params[:group_flights].nil? ? true : params[:group_flights]
|
18
19
|
self.rules = params[:rules] || []
|
19
20
|
self
|
20
21
|
end
|
@@ -85,6 +86,15 @@ module RRSchedule
|
|
85
86
|
self
|
86
87
|
end
|
87
88
|
|
89
|
+
def total_nbr_games
|
90
|
+
total=0
|
91
|
+
|
92
|
+
@flights.each do |teams|
|
93
|
+
total += (teams.size / 2) * (teams.size-1)
|
94
|
+
end
|
95
|
+
total
|
96
|
+
end
|
97
|
+
|
88
98
|
#human readable schedule
|
89
99
|
def to_s
|
90
100
|
res = ""
|
@@ -133,24 +143,47 @@ module RRSchedule
|
|
133
143
|
|
134
144
|
#Dispatch games according to available playing surfaces and game times
|
135
145
|
def dispatch_games(rounds)
|
146
|
+
|
136
147
|
rounds_copy = Marshal.load(Marshal.dump(rounds)) #deep clone
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
148
|
+
|
149
|
+
flat_games = []
|
150
|
+
if group_flights
|
151
|
+
while rounds_copy.flatten.size > 0 do
|
152
|
+
@flights.each_with_index do |f,flight_index|
|
153
|
+
flat_games << rounds_copy[flight_index].shift.games
|
154
|
+
end
|
155
|
+
end
|
156
|
+
else
|
157
|
+
flight_index = round_index = 0
|
158
|
+
game_ctr = 0
|
159
|
+
while game_ctr < total_nbr_games
|
160
|
+
if rounds_copy[flight_index][round_index] != nil
|
161
|
+
game = rounds_copy[flight_index][round_index].games.shift
|
162
|
+
if game
|
163
|
+
flat_games << game
|
164
|
+
game_ctr += 1
|
165
|
+
end
|
145
166
|
end
|
146
|
-
end
|
147
167
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
168
|
+
#check if round is empty
|
169
|
+
round_empty=true
|
170
|
+
@flights.size.times do |i|
|
171
|
+
round_empty = round_empty && (rounds_copy[i][round_index].nil? || rounds_copy[i][round_index].games.empty?)
|
172
|
+
end
|
173
|
+
|
174
|
+
if flight_index == @flights.size-1
|
175
|
+
flight_index = 0
|
176
|
+
round_index+=1 if round_empty
|
177
|
+
else
|
178
|
+
flight_index += 1
|
179
|
+
end
|
152
180
|
end
|
153
181
|
end
|
182
|
+
|
183
|
+
flat_games.flatten!
|
184
|
+
flat_games.each do |game|
|
185
|
+
dispatch_game(game) unless [game.team_a,game.team_b].include?(:dummy)
|
186
|
+
end
|
154
187
|
|
155
188
|
#We group our schedule by gameday
|
156
189
|
s=@schedule.group_by{|fs| fs[:gamedate]}.sort
|
metadata
CHANGED
@@ -1,39 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rrschedule
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
4
5
|
prerelease:
|
5
|
-
version: 0.3.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- flamontagne
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: thoughtbot-shoulda
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
25
22
|
type: :development
|
26
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
27
30
|
description: This gem automate the process of creating a round-robin sport schedule.
|
28
31
|
email: flamontagne@azanka.ca
|
29
32
|
executables: []
|
30
|
-
|
31
33
|
extensions: []
|
32
|
-
|
33
|
-
extra_rdoc_files:
|
34
|
+
extra_rdoc_files:
|
34
35
|
- LICENSE
|
35
36
|
- README.markdown
|
36
|
-
files:
|
37
|
+
files:
|
37
38
|
- .document
|
38
39
|
- LICENSE
|
39
40
|
- README.markdown
|
@@ -44,33 +45,28 @@ files:
|
|
44
45
|
- test/helper.rb
|
45
46
|
- test/test_rrschedule.rb
|
46
47
|
- test_schedule.rb
|
47
|
-
has_rdoc: true
|
48
48
|
homepage: http://flamontagne.github.com/rrschedule
|
49
49
|
licenses: []
|
50
|
-
|
51
50
|
post_install_message:
|
52
51
|
rdoc_options: []
|
53
|
-
|
54
|
-
require_paths:
|
52
|
+
require_paths:
|
55
53
|
- lib
|
56
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
55
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
61
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version:
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
68
66
|
requirements: []
|
69
|
-
|
70
67
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.8.24
|
72
69
|
signing_key:
|
73
70
|
specification_version: 3
|
74
71
|
summary: Round-Robin schedule generator
|
75
72
|
test_files: []
|
76
|
-
|