-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added enum contract #181
Added enum contract #181
Conversation
@@ -201,6 +201,17 @@ def to_s | |||
end | |||
end | |||
|
|||
# Takes a list of values, e.g. +[:a, :b, :c]A+. If argument is included in the list, the contract passes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you break the comment at 80 characters?
Can you add an example like this # Example: <tt>Enum[:a, :b, :c]</tt>
?
Can you provide short description for this Pull Request? Can you add it to list of builtin contracts in |
Fixed. |
Can you prepare a new release? Are you going to follow semver? I saw that your version number has only two digits.... |
Yes I do want it. But I do not know if @egonSchiele is ok with that. Actually I have bumped to |
@@ -88,6 +88,7 @@ contracts.ruby comes with a lot of built-in contracts, including the following: | |||
* [`SetOf`](http://www.rubydoc.info/gems/contracts/Contracts/SetOf) – checks that the argument is a set, and all elements pass the given contract, e.g. `SetOf[Num]` | |||
* [`HashOf`](http://www.rubydoc.info/gems/contracts/Contracts/HashOf) – checks that the argument is a hash, and all keys and values pass the given contract, e.g. `HashOf[Symbol => String]` or `HashOf[Symbol,String]` | |||
* [`RangeOf`](http://www.rubydoc.info/gems/contracts/Contracts/RangeOf) – checks that the argument is a range whose elements (#first and #last) pass the given contract, e.g. `RangeOf[Date]` | |||
* [`RangeOf`](http://www.rubydoc.info/gems/contracts/Contracts/Enum) – checks that the argument is part of a given collection of objects, e.g. `Enum[:a, :b; :c]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in links title: RangeOf
=> Enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in example: ;
=> ,
Nice contract! Just waiting on responses to @alex-fedorov 's comments before I merge. I agree we should switch to semver. |
Fixed. Sorry for the mistakes. |
@dg-ratiodata no problem :) LGTM, merging |
Thanks @dg-ratiodata! Do you need this to be released right away or this can wait? |
This one can wait. I've got a custom contract for that. The same is true for the PR I filed some minutes ago. |
I use contracts.ruby within a configuration class. Some options only allows a given subset of values - symbols. I added a custom contract for that, but thought it might be valueable for others as well.