Skip to content

Commit

Permalink
Merge pull request #20 from morgen-peschke/release-v0.2.0
Browse files Browse the repository at this point in the history
Release v0.2.0
  • Loading branch information
morgen-peschke authored Aug 28, 2022
2 parents b2ab589 + 4156e62 commit 7e26415
Show file tree
Hide file tree
Showing 39 changed files with 3,750 additions and 445 deletions.
11 changes: 11 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ EOF
exit 1
fi

if mill show __.publishVersion 2>/dev/null | jq --raw-output '.[]' | \grep -E '[^0-9.]'
then
cat <<\EOF
Error: Version number contains unexpected characters.
Sometimes a 'g' will sneak in there, (see version 0.2g.0), please double-check the publishVersion in build.sc
EOF
exit 1
fi

mill __.compile + \
__.test + \
__.fix --check + \
__.checkFormat
20 changes: 15 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
.idea
.bloop
.bsp
.metals
.scala
.vscode

target
out
project
metals.sbt
*.iml

*.class
*.log
target/
.eclipse

*~
.idea
out
.DS_Store
.bsp
project
28 changes: 28 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
rules: [
DisableSyntax
LeakingImplicitClassVal
NoValInForComprehension
RedundantSyntax
OrganizeImports
]

DisableSyntax.noVars = true
DisableSyntax.noThrows = true
DisableSyntax.noNulls = true
DisableSyntax.noReturns = true
DisableSyntax.noWhileLoops = true
DisableSyntax.noAsInstanceOf = true
DisableSyntax.noIsInstanceOf = true
DisableSyntax.noXml = false
DisableSyntax.noDefaultArgs = true
DisableSyntax.noFinalVal = true
DisableSyntax.noFinalize = true
DisableSyntax.noValPatterns = true
DisableSyntax.noUniversalEquality = true
DisableSyntax.regex: [
{
id = "non-final case class"
pattern = "^\\s{2,}case class"
message = "Extending a case class produces broken classes. See https://stackoverflow.com/a/34562046/1188897"
}
]
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ Highlights include:
```scala
Gen.chooseNum(0, (b-a) - 1).map(l => a + (c * l))
```
- `Combinators.ranges(min, max)` generates `Range`s within those bounds
- `RangeGens.ranges(min, max)` generates `Range`s within those bounds
- `NumericRangeGens.numericRanges(min, max)` generates `NumericRange`s within those bounds
- `(g: Gen[A]).as.list(a to b)` as an alternative to `Gen.chooseNum(a, b).flatMap(Gen.listOfN(g, foo))`
Variants also exist to produce `Vector`, `Chain`, and the `NonEmpty*` equivalents, as well as one to

Variants also exist to produce `Vector`, `Chain`, and the `NonEmpty*` equivalents, as well as one to
lift a `Gen[Char]` into a `Gen[String]`
- `(g: Gen[A]).optional` as an chaining alternative to `Gen.option(g)`
- `(g: Gen[A]).optional` as a chaining alternative to `Gen.option(g)`

### `commons-decline`

Instances for Decline, notably one for `Slice` as it tends to very handy for CLI utilities.
Instances for Decline, notably one for `Slice` as it tends to be very handy for CLI utilities.
172 changes: 100 additions & 72 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import $ivy.`com.goyeau::mill-scalafix::0.2.10`
import com.goyeau.mill.scalafix.ScalafixModule
import mill._, scalalib._, scalafmt._
import mill.scalalib.publish._

val Scala12 = "2.12.16"
val Scala13 = "2.13.8"

trait CommonModule extends CrossScalaModule with ScalafmtModule with PublishModule {
def publishVersion = "0.1.0"
val CatsCore = ivy"org.typelevel::cats-core:2.7.0"
val CatsParse = ivy"org.typelevel::cats-parse:0.3.7"

def pomSettings = PomSettings(
description = "Scala Commons - common utilities for Scala projects",
organization = "com.github.morgen-peschke",
url = "https://github.com/morgen-peschke/scala-commons",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("morgen-peschke", "scala-commons"),
developers = Seq(
Developer("morgen-peschke", "Morgen Peschke", "https://github.com/morgen-peschke")
)
)
val SuperTagged = ivy"org.rudogma::supertagged:2.0-RC2"

def crossScalaVersion: String
val ScalaCheck = ivy"org.scalacheck::scalacheck:1.16.0"
val ScalaTest = ivy"org.scalatest::scalatest:3.2.13"
val WordSpec = Set(ScalaTest, ivy"org.scalatest::scalatest-wordspec:3.2.13")
val PropSpec = Set(
ScalaTest,
ivy"org.scalatest::scalatest-propspec:3.2.13",
ivy"org.scalatestplus::scalacheck-1-16:3.2.12.0"
)

trait StyleModule extends ScalafmtModule with ScalafixModule {
override def scalafixIvyDeps = super.scalafixIvyDeps() ++ Agg(ivy"com.github.liancheng::organize-imports:0.6.0")

def commonScalacOptions = Seq(
"-encoding",
Expand All @@ -34,96 +37,121 @@ trait CommonModule extends CrossScalaModule with ScalafmtModule with PublishModu
)

def versionSpecificOptions(version: String) = version match {
case Scala12 => Seq(
"-Ywarn-adapted-args",
"-Ywarn-inaccessible",
"-Ywarn-unused-import",
"-Ypartial-unification"
)
case Scala12 =>
Seq(
"-Ywarn-adapted-args",
"-Ywarn-inaccessible",
"-Ywarn-unused-import",
"-Ypartial-unification"
)
case _ => Seq()
}

def scalacOptions = commonScalacOptions ++ versionSpecificOptions(crossScalaVersion)
def crossScalaVersion: String

override def scalacOptions =
super.scalacOptions() ++ commonScalacOptions ++ versionSpecificOptions(crossScalaVersion)

def scalaDocOptions = Seq("-no-link-warnings")
override def scalaDocOptions = super.scalaDocOptions() ++ Seq("-no-link-warnings")

override def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ Agg(
ivy"com.olegpy::better-monadic-for:0.3.1",
ivy"org.typelevel:::kind-projector:0.13.2"
)
}

object core extends Cross[CoreModule](Scala12, Scala13)
class CoreModule(val crossScalaVersion: String)
extends CommonModule {
trait CommonModule
extends CrossScalaModule
with StyleModule
with PublishModule {

override def artifactName: T[String] = T { s"commons-${super.artifactName()}" }

override def artifactName = "commons-core"
def publishVersion: T[String] = "0.2.0"

override def ivyDeps = Agg(
ivy"org.typelevel::cats-core:2.7.0",
ivy"org.rudogma::supertagged:2.0-RC2",
ivy"org.typelevel::cats-parse:0.3.7"
override def pomSettings: T[PomSettings] = PomSettings(
description = "Scala Commons - common utilities for Scala projects",
organization = "com.github.morgen-peschke",
url = "https://github.com/morgen-peschke/scala-commons",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("morgen-peschke", "scala-commons"),
developers = Seq(
Developer(
"morgen-peschke",
"Morgen Peschke",
"https://github.com/morgen-peschke"
)
)
)

object test extends Tests with TestModule.ScalaTest {
protected def outerCrossScalaVersion: String = crossScalaVersion
}

trait CommonTestModule extends TestModule.ScalaTest with StyleModule

object core extends Cross[CoreModule](Scala12, Scala13)
class CoreModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps = Agg(CatsCore, CatsParse, SuperTagged)

override def moduleDeps = super.moduleDeps ++ Seq(scalacheck(crossScalaVersion))
object test extends Tests with CommonTestModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(scalacheck(crossScalaVersion))

override def ivyDeps = Agg(
ivy"org.scalacheck::scalacheck:1.16.0",
ivy"org.scalatest::scalatest:3.2.13",
ivy"org.scalatest::scalatest-wordspec:3.2.13",
ivy"org.scalatest::scalatest-propspec:3.2.13",
ivy"org.scalatestplus::scalacheck-1-16:3.2.12.0",
ivy"org.python:jython-slim:2.7.2"
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(
WordSpec ++ PropSpec + ivy"org.python:jython-slim:2.7.2"
)

override def crossScalaVersion: String = outerCrossScalaVersion
}
}

object collections extends Cross[CollectionsModule](Scala12, Scala13)
class CollectionsModule(val crossScalaVersion: String)
extends CommonModule {

override def artifactName = "commons-collections"
class CollectionsModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(CatsCore)

object test extends Tests with TestModule.ScalaTest {
object test extends Tests with CommonTestModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(scalacheck(crossScalaVersion))

override def moduleDeps = super.moduleDeps ++ Seq(scalacheck(crossScalaVersion))
override def crossScalaVersion: String = outerCrossScalaVersion

override def ivyDeps = Agg(
ivy"org.scalacheck::scalacheck:1.16.0",
ivy"org.scalatest::scalatest:3.2.13",
ivy"org.scalatest::scalatest-wordspec:3.2.13",
ivy"org.scalatest::scalatest-propspec:3.2.13",
ivy"org.scalatestplus::scalacheck-1-16:3.2.12.0",
ivy"org.python:jython-slim:2.7.2"
)
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(WordSpec ++ PropSpec)
}
}

object scalacheck extends Cross[ScalaCheckModule](Scala12, Scala13)
class ScalaCheckModule(val crossScalaVersion: String)
extends CommonModule {

override def artifactName = "commons-scalacheck"
class ScalaCheckModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(ScalaCheck)

override def ivyDeps = Agg(
ivy"org.typelevel::cats-core:2.7.0",
ivy"org.scalacheck::scalacheck:1.16.0"
override def moduleDeps: Seq[PublishModule] = super.moduleDeps ++ Seq(
core(crossScalaVersion),
collections(crossScalaVersion)
)

object test extends Tests with TestModule.ScalaTest {
override def ivyDeps = Agg(
ivy"org.scalacheck::scalacheck:1.16.0",
ivy"org.scalatest::scalatest:3.2.13",
ivy"org.scalatest::scalatest-propspec:3.2.13",
ivy"org.scalatestplus::scalacheck-1-16:3.2.12.0"
)
object test extends Tests with CommonTestModule {
override def crossScalaVersion: String = outerCrossScalaVersion

override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(PropSpec)
}
}

object decline extends Cross[DeclineModule](Scala12, Scala13)
class DeclineModule(val crossScalaVersion: String)
extends CommonModule {
class DeclineModule(val crossScalaVersion: String) extends CommonModule {
override def moduleDeps: Seq[PublishModule] = super.moduleDeps ++ Seq(core(crossScalaVersion))

override def artifactName = "commons-decline"
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(
CatsCore,
ivy"com.monovore::decline:2.3.0"
)
}

object shims extends Cross[ShimsModule](Scala12, Scala13)
class ShimsModule(val crossScalaVersion: String) extends CommonModule {
override def moduleDeps: Seq[PublishModule] = super.moduleDeps ++ Seq(core(crossScalaVersion))

override def moduleDeps = super.moduleDeps ++ Seq(core(crossScalaVersion))
object test extends Tests with CommonTestModule {
override def crossScalaVersion: String = outerCrossScalaVersion

override def ivyDeps = Agg(ivy"com.monovore::decline:2.3.0")
}
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(WordSpec)
}
}
5 changes: 3 additions & 2 deletions collections/src-2.12/peschke/collections/TakeUntil.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package peschke.collections

import scala.annotation.tailrec
import scala.collection.TraversableLike
import scala.collection.generic.CanBuildFrom
import scala.collection.{TraversableLike, mutable}
import scala.collection.mutable
import scala.language.higherKinds

/** Provides a reversed alternative to
Expand Down Expand Up @@ -34,7 +35,7 @@ object TakeUntil {

object syntax {
implicit class TakeUntilOps[E, C[X] <: TraversableLike[X, C[X]]]
(val source: C[E])
(private val source: C[E])
extends AnyVal {
def takeUntil[That](p: E => Boolean)
(implicit cbf: CanBuildFrom[C[E], E, That])
Expand Down
3 changes: 2 additions & 1 deletion collections/src-2.13/peschke/collections/TakeUntil.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package peschke.collections

import scala.collection.{AbstractView, BuildFrom}
import scala.collection.AbstractView
import scala.collection.BuildFrom

/** Provides a reversed alternative to [[scala.collection.Iterator.takeWhile]]
*
Expand Down
Loading

0 comments on commit 7e26415

Please sign in to comment.