playoffs 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +2 -0
- data/.editorconfig +8 -0
- data/.github/workflows/ci.yaml +29 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +34 -0
- data/.tool-versions +1 -0
- data/.vscode/settings.json +5 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +73 -0
- data/Gemfile +5 -0
- data/Guardfile +17 -0
- data/LICENSE +5 -0
- data/README.md +245 -0
- data/Rakefile +11 -0
- data/bin/_guard-core +27 -0
- data/bin/bundle +109 -0
- data/bin/bundle-audit +27 -0
- data/bin/bundler-audit +27 -0
- data/bin/coderay +27 -0
- data/bin/console +11 -0
- data/bin/guard +27 -0
- data/bin/htmldiff +27 -0
- data/bin/ldiff +27 -0
- data/bin/listen +27 -0
- data/bin/playoffs +27 -0
- data/bin/pry +27 -0
- data/bin/racc +27 -0
- data/bin/rake +27 -0
- data/bin/rspec +27 -0
- data/bin/rubocop +27 -0
- data/bin/ruby-parse +27 -0
- data/bin/ruby-rewrite +27 -0
- data/bin/spoom +27 -0
- data/bin/srb +27 -0
- data/bin/srb-rbi +27 -0
- data/bin/tapioca +27 -0
- data/bin/thor +27 -0
- data/bin/yard +27 -0
- data/bin/yardoc +27 -0
- data/bin/yri +27 -0
- data/exe/playoffs +7 -0
- data/lib/playoffs/basketball.rb +120 -0
- data/lib/playoffs/best_of.rb +38 -0
- data/lib/playoffs/cli.rb +201 -0
- data/lib/playoffs/contestant.rb +8 -0
- data/lib/playoffs/round.rb +42 -0
- data/lib/playoffs/series.rb +167 -0
- data/lib/playoffs/team.rb +7 -0
- data/lib/playoffs/tournament/bracketable.rb +93 -0
- data/lib/playoffs/tournament/roundable.rb +53 -0
- data/lib/playoffs/tournament.rb +61 -0
- data/lib/playoffs/version.rb +6 -0
- data/lib/playoffs.rb +26 -0
- data/playoffs.gemspec +49 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/ansi@1.5.0.rbi +688 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +585 -0
- data/sorbet/rbi/gems/bundler-audit@0.9.1.rbi +309 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +3426 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.1.rbi +1131 -0
- data/sorbet/rbi/gems/docile@1.4.0.rbi +377 -0
- data/sorbet/rbi/gems/erubi@1.12.0.rbi +145 -0
- data/sorbet/rbi/gems/ffi@1.16.3.rbi +9 -0
- data/sorbet/rbi/gems/formatador@1.1.0.rbi +9 -0
- data/sorbet/rbi/gems/guard-compat@1.2.1.rbi +67 -0
- data/sorbet/rbi/gems/guard-rspec@4.7.3.rbi +563 -0
- data/sorbet/rbi/gems/guard@2.18.1.rbi +9 -0
- data/sorbet/rbi/gems/json@2.7.2.rbi +1562 -0
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
- data/sorbet/rbi/gems/listen@3.9.0.rbi +9 -0
- data/sorbet/rbi/gems/lumberjack@1.2.10.rbi +9 -0
- data/sorbet/rbi/gems/method_source@1.1.0.rbi +304 -0
- data/sorbet/rbi/gems/nenv@0.3.0.rbi +9 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
- data/sorbet/rbi/gems/notiffany@0.1.3.rbi +9 -0
- data/sorbet/rbi/gems/parallel@1.24.0.rbi +280 -0
- data/sorbet/rbi/gems/parser@3.3.1.0.rbi +7238 -0
- data/sorbet/rbi/gems/primitive@1.0.0.rbi +58 -0
- data/sorbet/rbi/gems/prism@0.29.0.rbi +37987 -0
- data/sorbet/rbi/gems/pry@0.14.2.rbi +10069 -0
- data/sorbet/rbi/gems/racc@1.7.3.rbi +162 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
- data/sorbet/rbi/gems/rake@13.2.1.rbi +3028 -0
- data/sorbet/rbi/gems/rb-fsevent@0.11.2.rbi +9 -0
- data/sorbet/rbi/gems/rb-inotify@0.10.1.rbi +9 -0
- data/sorbet/rbi/gems/rbi@0.1.13.rbi +3078 -0
- data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +3772 -0
- data/sorbet/rbi/gems/rexml@3.2.8.rbi +4794 -0
- data/sorbet/rbi/gems/rspec-core@3.13.0.rbi +10874 -0
- data/sorbet/rbi/gems/rspec-expectations@3.13.0.rbi +8154 -0
- data/sorbet/rbi/gems/rspec-mocks@3.13.1.rbi +5341 -0
- data/sorbet/rbi/gems/rspec-support@3.13.1.rbi +1630 -0
- data/sorbet/rbi/gems/rspec@3.13.0.rbi +83 -0
- data/sorbet/rbi/gems/rubocop-ast@1.31.3.rbi +7159 -0
- data/sorbet/rbi/gems/rubocop-capybara@2.20.0.rbi +1208 -0
- data/sorbet/rbi/gems/rubocop-factory_bot@2.25.1.rbi +928 -0
- data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +329 -0
- data/sorbet/rbi/gems/rubocop-rspec@2.29.2.rbi +8247 -0
- data/sorbet/rbi/gems/rubocop-rspec_rails@2.28.3.rbi +911 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.8.3.rbi +1607 -0
- data/sorbet/rbi/gems/rubocop@1.63.5.rbi +57788 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
- data/sorbet/rbi/gems/shellany@0.0.1.rbi +9 -0
- data/sorbet/rbi/gems/simplecov-console@0.9.1.rbi +103 -0
- data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +217 -0
- data/sorbet/rbi/gems/simplecov@0.22.0.rbi +2149 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +9 -0
- data/sorbet/rbi/gems/sorbet-runtime-stub@0.2.0.rbi +8 -0
- data/sorbet/rbi/gems/spoom@1.3.2.rbi +4420 -0
- data/sorbet/rbi/gems/strscan@3.1.0.rbi +9 -0
- data/sorbet/rbi/gems/tapioca@0.14.2.rbi +3539 -0
- data/sorbet/rbi/gems/terminal-table@3.0.2.rbi +9 -0
- data/sorbet/rbi/gems/thor@1.3.1.rbi +4318 -0
- data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +66 -0
- data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +428 -0
- data/sorbet/rbi/gems/yard@0.9.36.rbi +18085 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +383 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d1a073c8554e9f8e237a7d55bab24bd078671fd84464bcedca0e1ef557851286
|
4
|
+
data.tar.gz: 07ecbd52187a90afb8fbc3e27abadac5ecb4c2ffdc75cd5ae686f742eb7921b9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 867f0f7137c5e84349f7a1ee530eb7662a93f2782a6c0752908a0d26e0bcf2045c1857231f5e4bed0bafeb34e308a9a98751962709083cf7c8b1c746c3e7723a
|
7
|
+
data.tar.gz: 1a2c1debbbfddbcccabd9ebc38a6f568c0c6a1f7220ebfa678c0992de78701f6f78ce6e91c6328d4b551b4c1b0744c5cf2cf784afd485a9af43c97ab55d05077
|
data/.bundle/config
ADDED
data/.editorconfig
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
verify:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ['3.2.1']
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby-version }}
|
21
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
22
|
+
- name: Lint
|
23
|
+
run: bin/rubocop
|
24
|
+
- name: Sorbet
|
25
|
+
run: bin/srb
|
26
|
+
- name: Test
|
27
|
+
run: bin/rspec spec --format documentation
|
28
|
+
- name: Dependency Audit
|
29
|
+
run: bin/bundler-audit check --update
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
- rubocop-sorbet
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
NewCops: enable
|
8
|
+
TargetRubyVersion: 3.2
|
9
|
+
Exclude:
|
10
|
+
- bin/*
|
11
|
+
- vendor/bundle/**/*
|
12
|
+
- '*.gemspec'
|
13
|
+
- tmp/*
|
14
|
+
|
15
|
+
Layout/LineLength:
|
16
|
+
Max: 125
|
17
|
+
|
18
|
+
Layout/MultilineMethodCallIndentation:
|
19
|
+
EnforcedStyle: indented
|
20
|
+
|
21
|
+
Metrics/BlockLength:
|
22
|
+
Max: 30
|
23
|
+
|
24
|
+
Metrics/ClassLength:
|
25
|
+
Max: 150
|
26
|
+
|
27
|
+
RSpec/ExampleLength:
|
28
|
+
Max: 25
|
29
|
+
|
30
|
+
Metrics/MethodLength:
|
31
|
+
Max: 30
|
32
|
+
|
33
|
+
RSpec/MultipleMemoizedHelpers:
|
34
|
+
Max: 10
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.2.1
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported. All complaints will be reviewed and investigated and will result in a response that
|
59
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
60
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
61
|
+
Further details of specific enforcement policies may be posted separately.
|
62
|
+
|
63
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
64
|
+
faith may face temporary or permanent repercussions as determined by other
|
65
|
+
members of the project's leadership.
|
66
|
+
|
67
|
+
## Attribution
|
68
|
+
|
69
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
70
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
71
|
+
|
72
|
+
[homepage]: http://contributor-covenant.org
|
73
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
guard :rspec, cmd: 'DISABLE_SIMPLECOV=true bundle exec rspec --format=documentation' do
|
5
|
+
require 'guard/rspec/dsl'
|
6
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
7
|
+
|
8
|
+
# RSpec files
|
9
|
+
rspec = dsl.rspec
|
10
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
11
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
12
|
+
watch(rspec.spec_files)
|
13
|
+
|
14
|
+
# Ruby files
|
15
|
+
ruby = dsl.ruby
|
16
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
17
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
2
|
+
|
3
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
4
|
+
|
5
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
# Playoffs
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/playoffs.svg)](https://badge.fury.io/rb/playoffs) [![CI](https://github.com/mattruggio/playoffs/actions/workflows/ci.yaml/badge.svg)](https://github.com/mattruggio/playoffs/actions/workflows/ci.yaml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
4
|
+
|
5
|
+
I was looking to create a turn-based sports game which, inevitably, would include a playoffs simulator. This library provides a few, easy-to-use APIs to create, simulate, and complete a team & series-based tournament with one clear winner.
|
6
|
+
|
7
|
+
### Installation
|
8
|
+
|
9
|
+
To install through Rubygems:
|
10
|
+
|
11
|
+
```zsh
|
12
|
+
gem install playoffs
|
13
|
+
```
|
14
|
+
|
15
|
+
You can also add this to your Gemfile using:
|
16
|
+
|
17
|
+
```zsh
|
18
|
+
bundle add playoffs
|
19
|
+
```
|
20
|
+
|
21
|
+
Copy the executables locally:
|
22
|
+
|
23
|
+
```zsh
|
24
|
+
bundle binstubs playoffs
|
25
|
+
```
|
26
|
+
|
27
|
+
### CLI Usage
|
28
|
+
|
29
|
+
This library comes with an executable which shows off the basics of consuming the underlying data structures. It is currently limited to supporting NBA-style playoffs (play-in games included). Let's say we are looking to model the 2024 NBA playoffs, we could run these commands to simulate step-by-step:
|
30
|
+
|
31
|
+
#### Create New Tournament
|
32
|
+
|
33
|
+
```zsh
|
34
|
+
bin/playoffs 2024.yaml new BOS,NYK,MIL,CLE,ORL,IND,PHI,MIA,CHI,ATL,OKC,DEN,MIN,LAC,DAL,PHX,LAL,NO,SAC,GS
|
35
|
+
```
|
36
|
+
|
37
|
+
Note(s):
|
38
|
+
|
39
|
+
* This will save a serialized tournament to `2024.yaml`
|
40
|
+
* The last argument is a comma-separated list of teams in ranked order per conference.
|
41
|
+
|
42
|
+
### View Bracket
|
43
|
+
|
44
|
+
```zsh
|
45
|
+
bin/playoffs 2024.yaml
|
46
|
+
```
|
47
|
+
|
48
|
+
This will output a tree-based text representation:
|
49
|
+
|
50
|
+
```zsh
|
51
|
+
TBD
|
52
|
+
└ BestOf::7::Series::TBD::0::TBD::0
|
53
|
+
├ BestOf::7::Series::TBD::0::TBD::0
|
54
|
+
│ ├ BestOf::7::Series::TBD::0::TBD::0
|
55
|
+
│ │ ├ BestOf::7::Series::BOS::0::TBD::0
|
56
|
+
│ │ │ └ BestOf::1::Series::TBD::0::TBD::0
|
57
|
+
│ │ │ ├ BestOf::1::Series::PHI::0::MIA::0::LoserAdvances
|
58
|
+
│ │ │ └ BestOf::1::Series::CHI::0::ATL::0
|
59
|
+
│ │ └ BestOf::7::Series::CLE::0::ORL::0
|
60
|
+
│ └ BestOf::7::Series::TBD::0::TBD::0
|
61
|
+
│ ├ BestOf::7::Series::MIL::0::IND::0
|
62
|
+
│ └ BestOf::7::Series::NYK::0::TBD::0
|
63
|
+
│ └ BestOf::1::Series::PHI::0::MIA::0::WinnerAdvances
|
64
|
+
└ BestOf::7::Series::TBD::0::TBD::0
|
65
|
+
├ BestOf::7::Series::TBD::0::TBD::0
|
66
|
+
│ ├ BestOf::7::Series::OKC::0::TBD::0
|
67
|
+
│ │ └ BestOf::1::Series::TBD::0::TBD::0
|
68
|
+
│ │ ├ BestOf::1::Series::LAL::0::NO::0::LoserAdvances
|
69
|
+
│ │ └ BestOf::1::Series::SAC::0::GS::0::LoserAdvances
|
70
|
+
│ └ BestOf::7::Series::LAC::0::DAL::0
|
71
|
+
└ BestOf::7::Series::TBD::0::TBD::0
|
72
|
+
├ BestOf::7::Series::MIN::0::PHX::0
|
73
|
+
└ BestOf::7::Series::DEN::0::TBD::0
|
74
|
+
└ BestOf::1::Series::LAL::0::NO::0::WinnerAdvances
|
75
|
+
```
|
76
|
+
|
77
|
+
### View Rounds
|
78
|
+
|
79
|
+
```zsh
|
80
|
+
bin/playoffs 2024.yaml rounds
|
81
|
+
```
|
82
|
+
|
83
|
+
This will output all series, grouped by round:
|
84
|
+
|
85
|
+
```zsh
|
86
|
+
BestOf::1::Series::PHI::0::MIA::0
|
87
|
+
BestOf::1::Series::CHI::0::ATL::0
|
88
|
+
BestOf::1::Series::LAL::0::NO::0
|
89
|
+
BestOf::1::Series::SAC::0::GS::0
|
90
|
+
|
91
|
+
BestOf::1::Series::TBD::0::TBD::0
|
92
|
+
BestOf::1::Series::PHI::0::MIA::0
|
93
|
+
BestOf::1::Series::TBD::0::TBD::0
|
94
|
+
BestOf::1::Series::LAL::0::NO::0
|
95
|
+
|
96
|
+
BestOf::7::Series::BOS::0::TBD::0
|
97
|
+
BestOf::7::Series::CLE::0::ORL::0
|
98
|
+
BestOf::7::Series::MIL::0::IND::0
|
99
|
+
BestOf::7::Series::NYK::0::TBD::0
|
100
|
+
BestOf::7::Series::OKC::0::TBD::0
|
101
|
+
BestOf::7::Series::LAC::0::DAL::0
|
102
|
+
BestOf::7::Series::MIN::0::PHX::0
|
103
|
+
BestOf::7::Series::DEN::0::TBD::0
|
104
|
+
|
105
|
+
BestOf::7::Series::TBD::0::TBD::0
|
106
|
+
BestOf::7::Series::TBD::0::TBD::0
|
107
|
+
BestOf::7::Series::TBD::0::TBD::0
|
108
|
+
BestOf::7::Series::TBD::0::TBD::0
|
109
|
+
|
110
|
+
BestOf::7::Series::TBD::0::TBD::0
|
111
|
+
BestOf::7::Series::TBD::0::TBD::0
|
112
|
+
|
113
|
+
BestOf::7::Series::TBD::0::TBD::0
|
114
|
+
```
|
115
|
+
|
116
|
+
#### View Up Next
|
117
|
+
|
118
|
+
```zsh
|
119
|
+
bin/playoffs 2024.yaml up
|
120
|
+
```
|
121
|
+
|
122
|
+
This will output the current round number and series (nothing if the tournament is over):
|
123
|
+
|
124
|
+
```zsh
|
125
|
+
1
|
126
|
+
BestOf::1::Series::PHI::0::MIA::0
|
127
|
+
```
|
128
|
+
|
129
|
+
#### Log a Win
|
130
|
+
|
131
|
+
Once you know which series is currently up, use this command to pick a winner:
|
132
|
+
|
133
|
+
```zsh
|
134
|
+
bin/playoffs 2024.yaml win PHI
|
135
|
+
```
|
136
|
+
|
137
|
+
This will output the current series after the win:
|
138
|
+
|
139
|
+
```zsh
|
140
|
+
BestOf::1::Series::PHI::1::MIA::0::Done
|
141
|
+
```
|
142
|
+
|
143
|
+
#### Simulate
|
144
|
+
|
145
|
+
The CLI example executable comes with a randomized simulator. This is where this library stops and the application should start: the consumer is responsible to actually deciding winners while this library is only focused on providing the state machine. Run this command to simulate the rest of the games and series:
|
146
|
+
|
147
|
+
```zsh
|
148
|
+
bin/playoffs 2024.yaml sim
|
149
|
+
```
|
150
|
+
|
151
|
+
This will output the number of games simulated and the winner:
|
152
|
+
|
153
|
+
```zsh
|
154
|
+
97
|
155
|
+
DAL
|
156
|
+
```
|
157
|
+
|
158
|
+
#### View Winner
|
159
|
+
|
160
|
+
```zsh
|
161
|
+
bin/playoffs 2024.yaml winner
|
162
|
+
```
|
163
|
+
|
164
|
+
Will output the winner (nothing if the tournament is not over):
|
165
|
+
|
166
|
+
```zsh
|
167
|
+
DAL
|
168
|
+
```
|
169
|
+
|
170
|
+
### Ruby API Usage
|
171
|
+
|
172
|
+
While the CLI executable exemplifies building a consumer app using the data structures provided here, the real power is extending yourself to fit your needs, specifically:
|
173
|
+
|
174
|
+
1. Subclassing `Playoffs::Team` to customize per your domain-specific needs
|
175
|
+
2. Constructing your own tournament using the main `Playoffs::Series` data structure. View `Playoffs::Basketball#tournament_for` to see how an NBA tournament is constructed.
|
176
|
+
3. Interact with the tournament state machine directly, such as:
|
177
|
+
|
178
|
+
* `Playoffs::Tournament#up_next`: Get the current series which needs a winner.
|
179
|
+
* `Playoffs::Series#win`: Log a winner for the current series.
|
180
|
+
* `Playoffs::Tournament#winner`: Get the winning team once there is no current series (series is over).
|
181
|
+
|
182
|
+
## Contributing
|
183
|
+
|
184
|
+
### Development Environment Configuration
|
185
|
+
|
186
|
+
Basic steps to take to get this repository compiling:
|
187
|
+
|
188
|
+
1. Install [Ruby](https://www.ruby-lang.org/en/documentation/installation/) (check playoffs.gemspec for versions supported)
|
189
|
+
2. Install bundler (gem install bundler)
|
190
|
+
3. Clone the repository (git clone git@github.com:mattruggio/playoffs.git)
|
191
|
+
4. Navigate to the root folder (cd playoffs)
|
192
|
+
5. Install dependencies (bundle)
|
193
|
+
|
194
|
+
### Running Tests
|
195
|
+
|
196
|
+
To execute the test suite run:
|
197
|
+
|
198
|
+
```zsh
|
199
|
+
bin/rspec spec --format documentation
|
200
|
+
```
|
201
|
+
|
202
|
+
Alternatively, you can have Guard watch for changes:
|
203
|
+
|
204
|
+
```zsh
|
205
|
+
bin/guard
|
206
|
+
```
|
207
|
+
|
208
|
+
Also, do not forget to run Rubocop:
|
209
|
+
|
210
|
+
```zsh
|
211
|
+
bin/rubocop
|
212
|
+
```
|
213
|
+
|
214
|
+
And auditing the dependencies:
|
215
|
+
|
216
|
+
```zsh
|
217
|
+
bin/bundler-audit check --update
|
218
|
+
```
|
219
|
+
|
220
|
+
And Sorbet:
|
221
|
+
|
222
|
+
```zsh
|
223
|
+
bin/srb
|
224
|
+
```
|
225
|
+
|
226
|
+
### Publishing
|
227
|
+
|
228
|
+
Note: ensure you have proper authorization before trying to publish new versions.
|
229
|
+
|
230
|
+
After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
|
231
|
+
|
232
|
+
1. Merge Pull Request into main
|
233
|
+
2. Update `version.rb` using [semantic versioning](https://semver.org/)
|
234
|
+
3. Install dependencies: `bundle`
|
235
|
+
4. Update `CHANGELOG.md` with release notes
|
236
|
+
5. Commit & push main to remote and ensure CI builds main successfully
|
237
|
+
6. Run `bin/rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
238
|
+
|
239
|
+
## Code of Conduct
|
240
|
+
|
241
|
+
Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mattruggio/playoffs/blob/main/CODE_OF_CONDUCT.md).
|
242
|
+
|
243
|
+
## License
|
244
|
+
|
245
|
+
This project is MIT Licensed.
|
data/Rakefile
ADDED
data/bin/_guard-core
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application '_guard-core' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("guard", "_guard-core")
|
data/bin/bundle
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../Gemfile", __dir__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_requirement
|
64
|
+
@bundler_requirement ||=
|
65
|
+
env_var_version ||
|
66
|
+
cli_arg_version ||
|
67
|
+
bundler_requirement_for(lockfile_version)
|
68
|
+
end
|
69
|
+
|
70
|
+
def bundler_requirement_for(version)
|
71
|
+
return "#{Gem::Requirement.default}.a" unless version
|
72
|
+
|
73
|
+
bundler_gem_version = Gem::Version.new(version)
|
74
|
+
|
75
|
+
bundler_gem_version.approximate_recommendation
|
76
|
+
end
|
77
|
+
|
78
|
+
def load_bundler!
|
79
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
80
|
+
|
81
|
+
activate_bundler
|
82
|
+
end
|
83
|
+
|
84
|
+
def activate_bundler
|
85
|
+
gem_error = activation_error_handling do
|
86
|
+
gem "bundler", bundler_requirement
|
87
|
+
end
|
88
|
+
return if gem_error.nil?
|
89
|
+
require_error = activation_error_handling do
|
90
|
+
require "bundler/version"
|
91
|
+
end
|
92
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
93
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
94
|
+
exit 42
|
95
|
+
end
|
96
|
+
|
97
|
+
def activation_error_handling
|
98
|
+
yield
|
99
|
+
nil
|
100
|
+
rescue StandardError, LoadError => e
|
101
|
+
e
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
m.load_bundler!
|
106
|
+
|
107
|
+
if m.invoked_as_script?
|
108
|
+
load Gem.bin_path("bundler", "bundle")
|
109
|
+
end
|
data/bin/bundle-audit
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle-audit' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("bundler-audit", "bundle-audit")
|
data/bin/bundler-audit
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundler-audit' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("bundler-audit", "bundler-audit")
|