tournament-system 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/tournament/driver.rb +5 -0
- data/lib/tournament/single_elimination.rb +11 -2
- data/lib/tournament/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 658d99ded4876bcc1c1ec78dbb38066d3dfae06a
|
4
|
+
data.tar.gz: 9a11ee1ed63be549fc09d2c6f40165a316188949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c355fa4f8edfeb89e524b613cf98e66ab551f3cfe773690a039d3d7996342eab2556e151a69fc775226d11a0819cbe7660685b985f1576fcf44998a6642113f8
|
7
|
+
data.tar.gz: d5abd06fb557db3adf12c9de53d19fbfa7097c198d0b637a6a4a7a37b1ea9826ec08cabe8a1944609c2b5a3db35e67c320f7a512f41aa4fce11a4e9fa8643f60
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/ozfortress/tournament-system)
|
4
4
|
[](https://coveralls.io/github/ozfortress/tournament-system?branch=master)
|
5
|
+
[](https://badge.fury.io/rb/tournament-system)
|
5
6
|
|
6
7
|
This is a simple gem that implements numerous tournament systems.
|
7
8
|
|
@@ -34,6 +35,10 @@ and the tournament systems:
|
|
34
35
|
|
35
36
|
```ruby
|
36
37
|
class Driver < Tournament::Driver
|
38
|
+
def matches
|
39
|
+
...
|
40
|
+
end
|
41
|
+
|
37
42
|
def matches_for_round(round)
|
38
43
|
...
|
39
44
|
end
|
data/lib/tournament/driver.rb
CHANGED
@@ -7,6 +7,11 @@ module Tournament
|
|
7
7
|
class Driver
|
8
8
|
# rubocop:disable Lint/UnusedMethodArgument
|
9
9
|
|
10
|
+
# Get all matches
|
11
|
+
def matches
|
12
|
+
raise 'Not Implemented'
|
13
|
+
end
|
14
|
+
|
10
15
|
# Get the matches played for a particular round
|
11
16
|
def matches_for_round(round)
|
12
17
|
raise 'Not Implemented'
|
@@ -23,13 +23,22 @@ module Tournament
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def seed_teams(teams, options)
|
26
|
-
|
27
|
-
teams = [nil] * padding + teams
|
26
|
+
teams = padd_teams teams
|
28
27
|
|
29
28
|
seeder = options[:seeder] || Seeder::SingleBracket
|
30
29
|
seeder.seed teams
|
31
30
|
end
|
32
31
|
|
32
|
+
def padd_teams(teams)
|
33
|
+
# Insert the padding after the top half of the total number of teams
|
34
|
+
total = 2**total_rounds_for_teams(teams)
|
35
|
+
half = total / 2
|
36
|
+
|
37
|
+
padding = total - teams.length
|
38
|
+
|
39
|
+
teams[0...half] + [nil] * padding + teams[half...teams.length]
|
40
|
+
end
|
41
|
+
|
33
42
|
def total_rounds_for_teams(teams)
|
34
43
|
team_count = teams.length
|
35
44
|
|
data/lib/tournament/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tournament-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Schaaf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|