tournament-system 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 282ede5d3142f58c0ec7c91288de41babcea71da
4
- data.tar.gz: 8be80356ef88d1d47d1db402790a37ca3832e4d3
3
+ metadata.gz: bf472f14954ad05551b972f6001a53dbfdbe9f0a
4
+ data.tar.gz: 41769df3e3b025ff4f4b0986e33585e845b37fcd
5
5
  SHA512:
6
- metadata.gz: c82ca2650a96ecd49d86ea129b9004dcf0af59d773136062dbc162db5ac1e77c7438b66fed6d1486d15bde29b1bbd061e005743dc52b2ba552653b6f29539a83
7
- data.tar.gz: bde5fb564d5c9a6863d751c65fe5e80d1d6952d4e06b3674ea10a2136e68b036b8eed4c50310c3aff2c3bdabef058f1ab16f45ee3ecc7e83a4705e3905af30b7
6
+ metadata.gz: b38f47ed72a2a1765f78b9d706702670cf4aa84457dc399c41fdce30f7e0f2a3dfc0b5ac8ea6a27fd95e93a7726c7629d9067b784f27458a09b37b1d624ba63c
7
+ data.tar.gz: 658ec1108455ad0902c288c2d510588a91d07be6dc8200c759784d79b2e74eef3ecda3864334b53af8b6f563ffe1d7ed48c234d4505ab8c56bc9a90fc5848c9c
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ DisplayCopNames: true
2
3
  TargetRubyVersion: 2.3
3
4
 
4
5
  # This is fine, really
@@ -14,6 +14,7 @@ module Tournament
14
14
  # :reek:UnusedParameters
15
15
  class Driver
16
16
  # rubocop:disable Lint/UnusedMethodArgument
17
+ # :nocov:
17
18
 
18
19
  # Get all matches
19
20
  def matches
@@ -50,6 +51,7 @@ module Tournament
50
51
  raise 'Not Implemented'
51
52
  end
52
53
 
54
+ # :nocov:
53
55
  # rubocop:enable Lint/UnusedMethodArgument
54
56
 
55
57
  # Get the losing team of a specific match
@@ -27,7 +27,8 @@ module Tournament
27
27
 
28
28
  # Merges small groups to the right (if possible) such that all groups
29
29
  # are larger than min_size.
30
- # rubocop:disable Metrics/MethodLength :reek:TooManyStatements
30
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
31
+ # :reek:TooManyStatements
31
32
  def merge_small_groups(groups, group_keys, min_size)
32
33
  new_keys = []
33
34
 
@@ -45,7 +46,14 @@ module Tournament
45
46
  # If there isn't, merge into the adjacent greater group
46
47
  else
47
48
  new_key = new_keys[-1]
48
- groups[new_key] += group
49
+
50
+ if new_key
51
+ groups[new_key] += group
52
+ else
53
+ # If there are no new keys just use the current key
54
+ new_keys << key
55
+ groups[key] = group
56
+ end
49
57
  end
50
58
  # Leave larger groups the way they are
51
59
  else
@@ -60,10 +68,10 @@ module Tournament
60
68
 
61
69
  # Get a set of already played matches. Matches are also sets
62
70
  def matches_set(driver)
63
- existing_matches = Set.new
71
+ existing_matches = Hash.new(0)
64
72
  driver.matches.each do |match|
65
- match_teams = driver.get_match_teams match
66
- existing_matches.add Set.new match_teams
73
+ match_teams = Set.new driver.get_match_teams match
74
+ existing_matches[match_teams] += 1
67
75
  end
68
76
  existing_matches
69
77
  end
@@ -75,7 +83,7 @@ module Tournament
75
83
 
76
84
  # Count the number of matches already played
77
85
  def count_existing_matches(matches, existing_matches)
78
- matches.count { |match| existing_matches.include?(Set.new(match)) }
86
+ matches.map { |match| existing_matches[Set.new(match)] }.reduce(:+)
79
87
  end
80
88
 
81
89
  # Finds the first permutation of teams that has a unique pairing.
@@ -101,10 +109,10 @@ module Tournament
101
109
  best_matches = matches
102
110
  end
103
111
  end
104
- # rubocop:enable Metrics/MethodLength
105
112
 
106
113
  best_matches
107
114
  end
115
+ # rubocop:enable Metrics/MethodLength
108
116
  end
109
117
  end
110
118
  end
@@ -1,3 +1,3 @@
1
1
  module Tournament
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
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.3
4
+ version: 0.1.4
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-04-28 00:00:00.000000000 Z
11
+ date: 2017-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.6.10
77
+ rubygems_version: 2.6.12
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Implements various tournament systems