brackets 0.0.1 → 0.0.2

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: 6c83d7fafb937ee94ed9ae54cefa98cb2ed830c4
4
- data.tar.gz: 990b94f69f4e57cb5ecb43804fefbe7cb1565e1c
3
+ metadata.gz: 3cdb35f83c0d29c3790eafbef261816e62bf6176
4
+ data.tar.gz: 223e2209efcd6aa22decfd876843cdb87c49c9f9
5
5
  SHA512:
6
- metadata.gz: 8187f943dbc8be7e3c96501966e2f506637fa5f1814308224018ea864409758454589cd98d14621a766d2eba4bbca7970c6cc58bb40b5a84873d4a49703b8146
7
- data.tar.gz: 53213ef11e8cc68488f95be647d9bd373b6b74e9c1985cbbc93e4b544966a5ebed66ac2a104cd965a99d98afdc41da5e53247adc36a07a3bf894750fbb0063f7
6
+ metadata.gz: 303155079213b985b127484c1b88b558d7eaa163e4e600d2a85b6f5aae9cba82a287b1ccd1a662eb76996af51a988cff3f3a2844d4109c97e940fb79520ff8a5
7
+ data.tar.gz: 3f21e9e2306b0cd10b90f8ba1a3c20fbb5cabbe4ce462c11b539b6e58a0bfaa016df5bd0d3e2eece39e1e5480b238121503ff89dd12c9ac7f31f84c1f0fb2472
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brackets (0.0.0)
4
+ brackets (0.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'brackets'
5
- s.version = '0.0.1'
5
+ s.version = '0.0.2'
6
6
  s.date = '2015-11-08'
7
7
  s.summary = "A gem to generate tournament brackets"
8
8
  s.description = "A gem to generate tournament brackets"
@@ -12,7 +12,7 @@ module Brackets
12
12
  @red.nil? && @blue.nil?
13
13
  end
14
14
 
15
- def to_s
15
+ def name
16
16
  "-"
17
17
  end
18
18
  end
@@ -5,6 +5,8 @@ module Brackets
5
5
  end
6
6
 
7
7
  def generate(competitors)
8
+ return [] if competitors.to_a.empty?
9
+
8
10
  generate_rounds(generate_first_round(competitors))
9
11
  end
10
12
 
@@ -27,7 +29,7 @@ module Brackets
27
29
  end
28
30
 
29
31
  def generate_rounds(round, deph = 2)
30
- if round.size == 1
32
+ if round.size == 1 || round.size == 3
31
33
  round
32
34
  else
33
35
  matches = round.select{|m| m.deph == deph - 1 }.each_slice(2).map do |slice|
@@ -15,10 +15,27 @@ module Brackets
15
15
 
16
16
  let(:competitors) { [anakin, obiwan, maul, mace] }
17
17
 
18
+
18
19
  it "numbers the matches sequentially" do
19
20
  expect(subject.map(&:number)).to eq([1, 2, 3])
20
21
  end
21
22
 
23
+ describe "when receiving an empty array" do
24
+ let(:competitors) { [] }
25
+
26
+ it "returns an empty array" do
27
+ expect(subject).to eq([])
28
+ end
29
+ end
30
+
31
+ describe "when receiving nil" do
32
+ let(:competitors) { nil }
33
+
34
+ it "returns an empty array" do
35
+ expect(subject).to eq([])
36
+ end
37
+ end
38
+
22
39
  context "with one participant" do
23
40
  let(:competitors) { [anakin] }
24
41
 
@@ -41,6 +58,14 @@ module Brackets
41
58
  end
42
59
  end
43
60
 
61
+ context "with three competitors" do
62
+ let(:competitors) { [anakin, obiwan, yoda] }
63
+
64
+ it "generates one match with no winner", focus: true do
65
+ expect(subject.length).to eq(3)
66
+ end
67
+ end
68
+
44
69
  context "when number of competitors is a power of two" do
45
70
  let(:competitors) { [yoda, mace, anakin, obiwan] }
46
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brackets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitor HP Bittencourt