Skip to content

Commit

Permalink
v2.2.2 - Scala 2.13 StackTrace related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
agilesteel committed Jul 3, 2020
1 parent 4b1803b commit b1513f5
Show file tree
Hide file tree
Showing 36 changed files with 681 additions and 499 deletions.
66 changes: 58 additions & 8 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,69 @@
version = "2.3.2"
version = "2.6.1"

assumeStandardLibraryStripMargin = true
align {
stripMargin = true
}

assumeStandardLibraryStripMargin = false

binPack {
literalArgumentLists = false
}

continuationIndent {
withSiteRelativeToExtends = 3
}

includeNoParensInSelectChains = true

newlines {
alwaysBeforeElseAfterCurlyIf = true
}

project {
excludeFilters = [
".metals"
]
}

rewrite {
rules = [SortModifiers, PreferCurlyFors]
sortModifiers.order = [
"final", "sealed", "abstract", "override",
"implicit", "private", "protected", "lazy"
rules = [
PreferCurlyFors,
RedundantBraces,
RedundantParens,
SortImports,
SortModifiers,
]

sortModifiers {
order = [
"final",
"sealed",
"abstract",
"override",
"implicit",
"private",
"protected",
"lazy"
]
}
}

rewriteTokens {
"⇒" = "=>"
"→" = "->"
"←" = "<-"
}

spaces {
inImportCurlyBraces = true
}

verticalMultiline {
arityThreshold = 60
arityThreshold = 3
atDefnSite = true
excludeDanglingParens = []
newlineAfterImplicitKW = true
newlineAfterOpenParen = true
newlineBeforeImplicitKW = true
newlineBeforeImplicitKW = false
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
### Releases

```scala
libraryDependencies += "com.github.agilesteel" %% "spells" % "2.2.1"
libraryDependencies += "com.github.agilesteel" %% "spells" % "2.2.2"

// for Scala version below 2.13 use:
libraryDependencies += "com.github.agilesteel" %% "spells" % "2.2.0"
Expand Down
11 changes: 9 additions & 2 deletions aliases.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ addCommandAlias(
)

addCommandAlias("testWithCoverage", "clean; coverage; test; coverageReport")
addCommandAlias("deploySnapshot", "+clean; +test; +publish")
addCommandAlias("deploy", "+clean; +test; +publishSigned; sonatypeReleaseAll")
addCommandAlias("deploySnapshot", "clean; test; publish")
addCommandAlias("deploy", "clean; test; publishSigned; sonatypeReleaseAll")
addCommandAlias("deploySnapshotAll", "+clean; +test; +publish")
addCommandAlias(
"deployAll",
"+clean; +test; +publishSigned; sonatypeReleaseAll"
)

onLoadMessage +=
s"""|
Expand All @@ -29,5 +34,7 @@ onLoadMessage +=
|${styled("up2date")} │ dependencyUpdates
|${styled("deploy")} │ deploy
|${styled("deploySnapshot")} │ deploySnapshot
|${styled("deployAll")} │ deployAll
|${styled("deploySnapshotAll")}│ deploySnapshotAll
|${styled("testWithCoverage")} │ testWithCoverage
|─────────────────┴──────────────────""".stripMargin
8 changes: 6 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ lazy val spells =
.settings(
name := "spells",
organization := "com.github.agilesteel",
version := "2.2.1",
scalaVersion := "2.13.1",
version := "2.2.2",
scalaVersion := "2.13.3",
homepage := Some(url("https://agilesteel.github.io/spells/")),
startYear := some(2012),
description := """This is a small scala "util" library, which will hopefully grow over time.""",
Expand Down Expand Up @@ -39,6 +39,10 @@ lazy val spells =
"-Ywarn-unused:_",
"-Xfatal-warnings"
),
Compile / doc / scalacOptions --= Seq(
"-Ywarn-unused:_",
"-Xfatal-warnings"
),
Compile / console / scalacOptions --= Seq(
"-Ywarn-unused:_",
"-Xfatal-warnings"
Expand Down
8 changes: 2 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Dependencies extends (String => Seq[ModuleID]) {
val `scala-reflect` = "org.scala-lang" % "scala-reflect" % scalaVersion

val `scala-collection-compat` =
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.2"
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6"

val config = {
val configVersion: String =
Expand All @@ -18,18 +18,14 @@ object Dependencies extends (String => Seq[ModuleID]) {
}

object Test {
val pegdown =
"org.pegdown" % "pegdown" % "1.6.0"

val scalatest =
"org.scalatest" %% "scalatest" % "3.0.8"
"org.scalatest" %% "scalatest" % "3.2.0"
}

Seq(
`scala-collection-compat`,
`scala-reflect`,
config,
Test.pegdown % sbt.Test,
Test.scalatest % sbt.Test
)
}
Expand Down
14 changes: 6 additions & 8 deletions project/UserConfigFileManager.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import java.nio.file.{Files, Paths}
import java.nio.file.{ Files, Paths }
import java.nio.file.StandardCopyOption._
import java.nio.file.LinkOption._

Expand All @@ -7,7 +7,8 @@ object UserConfigFileManager {
s"""${System.getProperty("user.home")}/.spells.conf"""

private[this] val userConfigLocation = Paths get userConfigLocationValue
private[this] val userConfigBackupLocation = Paths get (userConfigLocationValue + "_backup")
private[this] val userConfigBackupLocation =
Paths get (userConfigLocationValue + "_backup")

val createSpellsConfigFileForCurrentUser: () => Unit = () => {
backup()
Expand All @@ -19,7 +20,7 @@ object UserConfigFileManager {
restore()
}

private[this] def backup(): Unit = {
private[this] def backup(): Unit =
if (Files exists userConfigLocation)
Files.move(
userConfigLocation,
Expand All @@ -28,7 +29,6 @@ object UserConfigFileManager {
REPLACE_EXISTING,
NOFOLLOW_LINKS
)
}

private[this] def create(): Unit = {
val userConfigContent =
Expand All @@ -41,11 +41,10 @@ object UserConfigFileManager {
Files.write(userConfigLocation, userConfigContent.getBytes)
}

private[this] def delete(): Unit = {
private[this] def delete(): Unit =
Files.delete(userConfigLocation)
}

private[this] def restore(): Unit = {
private[this] def restore(): Unit =
if (Files exists userConfigBackupLocation)
Files.move(
userConfigBackupLocation,
Expand All @@ -54,5 +53,4 @@ object UserConfigFileManager {
REPLACE_EXISTING,
NOFOLLOW_LINKS
)
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.3
sbt.version=1.3.13
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ThisBuild / scalaVersion := "2.12.10"
ThisBuild / scalaVersion := "2.12.11"
ThisBuild / useSuperShell := false
ThisBuild / autoStartServer := false

Expand All @@ -13,12 +13,12 @@ resolvers ++= Seq(
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "3.0.3")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.0")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.3")

scalacOptions ++= Seq(
"-encoding",
Expand Down
2 changes: 1 addition & 1 deletion project/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.0")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1")
7 changes: 3 additions & 4 deletions publish.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pomIncludeRepository := { _ =>
false
}

publishTo := {
(version) { version: String =>
publishTo :=
version { version: String =>
if (version.trim.endsWith("SNAPSHOT"))
Some(
"Sonatype Nexus Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
Expand All @@ -18,8 +18,7 @@ publishTo := {
Some(
"Sonatype Nexus Staging" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"
)
}
}.value
}.value

scmInfo := Some(
ScmInfo(
Expand Down
52 changes: 27 additions & 25 deletions src/main/scala/spells/AnsiModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,39 @@ trait AnsiModule {
* @see https://en.wikipedia.org/wiki/ANSI_escape_code
* @return an instance of `AnsiStyle`
*/
final def toAnsiStyle: AnsiModule#AnsiStyle = style match {
case "Black" => AnsiStyle.Black
case "Blue" => AnsiStyle.Blue
case "Cyan" => AnsiStyle.Cyan
case "Green" => AnsiStyle.Green
case "Magenta" => AnsiStyle.Magenta
case "Random" => AnsiStyle.Random
case "Red" => AnsiStyle.Red
case "Untouched" => AnsiStyle.Reset
case "White" => AnsiStyle.White
case "Yellow" => AnsiStyle.Yellow
case _ =>
new AnsiStyle(Option(style).fold("")(_.replace("\\033", "\u001b")))
}
final def toAnsiStyle: AnsiModule#AnsiStyle =
style match {
case "Black" => AnsiStyle.Black
case "Blue" => AnsiStyle.Blue
case "Cyan" => AnsiStyle.Cyan
case "Green" => AnsiStyle.Green
case "Magenta" => AnsiStyle.Magenta
case "Random" => AnsiStyle.Random
case "Red" => AnsiStyle.Red
case "Untouched" => AnsiStyle.Reset
case "White" => AnsiStyle.White
case "Yellow" => AnsiStyle.Yellow
case _ =>
new AnsiStyle(Option(style).fold("")(_.replace("\\033", "\u001b")))
}
}

/** Encoding of `AnsiStyle`s
* @param value the style to encode
*/
final class AnsiStyle private[spells] (val value: String) {
final override def toString: String = value match {
case AnsiStyle.Black.value => "Black" in this
case AnsiStyle.Blue.value => "Blue" in this
case AnsiStyle.Cyan.value => "Cyan" in this
case AnsiStyle.Green.value => "Green" in this
case AnsiStyle.Magenta.value => "Magenta" in this
case AnsiStyle.Red.value => "Red" in this
case AnsiStyle.White.value => "White" in this
case AnsiStyle.Yellow.value => "Yellow" in this
case _ => AnsiStyle.Sample in this
}
final override def toString: String =
value match {
case AnsiStyle.Black.value => "Black" in this
case AnsiStyle.Blue.value => "Blue" in this
case AnsiStyle.Cyan.value => "Cyan" in this
case AnsiStyle.Green.value => "Green" in this
case AnsiStyle.Magenta.value => "Magenta" in this
case AnsiStyle.Red.value => "Red" in this
case AnsiStyle.White.value => "White" in this
case AnsiStyle.Yellow.value => "Yellow" in this
case _ => AnsiStyle.Sample in this
}
}

/** Provides the method `in` which converts `Any` to `String` `in` `AnsiStyle`.
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/spells/CalendarOpsModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ trait CalendarOpsModule {
availableWidthInCharacters: StringOpsModule#AvailableWidthInCharacters =
SpellsConfig.terminal.WidthInCharacters.value
): String =
new SimpleDateFormat(DateOpsFromSpells.Defaults.Format) format value.getTime
new SimpleDateFormat(
DateOpsFromSpells.Defaults.Format
) format value.getTime
}
}
15 changes: 5 additions & 10 deletions src/main/scala/spells/ClearPrintModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,21 @@ trait ClearPrintModule {
*/
final def clearPrintln(
input: Any = ""
)(
implicit
)(implicit
style: AnsiModule#AnsiStyle = AnsiStyle.Reset
): Unit = {
): Unit =
Console println cleared(input)(style)
}

/** Prints an object to out using its toString method, beginning at the first character in the current line of your terminal.
* @param input the object to print
* @param style custom `AnsiStyle`
*/
final def clearPrint(
input: Any = ""
)(
implicit
)(implicit
style: AnsiModule#AnsiStyle = AnsiStyle.Reset
): Unit = {
): Unit =
Console print cleared(input)(style)
}

/** Moves the caret to the beginning of the line.
* @param input the object to be moved to the beginning of the line
Expand All @@ -64,8 +60,7 @@ trait ClearPrintModule {
*/
final def cleared(
input: Any = ""
)(
implicit
)(implicit
style: AnsiModule#AnsiStyle = AnsiStyle.Reset
): String =
styled(ClearPrint.Clear.value + s"\r$input" + AnsiStyle.Reset.value)(style)
Expand Down
Loading

0 comments on commit b1513f5

Please sign in to comment.