Skip to content

Add exhaustive case matcher - #43

Merged
dblock merged 4 commits into
dblock:masterfrom
peterfication:add-exhaustive-case-statement
Jan 7, 2024
Merged

Add exhaustive case matcher#43
dblock merged 4 commits into
dblock:masterfrom
peterfication:add-exhaustive-case-statement

Conversation

@peterfication

@peterficationpeterfication commented Jan 5, 2024

Copy link
Copy Markdown
Collaborator

Can be used by including Ruby::Enum::Ecase in an enum class. It will add a method called ecase that can be used to simulate a case statement that will raise an error if a case/enum value is not handled.

Fixes#42

@peterfication

Copy link
Copy Markdown
CollaboratorAuthor

@dblock here you go :)

@dblockdblock left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very close! I left a bunch of comments/questions, take a look.

Comment threadREADME.md
Comment threadREADME.md Outdated
Comment threadREADME.md Outdated
Comment threadREADME.md Outdated
Comment threadREADME.md Outdated
Comment threadREADME.md Outdated
Comment threadlib/ruby-enum/enum/ecase.rb Outdated
Comment threadlib/ruby-enum/enum/ecase.rb
Comment threadREADME.md Outdated
Comment threadspec/ruby-enum/enum/ecase_spec.rb Outdated
@peterfication

Copy link
Copy Markdown
CollaboratorAuthor

Thanks a lot for the deep review and your comments! I appreciate it :)

@dblock

Copy link
Copy Markdown
Owner

Make rubocop happy and we're good to go! Much thanks.

@dblock

Copy link
Copy Markdown
Owner

Oh and since it's a new feature, increment the version to 0.10.0 in this PR. I also wonder whether it's time for Ruby::Enum to graduate to 1.0. That works for me too, your call!

@peterfication

Copy link
Copy Markdown
CollaboratorAuthor

Rubocop is failing on master. Hence, I will make the Rubocop adjustments in a separate commit.

Can be used by including `Ruby::Enum::Ecase` in an enum class. It will
add a method called `ecase` that can be used to simulate a case
statement that will raise an error if a case/enum value is not handled.
@peterfication

Copy link
Copy Markdown
CollaboratorAuthor

I had to disable and ignore some Rubocop rules. See the Rubocop related commit. I wanted to make as little changes as possible in that commit.

@peterfication

Copy link
Copy Markdown
CollaboratorAuthor

I feel like it's a good idea to release a 1.0.0 version as it has been proven stable.

Note: the 0.9.1 version has not been tagged or released to Ruby gems yet.

@peterfication

Copy link
Copy Markdown
CollaboratorAuthor

But maybe it makes sense to wait for #41 for the 1.0.0 release.

@dblockdblock left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Rubocop, you can remove any of the manual disable and the new rules and just run rubocop -a ; rubocop --auto-gen-config, but what you have here works fine too.

Comment threadCHANGELOG.md Outdated
@dblock

Copy link
Copy Markdown
Owner

But maybe it makes sense to wait for #41 for the 1.0.0 release.

Are you going to take it up? :) Please!

@peterfication

Copy link
Copy Markdown
CollaboratorAuthor

Are you going to take it up? :) Please!

I might give it a try next week.

@dblock
dblock merged commit c38afd8 into dblock:masterJan 7, 2024
@dblock

Copy link
Copy Markdown
Owner

Great work @peterfication! Want to help comantain ruby-enum? Drop me your rubygems username to dblock at dblock dot org!

@peterfication
peterfication deleted the add-exhaustive-case-statement branch January 8, 2024 04:31
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Add exhaustive case matcher

2 participants

@peterfication@dblock