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

Add IPv4 and private networks #356

Merged
merged 2 commits into from
Nov 23, 2017
Merged

Conversation

NeQuissimus
Copy link
Contributor

@NeQuissimus NeQuissimus commented Nov 17, 2017

Basically a follow-up to #353

This is what I am using at work, I figured I would clean it up and contribute it back.

No external Java dependencies, so this also works with Scala.js without any issues.

I will have to add IPv6 next week, so I will send that in as well once I have it.

/cc @derekmorr @fthomas

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.

I've left some minor comments but in general this LGTM. You should also add MiMa exclusions for the things it complained about. Adding methods is OK.

@@ -40,14 +43,34 @@ object string extends StringValidate with StringInference {
final case class XPath()
}

private[refined] trait StringValidate {
object Predicates {
object IPv4 {
Copy link
Owner

Choose a reason for hiding this comment

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

Could you move the IPv4 object into the string object right below the IPv4 case class and remove the Predicates object? It makes sense to put auxiliary code of predicates into their proper companion.


/** A `String` representing a valid IPv4 in a private network according to RFC1918 */
type Rfc1918Private =
String Refined Rfc1918ClassAPrivateSpec Or Rfc1918ClassBPrivateSpec Or Rfc1918ClassCPrivateSpec
Copy link
Owner

Choose a reason for hiding this comment

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

Would it make sense to add an alias type Rfc1918PrivateSpec = Rfc1918ClassAPrivateSpec Or Rfc1918ClassBPrivateSpec Or Rfc1918ClassCPrivateSpec? That could be used here and in the definition of PrivateNetwork. A type Rfc5737TestnetSpec could be also useful to avoid repetition.

@codecov
Copy link

codecov bot commented Nov 22, 2017

Codecov Report

Merging #356 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #356      +/-   ##
==========================================
+ Coverage   98.71%   98.74%   +0.02%     
==========================================
  Files          39       39              
  Lines         468      478      +10     
  Branches        8        8              
==========================================
+ Hits          462      472      +10     
  Misses          6        6
Impacted Files Coverage Δ
...red/src/main/scala/eu/timepit/refined/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 1121e99...f8e23af. Read the comment docs.

@fthomas
Copy link
Owner

fthomas commented Nov 23, 2017

Looks great, many thanks @NeQuissimus!

@fthomas fthomas merged commit 40bedc4 into fthomas:master Nov 23, 2017
@NeQuissimus NeQuissimus deleted the ip_networks branch November 23, 2017 23:57
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.

3 participants