Skip to content
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

Message digests #453

Merged
merged 8 commits into from
Apr 16, 2018
Merged

Message digests #453

merged 8 commits into from
Apr 16, 2018

Conversation

NeQuissimus
Copy link
Contributor

  • Add HexString to string types
  • Add new category "message digests"
  • Add MD5, SHA1, SHA224, SHA256, SHA384, SHA512

@NeQuissimus NeQuissimus force-pushed the message_digests branch 2 times, most recently from 975f3d9 to d3740c6 Compare March 10, 2018 22:54
@codecov
Copy link

codecov bot commented Mar 14, 2018

Codecov Report

Merging #453 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #453      +/-   ##
==========================================
+ Coverage    95.7%   95.74%   +0.04%     
==========================================
  Files          60       61       +1     
  Lines         675      682       +7     
  Branches       14       12       -2     
==========================================
+ Hits          646      653       +7     
  Misses         29       29
Impacted Files Coverage Δ
.../main/scala/eu/timepit/refined/types/digests.scala 100% <100%> (ø)
...c/main/scala/eu/timepit/refined/types/string.scala 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1d6ca1...1f937fa. Read the comment docs.

@NeQuissimus
Copy link
Contributor Author

@fthomas I don't understand that build error. I import Refined at the top...

@fthomas
Copy link
Owner

fthomas commented Mar 14, 2018

Wow, this is strange. I've no idea what could be causing this.


/** Module for type representing message digests. */
object digests {
import string.HexStringSpec
Copy link
Owner

@fthomas fthomas Mar 19, 2018

Choose a reason for hiding this comment

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

@NeQuissimus The build error on 2.10 can be fixed by moving this import to the top-level imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hadn't had time to look at this, thx :)
How did you figure that out? :D

Copy link
Owner

Choose a reason for hiding this comment

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

I moved and commented stuff out until it compiled. One of my special powers! ;-)

@NeQuissimus
Copy link
Contributor Author

@fthomas Can you kick Travis once more? Things build with 2.10 locally just fine now...

@fthomas
Copy link
Owner

fthomas commented Mar 23, 2018

The build is green now. 👍

Copy link
Owner

@fthomas fthomas left a comment

Choose a reason for hiding this comment

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

@NeQuissimus Sorry it took me so long to review your PR.

I've some questions about HexStringSpec but the rest looks good to me. It would be also nice if you could add an entry to the release notes in notes/0.9.0.markdown.

@@ -17,6 +17,11 @@ object string {
type TrimmedString = String Refined MatchesRegex[W.`"""^(?!\\s).*(?<!\\s)"""`.T]

object TrimmedString extends RefinedTypeOps[TrimmedString, String]

/** A `String` representing a hexadecimal number */
type HexStringSpec = MatchesRegex[W.`"""[0-9a-f]+"""`.T]
Copy link
Owner

Choose a reason for hiding this comment

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

@NeQuissimus Should we also allow upper case letters A-F? What about an optional 0x prefix? I think that a prefix would be fine for HexString but may be inappropriate for the message digests types. Maybe HexStringSpec should be private to digests to sidestep these potential conflicts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The prefix is not really much more than an artifact to identify a hexadecimal number to humans or when the information of it being a hex number is not available. I think that is exactly the information we are adding with the refined type.
I will make the change to allow for upper-case letters (but not mixed-upper/lower).

@@ -17,6 +17,11 @@ object string {
type TrimmedString = String Refined MatchesRegex[W.`"""^(?!\\s).*(?<!\\s)"""`.T]

object TrimmedString extends RefinedTypeOps[TrimmedString, String]

/** A `String` representing a hexadecimal number */
type HexStringSpec = MatchesRegex[W.`"""([0-9a-f]+)|([0-9A-F]+)"""`.T]
Copy link
Owner

Choose a reason for hiding this comment

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

It seems that this does not work with Scala.js (there is a test failure), but fortunately you've experience with such problems. 😺

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh god... I shall stop using coreJVM/test and dive into regex' in JS once again :D

@NeQuissimus
Copy link
Contributor Author

@fthomas Can you kick the build, some 503 thing just happened on Travis.

@fthomas fthomas merged commit 7cc44ec into fthomas:master Apr 16, 2018
@NeQuissimus NeQuissimus deleted the message_digests branch April 16, 2018 22:27
Sign up for free to 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.

2 participants