-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f6a4ee7
Showing
43 changed files
with
954 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# https://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = unset | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [devinsideyou] | ||
patreon: devinsideyou | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.worksheet.sc | ||
.ammonite/ | ||
.bloop/ | ||
.bsp/ | ||
.dotty-ide* | ||
.history/ | ||
.idea/ | ||
.metals/ | ||
.scala-build/ | ||
.scala/ | ||
.vscode/ | ||
metals.sbt | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-XX:MaxMetaspaceSize=2g | ||
-XX:ReservedCodeCacheSize=1g | ||
-Xms1g | ||
-Xmx12g | ||
-XshowSettings:vm | ||
-Xss4m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
rules = [ | ||
# ExplicitResultTypes | ||
LeakingImplicitClassVal | ||
NoValInForComprehension | ||
OrganizeImports | ||
# RemoveUnused | ||
] | ||
|
||
ExplicitResultTypes { | ||
memberKind = [Def, Val, Var] | ||
memberVisibility = [Public, Protected] | ||
skipSimpleDefinitions = ['Term.Ref', 'Lit', 'Term.New'] | ||
fatalWarnings = false | ||
rewriteStructuralTypesToNamedSubclass = false | ||
} | ||
|
||
OrganizeImports { | ||
blankLines = Auto | ||
coalesceToWildcardImportThreshold = 1 | ||
expandRelative = true | ||
groupExplicitlyImportedImplicitsSeparately = false | ||
groupedImports = AggressiveMerge | ||
groups = [ | ||
"re:javax?\\." | ||
"scala." | ||
"*" | ||
"dev.insideyou." | ||
] | ||
importSelectorsOrder = Ascii | ||
importsOrder = Ascii | ||
preset = DEFAULT | ||
removeUnused = false // should be true | ||
} | ||
|
||
RemoveUnused { | ||
imports = false | ||
privates = true | ||
locals = true | ||
patternvars = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
version = "3.7.17" | ||
|
||
align { | ||
preset = none | ||
stripMargin = yes | ||
} | ||
|
||
assumeStandardLibraryStripMargin = no | ||
|
||
danglingParentheses { | ||
exclude = [] | ||
} | ||
|
||
docstrings { | ||
forceBlankLineBefore = no | ||
oneline = keep | ||
style = SpaceAsterisk | ||
wrap = no | ||
} | ||
|
||
fileOverride { | ||
"glob:**/*.sbt" { | ||
newlines { | ||
topLevelStatementBlankLines = [ | ||
{ | ||
blanks { | ||
afterAll = -1, | ||
} | ||
|
||
minBreaks = 0 | ||
} | ||
] | ||
} | ||
|
||
runner { | ||
# https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects | ||
dialect = Scala212 | ||
} | ||
} | ||
|
||
"glob:**/project/*.scala" { | ||
newlines { | ||
topLevelStatementBlankLines = [ | ||
{ | ||
blanks { | ||
afterAll = -1, | ||
} | ||
|
||
minBreaks = 0 | ||
} | ||
] | ||
} | ||
|
||
runner { | ||
# https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects | ||
dialect = Scala212 | ||
} | ||
} | ||
} | ||
|
||
includeNoParensInSelectChains = yes | ||
|
||
indent { | ||
caseSite = 5 | ||
commaSiteRelativeToExtends = 8 | ||
ctrlSite = 4 | ||
defnSite = 2 | ||
withSiteRelativeToExtends = 3 | ||
} | ||
|
||
indentOperator { | ||
exemptScope = all | ||
} | ||
|
||
lineEndings = preserve | ||
|
||
maxColumn = 100 | ||
|
||
newlines { | ||
alwaysBeforeElseAfterCurlyIf = yes | ||
avoidInResultType = yes | ||
avoidForSimpleOverflow = [slc] | ||
beforeCurlyLambdaParams = multilineWithCaseOnly | ||
implicitParamListModifierForce = [after] | ||
inInterpolation = avoid | ||
|
||
topLevelStatementBlankLines = [ | ||
{ | ||
blanks { | ||
beforeAll = -1, | ||
afterAll = 1, | ||
beforeEndMarker = -1 | ||
} | ||
|
||
minBreaks = 0 | ||
}, | ||
{ | ||
blanks { | ||
beforeAll = -1, | ||
before = 1, | ||
after = 1, | ||
afterAll = -1, | ||
beforeEndMarker = -1 | ||
} | ||
|
||
minBreaks = 1 | ||
} | ||
] | ||
} | ||
|
||
project { | ||
excludeFilters = [ | ||
".metals" | ||
] | ||
} | ||
|
||
rewrite { | ||
redundantBraces { | ||
ifElseExpressions = yes | ||
} | ||
|
||
rules = [ | ||
PreferCurlyFors | ||
RedundantBraces | ||
RedundantParens | ||
SortModifiers | ||
] | ||
|
||
scala3 { | ||
convertToNewSyntax = yes | ||
removeEndMarkerMaxLines = 28 | ||
removeOptionalBraces = oldSyntaxToo | ||
} | ||
|
||
sortModifiers { | ||
order = [ | ||
inline | ||
final | ||
sealed | ||
abstract | ||
override | ||
implicit | ||
private | ||
protected | ||
lazy | ||
infix | ||
] | ||
} | ||
} | ||
|
||
rewriteTokens { | ||
"⇒" = "=>" | ||
"→" = "->" | ||
"←" = "<-" | ||
} | ||
|
||
runner { | ||
# https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects | ||
dialect = scala3 | ||
} | ||
|
||
spaces { | ||
inImportCurlyBraces = yes | ||
} | ||
|
||
trailingCommas = multiple | ||
|
||
verticalMultiline { | ||
arityThreshold = 3 | ||
atDefnSite = yes | ||
newlineAfterOpenParen = yes | ||
} |
6 changes: 6 additions & 0 deletions
6
01-core/src/main/scala/dev/insideyou/play3/usecase1/Boundary.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package dev.insideyou | ||
package play3 | ||
package usecase1 | ||
|
||
trait Boundary: | ||
def currentTime: UIO[LocalTime] |
9 changes: 9 additions & 0 deletions
9
01-core/src/main/scala/dev/insideyou/play3/usecase1/BusinessLogic.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dev.insideyou | ||
package play3 | ||
package usecase1 | ||
|
||
object BusinessLogic: | ||
lazy val make: Boundary = | ||
new: | ||
override lazy val currentTime = | ||
ZIO.succeed(java.time.LocalTime.now.nn) |
5 changes: 5 additions & 0 deletions
5
01-core/src/main/scala/dev/insideyou/play3/usecase1/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package dev.insideyou | ||
package play3 | ||
package usecase1 | ||
|
||
export java.time.LocalTime |
8 changes: 8 additions & 0 deletions
8
01-core/src/test/scala/dev/insideyou/play3/ExampleSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dev.insideyou | ||
package play3 | ||
|
||
final class ExampleSuite extends TestSuite: | ||
test("hello world"): | ||
forAll: (int: Int, string: String) => | ||
expectEquals(int, int) | ||
expectEquals(string, string) |
72 changes: 72 additions & 0 deletions
72
01-core/src/test/scala/dev/insideyou/play3/Expectations.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package dev.insideyou | ||
package play3 | ||
|
||
import scala.Console.* | ||
|
||
import com.eed3si9n.expecty.Expecty | ||
import munit.internal.console.StackTraces.dropInside | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.All")) | ||
trait Expectations: | ||
this: munit.FunSuite => | ||
inline def expect( | ||
inline cond: Boolean, | ||
clue: => Any = "assertion failed", | ||
)(using | ||
loc: munit.Location | ||
): Unit = | ||
lazy val calculatedClue = | ||
val expectyClue = | ||
try { Expecty.assert(cond); "" } | ||
catch Expectations.ExtractMessage | ||
|
||
if expectyClue.isEmpty then s"$RED\n$clue$RESET" | ||
else s"$RED\n$clue\n$expectyClue$RESET" | ||
|
||
assert(cond, calculatedClue) | ||
|
||
def expectEquals[A, B]( | ||
obtained: A, | ||
expected: B, | ||
clue: => Any = "values are not the same", | ||
)(using | ||
loc: munit.Location, | ||
ev: B <:< A, | ||
): Unit = | ||
lazy val calculatedClue = | ||
val expectyClue = | ||
try { Expecty.assert(obtained == expected); "" } | ||
catch Expectations.ExtractMessage | ||
|
||
if expectyClue.isEmpty then s"$RED\n$clue$RESET" | ||
else s"$RED\n$clue\n$expectyClue$RESET" | ||
|
||
assertEquals(obtained, expected, calculatedClue) | ||
|
||
def expectNotEquals[A, B]( | ||
obtained: A, | ||
expected: B, | ||
clue: => Any = "values are the same", | ||
)(using | ||
loc: munit.Location, | ||
ev: A =:= B, | ||
): Unit = | ||
lazy val calculatedClue = | ||
val expectyClue = | ||
try { Expecty.assert(obtained != expected); "" } | ||
catch Expectations.ExtractMessage | ||
|
||
val clueWithSuffix = | ||
s"${munitPrint(clue)} expected same: $expected was not: $obtained" | ||
|
||
if expectyClue.isEmpty then clueWithSuffix | ||
else s"$RED\n$clueWithSuffix\n$expectyClue$RESET" | ||
|
||
dropInside(if obtained == expected then failComparison(calculatedClue, obtained, expected)) | ||
|
||
object Expectations: | ||
private val ExtractMessage: PartialFunction[Throwable, String] = | ||
case e: AssertionError => | ||
// it's in a try/catch because of .nn | ||
try e.getMessage.nn.split("\n").nn.slice(2, Int.MaxValue).mkString("\n", "\n", "\n") | ||
catch case scala.util.control.NonFatal(_) => "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dev.insideyou | ||
package play3 | ||
|
||
export org.scalacheck.Arbitrary | ||
export org.scalacheck.Cogen | ||
export org.scalacheck.Gen | ||
|
||
trait TestSuite extends munit.DisciplineSuite, Expectations |
7 changes: 7 additions & 0 deletions
7
02-delivery/app/controllers/dev/insideyou/play3/FancyController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dev.insideyou | ||
package play3 | ||
|
||
trait FancyController( | ||
using | ||
override protected val controllerComponents: ControllerComponents | ||
) extends BaseController |
Oops, something went wrong.