card_dealer 0.2.0 → 0.3.0
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/.rubocop.yml +2 -2
- data/CHANGELOG.md +40 -8
- data/CODE_OF_CONDUCT.md +91 -0
- data/CONTRIBUTING.md +32 -0
- data/Gemfile +5 -6
- data/Gemfile.lock +82 -82
- data/README.md +68 -66
- data/SECURITY.md +14 -0
- data/card_dealer.gemspec +44 -0
- data/lib/card_dealer/version.rb +1 -1
- data/lib/card_dealer.rb +0 -2
- data/sig/card_dealer/card.rbs +10 -0
- metadata +14 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c3f3a33b1bc150361102599843b3cf9e7e1eb3d2b799b4116411f3445a00cf2
|
|
4
|
+
data.tar.gz: 6f32d0a5b10e0703424304aba1e8e3172a50b56066c49505c08f1752ca0c5bbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07f8695bf89b50776b4dbd412ed774679ae1d7cd9dccf78581148bd200b7afd30e97fdbe8eb392b640569faf3945dc738a67fd34d8501c6028216fb1d942a73f
|
|
7
|
+
data.tar.gz: b6936af01081753ab4f0e46174ddab834c2c84091923eb73794660fa2f6ea30c04c495a72121f8ffcc2ac998fb6754927b305d50bd4eabfaf3ae815d988a4c47
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
The public API covered by Semantic Versioning is the public methods of
|
|
9
|
+
`CardDealer::Card`, `CardDealer::Deck`, `CardDealer::BuildDeck`, and
|
|
10
|
+
`CardDealer::BinaryDeck`, the binary format `BinaryDeck` produces, and the
|
|
11
|
+
minimum Ruby version. Private methods and the RBS signatures under `sig/` are
|
|
12
|
+
outside it. While the version is below 1.0.0, an incompatible change bumps
|
|
13
|
+
MINOR and every other change bumps PATCH. A public item is deprecated with a
|
|
14
|
+
runtime warning naming its replacement for at least one release before it is
|
|
15
|
+
removed.
|
|
16
|
+
|
|
1
17
|
## [Unreleased]
|
|
2
18
|
|
|
3
|
-
## [0.
|
|
19
|
+
## [0.3.0] - 2026-09-07
|
|
4
20
|
|
|
5
|
-
###
|
|
21
|
+
### Changed
|
|
6
22
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
23
|
+
- **Breaking:** Ruby 3.3 or newer is required. Ruby 3.1 and 3.2 reached end of life and are no longer tested.
|
|
24
|
+
- Development dependencies updated to their current releases (RuboCop 1.90, RSpec 3.13, Steep 2.1, rbs 4.2)
|
|
25
|
+
- CI runs on Ruby 3.3, 3.4, and 4.0
|
|
26
|
+
|
|
27
|
+
## [0.2.0] - 2023-04-01
|
|
10
28
|
|
|
11
29
|
### Added
|
|
12
30
|
|
|
@@ -22,11 +40,20 @@
|
|
|
22
40
|
- `Deck#from_binary` helper method to convert the binary string to a deck
|
|
23
41
|
- `Deck#==` method to compare decks for equality
|
|
24
42
|
- Lots of documentation
|
|
25
|
-
- [Steep](https://github.com/soutaro/steep) gem to check
|
|
43
|
+
- [Steep](https://github.com/soutaro/steep) gem to check type correctness
|
|
26
44
|
|
|
27
45
|
### Changed
|
|
28
46
|
|
|
29
|
-
-
|
|
47
|
+
- **Breaking:** Deck building is extracted from the `Deck` class to the `BuildDeck` class.
|
|
48
|
+
`Deck#new` now takes an array of cards instead of a hash of options.
|
|
49
|
+
Call `BuildDeck.standard52`, `BuildDeck.standard36`, or `BuildDeck.custom` to build a deck.
|
|
50
|
+
- It's now possible to initialize a card with a string, e.g. `Card.new('9c')`
|
|
51
|
+
|
|
52
|
+
### Removed
|
|
53
|
+
|
|
54
|
+
- **Breaking:** `Deck#reset`. It was removed without a deprecation notice in 0.1.0,
|
|
55
|
+
so no release warned before the removal. Build a new deck with `BuildDeck` where
|
|
56
|
+
`reset` was called.
|
|
30
57
|
|
|
31
58
|
### Fixed
|
|
32
59
|
|
|
@@ -40,6 +67,11 @@ Initial release!
|
|
|
40
67
|
|
|
41
68
|
- `Card` class
|
|
42
69
|
- `Deck` class
|
|
43
|
-
- Ability to create a decks of various
|
|
70
|
+
- Ability to create a decks of various sizes, ranks, and suits
|
|
44
71
|
- Ability to shuffle a deck
|
|
45
72
|
- Ability to reset a deck
|
|
73
|
+
|
|
74
|
+
[unreleased]: https://github.com/svyatov/card_dealer/compare/v0.3.0...HEAD
|
|
75
|
+
[0.3.0]: https://github.com/svyatov/card_dealer/compare/v0.2.0...v0.3.0
|
|
76
|
+
[0.2.0]: https://github.com/svyatov/card_dealer/compare/v0.1.0...v0.2.0
|
|
77
|
+
[0.1.0]: https://github.com/svyatov/card_dealer/releases/tag/v0.1.0
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
# Contributor Covenant 3.0 Code of Conduct
|
|
3
|
+
|
|
4
|
+
## Our Pledge
|
|
5
|
+
|
|
6
|
+
We pledge to make our community welcoming, safe, and equitable for all.
|
|
7
|
+
|
|
8
|
+
We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Encouraged Behaviors
|
|
12
|
+
|
|
13
|
+
While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language.
|
|
14
|
+
|
|
15
|
+
With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including:
|
|
16
|
+
|
|
17
|
+
1. Respecting the **purpose of our community**, our activities, and our ways of gathering.
|
|
18
|
+
2. Engaging **kindly and honestly** with others.
|
|
19
|
+
3. Respecting **different viewpoints** and experiences.
|
|
20
|
+
4. **Taking responsibility** for our actions and contributions.
|
|
21
|
+
5. Gracefully giving and accepting **constructive feedback**.
|
|
22
|
+
6. Committing to **repairing harm** when it occurs.
|
|
23
|
+
7. Behaving in other ways that promote and sustain the **well-being of our community**.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Restricted Behaviors
|
|
27
|
+
|
|
28
|
+
We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct.
|
|
29
|
+
|
|
30
|
+
1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop.
|
|
31
|
+
2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people.
|
|
32
|
+
3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits.
|
|
33
|
+
4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community.
|
|
34
|
+
5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission.
|
|
35
|
+
6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group.
|
|
36
|
+
7. Behaving in other ways that **threaten the well-being** of our community.
|
|
37
|
+
|
|
38
|
+
### Other Restrictions
|
|
39
|
+
|
|
40
|
+
1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions.
|
|
41
|
+
2. **Failing to credit sources.** Not properly crediting the sources of content you contribute.
|
|
42
|
+
3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community.
|
|
43
|
+
4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Reporting an Issue
|
|
47
|
+
|
|
48
|
+
Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm.
|
|
49
|
+
|
|
50
|
+
When an incident does occur, it is important to report it promptly. To report a possible violation, email Leonid Svyatov at leonid@svyatov.com.
|
|
51
|
+
|
|
52
|
+
Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Addressing and Repairing Harm
|
|
56
|
+
|
|
57
|
+
If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped.
|
|
58
|
+
|
|
59
|
+
1) Warning
|
|
60
|
+
1) Event: A violation involving a single incident or series of incidents.
|
|
61
|
+
2) Consequence: A private, written warning from the Community Moderators.
|
|
62
|
+
3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations.
|
|
63
|
+
2) Temporarily Limited Activities
|
|
64
|
+
1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation.
|
|
65
|
+
2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members.
|
|
66
|
+
3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over.
|
|
67
|
+
3) Temporary Suspension
|
|
68
|
+
1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation.
|
|
69
|
+
2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions.
|
|
70
|
+
3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted.
|
|
71
|
+
4) Permanent Ban
|
|
72
|
+
1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member.
|
|
73
|
+
2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior.
|
|
74
|
+
3) Repair: There is no possible repair in cases of this severity.
|
|
75
|
+
|
|
76
|
+
This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Scope
|
|
80
|
+
|
|
81
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## Attribution
|
|
85
|
+
|
|
86
|
+
This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/).
|
|
87
|
+
|
|
88
|
+
Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/)
|
|
89
|
+
|
|
90
|
+
For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion).
|
|
91
|
+
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Bug reports and pull requests are welcome at https://github.com/svyatov/card_dealer/issues.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
Install Ruby 3.3 or newer, then run:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bin/setup
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Tests and checks
|
|
14
|
+
|
|
15
|
+
`bundle exec rake` runs what CI runs: Steep, RuboCop, and RSpec. `bundle exec rake spec` runs the tests alone.
|
|
16
|
+
|
|
17
|
+
## Pull requests
|
|
18
|
+
|
|
19
|
+
1. Fork the repository and create a branch from `main`.
|
|
20
|
+
2. Make the change. A change that adds or alters behavior arrives with a test in `spec/`.
|
|
21
|
+
3. Run `bundle exec rake` and fix what it reports.
|
|
22
|
+
4. Open a pull request against `main`.
|
|
23
|
+
|
|
24
|
+
CI runs `bundle exec rake` on Ruby 3.3, 3.4, and 4.0. All three must pass before merge. Pull requests are squash merged, and their titles follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
25
|
+
|
|
26
|
+
## What an acceptable change satisfies
|
|
27
|
+
|
|
28
|
+
`bundle exec rake` passes: RuboCop with the rules in [.rubocop.yml](.rubocop.yml), Steep against the signatures in [sig/](sig/), and the suite in [spec/](spec/).
|
|
29
|
+
|
|
30
|
+
## Governance
|
|
31
|
+
|
|
32
|
+
Leonid Svyatov ([@svyatov](https://github.com/svyatov)) is the only maintainer. He reviews, merges, and releases. No succession is arranged: if he stops, the project stops unless someone forks it.
|
data/Gemfile
CHANGED
|
@@ -5,14 +5,13 @@ source "https://rubygems.org"
|
|
|
5
5
|
# Specify your gem's dependencies in card_dealer.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem "rake", "~> 13.
|
|
8
|
+
gem "rake", "~> 13.4"
|
|
9
9
|
|
|
10
|
-
gem "rspec", "~> 3.
|
|
10
|
+
gem "rspec", "~> 3.13"
|
|
11
11
|
gem "simplecov", require: false
|
|
12
|
-
gem "simplecov_json_formatter", require: false
|
|
13
12
|
|
|
14
|
-
gem "rubocop", "~> 1.
|
|
15
|
-
gem "rubocop-rake", "~> 0.
|
|
16
|
-
gem "rubocop-rspec", "~>
|
|
13
|
+
gem "rubocop", "~> 1.90"
|
|
14
|
+
gem "rubocop-rake", "~> 0.7"
|
|
15
|
+
gem "rubocop-rspec", "~> 3.10"
|
|
17
16
|
|
|
18
17
|
gem "steep", require: false
|
data/Gemfile.lock
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
card_dealer (0.
|
|
4
|
+
card_dealer (0.3.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
i18n (1.12.0)
|
|
22
|
-
concurrent-ruby (~> 1.0)
|
|
23
|
-
json (2.6.3)
|
|
24
|
-
language_server-protocol (3.17.0.3)
|
|
25
|
-
listen (3.8.0)
|
|
9
|
+
ast (2.4.3)
|
|
10
|
+
concurrent-ruby (1.3.8)
|
|
11
|
+
csv (3.3.6)
|
|
12
|
+
diff-lcs (1.6.2)
|
|
13
|
+
ffi (1.17.4-arm64-darwin)
|
|
14
|
+
ffi (1.17.4-x86_64-linux-gnu)
|
|
15
|
+
fileutils (1.8.0)
|
|
16
|
+
json (2.21.2)
|
|
17
|
+
language_server-protocol (3.17.0.6)
|
|
18
|
+
lint_roller (1.1.0)
|
|
19
|
+
listen (3.10.0)
|
|
20
|
+
logger
|
|
26
21
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
27
22
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
28
|
-
logger (1.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
parser (3.2.1.1)
|
|
23
|
+
logger (1.7.0)
|
|
24
|
+
parallel (2.1.0)
|
|
25
|
+
parser (3.3.12.0)
|
|
32
26
|
ast (~> 2.4.1)
|
|
27
|
+
racc
|
|
28
|
+
prism (1.9.0)
|
|
29
|
+
racc (1.8.1)
|
|
33
30
|
rainbow (3.1.1)
|
|
34
|
-
rake (13.
|
|
31
|
+
rake (13.4.2)
|
|
35
32
|
rb-fsevent (0.11.2)
|
|
36
|
-
rb-inotify (0.
|
|
33
|
+
rb-inotify (0.11.1)
|
|
37
34
|
ffi (~> 1.0)
|
|
38
|
-
rbs (2.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
rspec-
|
|
45
|
-
|
|
46
|
-
rspec-
|
|
47
|
-
rspec-
|
|
35
|
+
rbs (4.2.0)
|
|
36
|
+
logger
|
|
37
|
+
prism (>= 1.6.0)
|
|
38
|
+
tsort
|
|
39
|
+
regexp_parser (2.12.0)
|
|
40
|
+
rspec (3.13.2)
|
|
41
|
+
rspec-core (~> 3.13.0)
|
|
42
|
+
rspec-expectations (~> 3.13.0)
|
|
43
|
+
rspec-mocks (~> 3.13.0)
|
|
44
|
+
rspec-core (3.13.6)
|
|
45
|
+
rspec-support (~> 3.13.0)
|
|
46
|
+
rspec-expectations (3.13.5)
|
|
48
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
49
|
-
rspec-support (~> 3.
|
|
50
|
-
rspec-mocks (3.
|
|
48
|
+
rspec-support (~> 3.13.0)
|
|
49
|
+
rspec-mocks (3.13.8)
|
|
51
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
52
|
-
rspec-support (~> 3.
|
|
53
|
-
rspec-support (3.
|
|
54
|
-
rubocop (1.
|
|
55
|
-
json (
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
rspec-support (~> 3.13.0)
|
|
52
|
+
rspec-support (3.13.7)
|
|
53
|
+
rubocop (1.90.0)
|
|
54
|
+
json (>= 2.3)
|
|
55
|
+
language_server-protocol (~> 3.17.0.2)
|
|
56
|
+
lint_roller (~> 1.1.0)
|
|
57
|
+
parallel (>= 1.10)
|
|
58
|
+
parser (>= 3.3.0.2)
|
|
58
59
|
rainbow (>= 2.2.2, < 4.0)
|
|
59
|
-
regexp_parser (>=
|
|
60
|
-
|
|
61
|
-
rubocop-ast (>= 1.26.0, < 2.0)
|
|
60
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
61
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
62
62
|
ruby-progressbar (~> 1.7)
|
|
63
|
-
unicode-display_width (>= 2.4.0, <
|
|
64
|
-
rubocop-ast (1.
|
|
65
|
-
parser (>= 3.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
rubocop (
|
|
70
|
-
rubocop-rspec (
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
64
|
+
rubocop-ast (1.50.0)
|
|
65
|
+
parser (>= 3.3.7.2)
|
|
66
|
+
prism (~> 1.7)
|
|
67
|
+
rubocop-rake (0.7.1)
|
|
68
|
+
lint_roller (~> 1.1)
|
|
69
|
+
rubocop (>= 1.72.1)
|
|
70
|
+
rubocop-rspec (3.10.2)
|
|
71
|
+
lint_roller (~> 1.1)
|
|
72
|
+
regexp_parser (>= 2.0)
|
|
73
|
+
rubocop (~> 1.86, >= 1.86.2)
|
|
73
74
|
ruby-progressbar (1.13.0)
|
|
74
|
-
securerandom (0.
|
|
75
|
-
simplecov (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
simplecov_json_formatter (~> 0.1)
|
|
79
|
-
simplecov-html (0.12.3)
|
|
80
|
-
simplecov_json_formatter (0.1.4)
|
|
81
|
-
steep (1.3.2)
|
|
82
|
-
activesupport (>= 5.1)
|
|
75
|
+
securerandom (0.4.1)
|
|
76
|
+
simplecov (1.1.1)
|
|
77
|
+
steep (2.1.0)
|
|
78
|
+
concurrent-ruby (>= 1.1.10)
|
|
83
79
|
csv (>= 3.0.9)
|
|
84
80
|
fileutils (>= 1.1.0)
|
|
85
81
|
json (>= 2.1.0)
|
|
86
|
-
language_server-protocol (>= 3.
|
|
82
|
+
language_server-protocol (>= 3.17.0.4, < 4.0)
|
|
87
83
|
listen (~> 3.0)
|
|
88
84
|
logger (>= 1.3.0)
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
parser (>= 3.2)
|
|
86
|
+
prism (>= 0.25.0)
|
|
91
87
|
rainbow (>= 2.2.2, < 4.0)
|
|
92
|
-
rbs (~> 2
|
|
88
|
+
rbs (~> 4.2)
|
|
93
89
|
securerandom (>= 0.1)
|
|
94
90
|
strscan (>= 1.0.0)
|
|
95
|
-
terminal-table (>= 2, <
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
unicode-display_width (2.
|
|
91
|
+
terminal-table (>= 2, < 5)
|
|
92
|
+
uri (>= 0.12.0)
|
|
93
|
+
strscan (3.1.8)
|
|
94
|
+
terminal-table (4.0.0)
|
|
95
|
+
unicode-display_width (>= 1.1.1, < 4)
|
|
96
|
+
tsort (0.2.0)
|
|
97
|
+
unicode-display_width (3.2.0)
|
|
98
|
+
unicode-emoji (~> 4.1)
|
|
99
|
+
unicode-emoji (4.2.0)
|
|
100
|
+
uri (1.1.1)
|
|
102
101
|
|
|
103
102
|
PLATFORMS
|
|
104
103
|
arm64-darwin-22
|
|
104
|
+
arm64-darwin-23
|
|
105
|
+
arm64-darwin-24
|
|
105
106
|
x86_64-linux
|
|
106
107
|
|
|
107
108
|
DEPENDENCIES
|
|
108
109
|
card_dealer!
|
|
109
|
-
rake (~> 13.
|
|
110
|
-
rspec (~> 3.
|
|
111
|
-
rubocop (~> 1.
|
|
112
|
-
rubocop-rake (~> 0.
|
|
113
|
-
rubocop-rspec (~>
|
|
110
|
+
rake (~> 13.4)
|
|
111
|
+
rspec (~> 3.13)
|
|
112
|
+
rubocop (~> 1.90)
|
|
113
|
+
rubocop-rake (~> 0.7)
|
|
114
|
+
rubocop-rspec (~> 3.10)
|
|
114
115
|
simplecov
|
|
115
|
-
simplecov_json_formatter
|
|
116
116
|
steep
|
|
117
117
|
|
|
118
118
|
BUNDLED WITH
|
|
119
|
-
|
|
119
|
+
4.0.17
|
data/README.md
CHANGED
|
@@ -1,49 +1,58 @@
|
|
|
1
1
|
# CardDealer
|
|
2
|
-
[](https://badge.fury.io/rb/card_dealer)
|
|
3
|
-
[](https://codeclimate.com/github/svyatov/card_dealer/maintainability)
|
|
4
|
-
[](https://codeclimate.com/github/svyatov/card_dealer/test_coverage)
|
|
5
|
-
[](LICENSE.txt)
|
|
6
2
|
|
|
7
|
-
CardDealer
|
|
8
|
-
with ease. Whether you're building a poker night app or a virtual bridge club,
|
|
9
|
-
CardDealer has got you covered. Enjoy customizable deck options, smooth
|
|
10
|
-
shuffling algorithms, and simple yet powerful deck manipulation tools that bring
|
|
11
|
-
the classic card game experience to life.
|
|
3
|
+
CardDealer builds, shuffles, and deals decks of playing cards for Ruby card game applications.
|
|
12
4
|
|
|
13
|
-
|
|
5
|
+
[](https://rubygems.org/gems/card_dealer)
|
|
6
|
+
[](https://github.com/svyatov/card_dealer/actions/workflows/main.yml)
|
|
14
7
|
|
|
15
|
-
|
|
8
|
+
- **Three deck shapes.** Builds standard 52-card and 36-card decks, and custom decks from any ranks, suits, and number of decks.
|
|
9
|
+
- **Replayable shuffles.** Shuffles with Fisher-Yates from a seed you can pass in or read back from the deck.
|
|
10
|
+
- **40 bytes for 52 cards.** Encodes a deck to a binary string for a database, a cache, or a file.
|
|
11
|
+
- **No runtime dependencies.** Requires Ruby 3.3 or newer and nothing else.
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
Add it to your Gemfile:
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
```bash
|
|
16
|
+
bundle add card_dealer
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Then build a deck, shuffle it, and deal a hand:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
require "card_dealer"
|
|
23
|
+
|
|
24
|
+
deck = CardDealer::BuildDeck.standard52.shuffle(42)
|
|
25
|
+
deck.deal(5).map(&:to_s) # => ["8d", "4s", "Ts", "Ac", "6s"]
|
|
26
|
+
deck.size # => 47
|
|
27
|
+
```
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
A card prints as its rank (2 to 9, T, J, Q, K, A) followed by its suit (c, d, h, s).
|
|
22
30
|
|
|
23
31
|
## Usage
|
|
24
32
|
|
|
25
|
-
###
|
|
33
|
+
### Building a standard 52-card deck
|
|
26
34
|
|
|
27
|
-
To
|
|
35
|
+
To build a 52-card deck, call `CardDealer::BuildDeck.standard52`:
|
|
28
36
|
|
|
29
37
|
```ruby
|
|
30
38
|
deck = CardDealer::BuildDeck.standard52
|
|
31
|
-
|
|
39
|
+
deck.size # => 52
|
|
40
|
+
deck.to_a.first(3) # => ["2c", "3c", "4c"]
|
|
32
41
|
```
|
|
33
42
|
|
|
34
|
-
###
|
|
43
|
+
### Building a standard 36-card deck
|
|
35
44
|
|
|
36
|
-
To
|
|
45
|
+
To build a 36-card deck, call `CardDealer::BuildDeck.standard36`:
|
|
37
46
|
|
|
38
47
|
```ruby
|
|
39
48
|
deck = CardDealer::BuildDeck.standard36
|
|
40
|
-
|
|
49
|
+
deck.size # => 36
|
|
50
|
+
deck.to_a.first(3) # => ["6c", "7c", "8c"]
|
|
41
51
|
```
|
|
42
52
|
|
|
43
|
-
###
|
|
53
|
+
### Building a custom deck
|
|
44
54
|
|
|
45
|
-
To
|
|
46
|
-
You can specify the number of decks, cards per suit, ranks, and suits:
|
|
55
|
+
To build a custom deck, call `CardDealer::BuildDeck.custom`. `ranks` takes `:highest`, `:lowest`, or an array such as `%w[2 4 6 8 T]`. `suits` takes `:all` or an array such as `%w[d h]`:
|
|
47
56
|
|
|
48
57
|
```ruby
|
|
49
58
|
deck = CardDealer::BuildDeck.custom(
|
|
@@ -52,87 +61,80 @@ deck = CardDealer::BuildDeck.custom(
|
|
|
52
61
|
ranks: :highest,
|
|
53
62
|
suits: %w[c d]
|
|
54
63
|
)
|
|
55
|
-
|
|
64
|
+
deck.size # => 20
|
|
65
|
+
deck.to_a.first(6) # => ["Tc", "Jc", "Qc", "Kc", "Ac", "Td"]
|
|
56
66
|
```
|
|
57
67
|
|
|
58
68
|
### Shuffling and dealing cards
|
|
59
69
|
|
|
60
|
-
|
|
70
|
+
`CardDealer::Deck#shuffle` takes an optional seed. Without one, it generates a seed and stores it in `seed`, so you can replay the shuffle later:
|
|
61
71
|
|
|
62
72
|
```ruby
|
|
63
73
|
deck = CardDealer::BuildDeck.standard52
|
|
64
74
|
deck.shuffle
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
seed = deck.seed # keep this to replay the shuffle
|
|
76
|
+
hand = deck.deal(5) # => five CardDealer::Card objects
|
|
77
|
+
deck.size # => 47
|
|
67
78
|
```
|
|
68
79
|
|
|
69
|
-
|
|
80
|
+
To burn cards before dealing, pass `burn:`:
|
|
70
81
|
|
|
71
82
|
```ruby
|
|
72
|
-
deck = CardDealer::BuildDeck.standard52
|
|
73
|
-
deck.shuffle
|
|
83
|
+
deck = CardDealer::BuildDeck.standard52.shuffle(42)
|
|
74
84
|
hand = deck.deal(3, burn: 1)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
To burn cards without dealing, just pass `0` as the number of cards to deal:
|
|
79
|
-
|
|
80
|
-
```ruby
|
|
81
|
-
deck = CardDealer::BuildDeck.standard52
|
|
82
|
-
deck.shuffle
|
|
83
|
-
hand = deck.deal(0, burn: 1)
|
|
84
|
-
puts hand
|
|
85
|
+
hand.map(&:to_s) # => ["4s", "Ts", "Ac"]
|
|
86
|
+
deck.burned_cards.map(&:to_s) # => ["8d"]
|
|
85
87
|
```
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
To burn cards without dealing, deal `0` cards:
|
|
88
90
|
|
|
89
91
|
```ruby
|
|
90
|
-
deck = CardDealer::BuildDeck.standard52
|
|
91
|
-
deck.shuffle
|
|
92
|
+
deck = CardDealer::BuildDeck.standard52.shuffle(42)
|
|
92
93
|
deck.deal(0, burn: 10)
|
|
93
|
-
|
|
94
|
+
deck.burned_cards.size # => 10
|
|
95
|
+
deck.size # => 42
|
|
94
96
|
```
|
|
95
97
|
|
|
96
|
-
### Encoding a deck
|
|
98
|
+
### Encoding a deck as a binary string
|
|
97
99
|
|
|
98
|
-
To encode a deck
|
|
99
|
-
This is useful if you'd like to store a deck of cards in a database, cache, or a file:
|
|
100
|
+
To encode a deck, call `CardDealer::BinaryDeck.encode` or `Deck#to_binary_s`. Each card takes 6 bits, after a 1, 2, or 4 byte header carrying the card count:
|
|
100
101
|
|
|
101
102
|
```ruby
|
|
102
|
-
deck = CardDealer::
|
|
103
|
-
|
|
103
|
+
deck = CardDealer::Deck.new([CardDealer::Card.new("As"), CardDealer::Card.new("Td")])
|
|
104
|
+
encoded = CardDealer::BinaryDeck.encode(deck)
|
|
104
105
|
# - or -
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
encoded = deck.to_binary_s
|
|
107
|
+
encoded # => "\x02\xCDP"
|
|
107
108
|
```
|
|
108
109
|
|
|
109
|
-
### Decoding a binary string into a deck
|
|
110
|
+
### Decoding a binary string into a deck
|
|
110
111
|
|
|
111
|
-
To decode a binary string
|
|
112
|
+
To decode a binary string, call `CardDealer::BinaryDeck.decode` or `Deck.from_binary`:
|
|
112
113
|
|
|
113
114
|
```ruby
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
encoded = "\x02\xCDP"
|
|
116
|
+
deck = CardDealer::BinaryDeck.decode(encoded)
|
|
116
117
|
# - or -
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
deck = CardDealer::Deck.from_binary(encoded)
|
|
119
|
+
deck.to_a # => ["As", "Td"]
|
|
119
120
|
```
|
|
120
121
|
|
|
121
122
|
## Development
|
|
122
123
|
|
|
123
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
|
124
|
-
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
|
125
|
-
prompt that will allow you to experiment.
|
|
124
|
+
After checking out the repo, run `bin/setup` to install dependencies. Run `bundle exec rake` to run the type checker, the linter, and the tests. Run `bin/console` for an interactive prompt.
|
|
126
125
|
|
|
127
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
128
|
-
release a new version, update the version number in `version.rb`, and then run
|
|
129
|
-
`bundle exec rake release`, which will create a git tag for the version, push
|
|
130
|
-
git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
126
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `lib/card_dealer/version.rb`. Add the release to `CHANGELOG.md`. Push a tag such as `v0.3.0`, which cuts the release.
|
|
131
127
|
|
|
132
128
|
## Contributing
|
|
133
129
|
|
|
134
|
-
|
|
130
|
+
Read [CONTRIBUTING.md](CONTRIBUTING.md) for setup, tests, and how to open a pull request. To report a vulnerability, follow [SECURITY.md](SECURITY.md).
|
|
131
|
+
|
|
132
|
+
## Help and status
|
|
133
|
+
|
|
134
|
+
Ask questions and report bugs in [GitHub issues](https://github.com/svyatov/card_dealer/issues).
|
|
135
|
+
|
|
136
|
+
CardDealer is actively maintained by one person. Releases happen when there is something to release.
|
|
135
137
|
|
|
136
138
|
## License
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
CardDealer is available under the [MIT License](LICENSE.txt). Releases are listed in [CHANGELOG.md](CHANGELOG.md).
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
The latest release on [rubygems.org](https://rubygems.org/gems/card_dealer) receives security fixes. Older releases do not.
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
|
|
9
|
+
Do not open a public issue for a vulnerability. Use one of these private channels:
|
|
10
|
+
|
|
11
|
+
- [GitHub private vulnerability reporting](https://github.com/svyatov/card_dealer/security/advisories/new)
|
|
12
|
+
- Email to leonid@svyatov.com
|
|
13
|
+
|
|
14
|
+
You will get a reply within 14 days. A fix ships as a new gem release, and the advisory is published after it.
|
data/card_dealer.gemspec
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/card_dealer/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "card_dealer"
|
|
7
|
+
spec.version = CardDealer::VERSION
|
|
8
|
+
spec.authors = ["Leonid Svyatov"]
|
|
9
|
+
spec.email = ["leonid@svyatov.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Builds, shuffles, and deals decks of playing cards."
|
|
12
|
+
spec.description = <<~DESC
|
|
13
|
+
CardDealer builds standard 52-card and 36-card decks and custom decks,
|
|
14
|
+
shuffles them with a seedable Fisher-Yates shuffle, deals and burns cards,
|
|
15
|
+
and encodes a deck to a compact binary string. It has no runtime
|
|
16
|
+
dependencies and requires Ruby 3.3 or newer.
|
|
17
|
+
DESC
|
|
18
|
+
spec.homepage = "https://github.com/svyatov/card_dealer"
|
|
19
|
+
spec.license = "MIT"
|
|
20
|
+
spec.required_ruby_version = ">= 3.3.0"
|
|
21
|
+
|
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
23
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
24
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
25
|
+
|
|
26
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
27
|
+
|
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
30
|
+
spec.files = Dir.chdir(__dir__) do
|
|
31
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
32
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
spec.bindir = "exe"
|
|
36
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
37
|
+
spec.require_paths = ["lib"]
|
|
38
|
+
|
|
39
|
+
# Uncomment to register a new dependency of your gem
|
|
40
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
41
|
+
|
|
42
|
+
# For more information and examples about making a new gem, check out our
|
|
43
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
44
|
+
end
|
data/lib/card_dealer/version.rb
CHANGED
data/lib/card_dealer.rb
CHANGED
data/sig/card_dealer/card.rbs
CHANGED
|
@@ -20,6 +20,16 @@ module CardDealer
|
|
|
20
20
|
|
|
21
21
|
def to_s: -> String
|
|
22
22
|
|
|
23
|
+
def eql?: (untyped other) -> bool
|
|
24
|
+
|
|
25
|
+
def hash: -> Integer
|
|
26
|
+
|
|
27
|
+
def ==: (untyped other) -> bool
|
|
28
|
+
|
|
29
|
+
def <=>: (untyped other) -> Integer?
|
|
30
|
+
|
|
31
|
+
def inspect: -> String
|
|
32
|
+
|
|
23
33
|
private
|
|
24
34
|
|
|
25
35
|
def validate_card!: -> void
|
metadata
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: card_dealer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Leonid Svyatov
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: |
|
|
14
|
-
CardDealer
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
manipulation tools that bring the classic card game experience to life.
|
|
13
|
+
CardDealer builds standard 52-card and 36-card decks and custom decks,
|
|
14
|
+
shuffles them with a seedable Fisher-Yates shuffle, deals and burns cards,
|
|
15
|
+
and encodes a deck to a compact binary string. It has no runtime
|
|
16
|
+
dependencies and requires Ruby 3.3 or newer.
|
|
19
17
|
email:
|
|
20
18
|
- leonid@svyatov.com
|
|
21
19
|
executables: []
|
|
@@ -25,12 +23,16 @@ files:
|
|
|
25
23
|
- ".rspec"
|
|
26
24
|
- ".rubocop.yml"
|
|
27
25
|
- CHANGELOG.md
|
|
26
|
+
- CODE_OF_CONDUCT.md
|
|
27
|
+
- CONTRIBUTING.md
|
|
28
28
|
- Gemfile
|
|
29
29
|
- Gemfile.lock
|
|
30
30
|
- LICENSE.txt
|
|
31
31
|
- README.md
|
|
32
32
|
- Rakefile
|
|
33
|
+
- SECURITY.md
|
|
33
34
|
- Steepfile
|
|
35
|
+
- card_dealer.gemspec
|
|
34
36
|
- lib/card_dealer.rb
|
|
35
37
|
- lib/card_dealer/binary_deck.rb
|
|
36
38
|
- lib/card_dealer/build_deck.rb
|
|
@@ -49,9 +51,8 @@ licenses:
|
|
|
49
51
|
metadata:
|
|
50
52
|
homepage_uri: https://github.com/svyatov/card_dealer
|
|
51
53
|
source_code_uri: https://github.com/svyatov/card_dealer
|
|
52
|
-
changelog_uri: https://github.com/svyatov/card_dealer/blob/
|
|
54
|
+
changelog_uri: https://github.com/svyatov/card_dealer/blob/main/CHANGELOG.md
|
|
53
55
|
rubygems_mfa_required: 'true'
|
|
54
|
-
post_install_message:
|
|
55
56
|
rdoc_options: []
|
|
56
57
|
require_paths:
|
|
57
58
|
- lib
|
|
@@ -59,15 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
59
60
|
requirements:
|
|
60
61
|
- - ">="
|
|
61
62
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: 3.
|
|
63
|
+
version: 3.3.0
|
|
63
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
65
|
requirements:
|
|
65
66
|
- - ">="
|
|
66
67
|
- !ruby/object:Gem::Version
|
|
67
68
|
version: '0'
|
|
68
69
|
requirements: []
|
|
69
|
-
rubygems_version: 3.
|
|
70
|
-
signing_key:
|
|
70
|
+
rubygems_version: 3.6.9
|
|
71
71
|
specification_version: 4
|
|
72
|
-
summary:
|
|
72
|
+
summary: Builds, shuffles, and deals decks of playing cards.
|
|
73
73
|
test_files: []
|