https://github.com/danielgatis/bowling-rb
https://github.com/danielgatis/bowling-rb
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/danielgatis/bowling-rb
- Owner: danielgatis
- Created: 2023-02-28T03:55:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T00:45:17.000Z (almost 2 years ago)
- Last Synced: 2025-02-08T20:47:33.080Z (over 1 year ago)
- Language: Ruby
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bowling
This is a gem for calculating bowling scores.
## Usage
Go to the root of the project and run:
```
cat spec/fixtures/positive/scores.txt | ./bin/score_board
```
And you will see this output:
```
Frame 1 2 3 4 5 6 7 8 9 10
Jeff
Pinfalls X 7 / 9 0 X 0 8 8 / F 6 X X X 8 1
Score 20 39 48 66 74 84 90 120 148 167
John
Pinfalls 3 / 6 3 X 8 1 X X 9 0 7 / 4 4 X 9 0
Score 16 25 44 53 82 101 110 124 132 151
```
## Errors
There are 3 types of errors:
- SyntaxError: When there are some unknown character on the input file.
- ParserError: When all characters is ok but there is a semantic error.
- RuntimeError: When all is ok but a runtime errors happens on evaluation time.
### SyntaxError
```
cat spec/fixtures/negative/negative.txt | ./bin/score_board
```
You can figure out the problem looking on the error message: `Unexpected char "-" at 2:6 (Bowling::Parser::Tokenizer::SyntaxError)`.
### ParserError
```
cat spec/fixtures/negative/invalid-score.txt | ./bin/score_board
```
You can figure out the problem looking on the error message: `Expected number or fault, got identifier "lorem" at 2:6 (Bowling::Parser::Parser::ParserError)`.
### RuntimeError
```
cat spec/fixtures/negative/extra-score.txt | ./bin/score_board
```
You can figure out the problem looking on the error message: `This game is already finished (Bowling::Game::BowlingError)`.
## Running tests
Go to the root of the project and run:
```bash
$ rspec
```