Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ test-output/*
project/project/
generatedFiles/
test-output/
.bloop
.vscode/
metals.sbt
.metals
.bsp
.DS_Store
58 changes: 58 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version = "3.7.12"
runner.dialect = scala213

style = defaultWithAlign
maxColumn = 120
align = most

continuationIndent.defnSite = 2
align.arrowEnumeratorGenerator = true
align.openParenCallSite = false
align.openParenDefnSite = false

assumeStandardLibraryStripMargin = true
align.stripMargin = true

danglingParentheses.defnSite = true
danglingParentheses.callSite = true
danglingParentheses.exclude = [class, trait, enum, def]

docstrings.style = Asterisk
docstrings.wrap = "no"
docstrings.forceBlankLineBefore = true

rewrite.rules = [RedundantBraces, RedundantParens, SortImports, PreferCurlyFors, SortModifiers]
rewrite.redundantBraces.includeUnitMethods = true
rewrite.redundantBraces.stringInterpolation = true
rewrite.redundantBraces.methodBodies = false

rewrite.imports.sort = ascii
rewrite.imports.groups = [
["javax?\\..*"]
["org\\..*"]
["com\\..*"]
["scala\\..*"]
["io\\..*", "cats\\..*"]
["scala\\.concurrent\\..*"]
]

rewrite.sortModifiers {
order = [
override
private
protected
final
sealed
abstract
lazy
implicit
]
}

rewrite.trailingCommas.style = "never"

newlines.topLevelStatementBlankLines = [
{
blanks { before = 1 }
}
]
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jdk:
- openjdk8

scala:
- 2.11.12
- 2.12.10
- 2.12.18
- 2.13.11

script:
- sbt clean coverage test
Expand Down
60 changes: 30 additions & 30 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import sbt.Keys._

scalaVersion := "2.13.5"
scalaVersion := "2.13.11"

crossScalaVersions := Seq("2.12.10", "2.13.5")
crossScalaVersions := Seq("2.12.18", "2.13.11", "3.3.0")

scalacOptions += "-target:jvm-1.8"

name := "fabricator"

version := "2.1.9"
version := "2.2.0"

organization := "com.github.azakordonets"

licenses +=("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html"))
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html"))

homepage := Some(url("https://github.com/azakordonets/fabricator"))

Expand All @@ -23,25 +23,28 @@ publishMavenStyle := true
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

credentials += Credentials("Sonatype Nexus Repository Manager",
credentials += Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
sys.props.getOrElse("SONATYPE_USERNAME", default = "biercoff"),
sys.props.getOrElse("SONATYPE_PASSWORD", default = "not_found"))
sys.props.getOrElse("SONATYPE_PASSWORD", default = "not_found")
)

publishArtifact in Test := false
Test / publishArtifact := false

pomIncludeRepository := { _ => false}
pomIncludeRepository := { _ => false }

unmanagedResourceDirectories in Compile += {
Compile / unmanagedResourceDirectories += {
baseDirectory.value / "src/main/resources"
}

fork in Test := true
Test / fork := true

pomExtra :=
<developers>
<developer>
Expand All @@ -51,7 +54,7 @@ pomExtra :=
</developer>
</developers>

coverageMinimum := 70
coverageMinimumStmtTotal := 70

coverageFailOnMinimum := true

Expand All @@ -68,21 +71,18 @@ resolvers += Classpaths.sbtPluginReleases
resolvers += Resolver.typesafeRepo("releases")

libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.10.0-RC2",
"org.scalatestplus" %% "testng-6-7" % "3.2.5.0" % "test",
"com.github.nscala-time" %% "nscala-time" % "2.26.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
"org.reflections" % "reflections" % "0.9.12",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"org.assertj" % "assertj-core" % "3.19.0",
"com.spatial4j" % "spatial4j" % "0.5",
"org.iban4j" % "iban4j" % "3.2.2-RELEASE",
"commons-validator" % "commons-validator" % "1.7",
"com.google.inject" % "guice" % "5.0.1",
"com.github.tototoshi" %% "scala-csv" % "1.3.7",
"com.google.zxing" % "core" % "3.4.1",
"io.github.classgraph" % "classgraph" % "4.8.102"
"com.typesafe.play" %% "play-json" % "2.10.0-RC9",
"org.scalatestplus" %% "testng-7-5" % "3.2.16.0" % "test",
"com.github.nscala-time" %% "nscala-time" % "2.32.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4",
"org.reflections" % "reflections" % "0.9.12",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"org.assertj" % "assertj-core" % "3.19.0",
"com.spatial4j" % "spatial4j" % "0.5",
"org.iban4j" % "iban4j" % "3.2.2-RELEASE",
"commons-validator" % "commons-validator" % "1.7",
"com.google.inject" % "guice" % "5.0.1",
"com.github.tototoshi" %% "scala-csv" % "1.3.10",
"com.google.zxing" % "core" % "3.4.1",
"io.github.classgraph" % "classgraph" % "4.8.102"
)



2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.7
sbt.version=1.9.3
23 changes: 16 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@ resolvers += Classpaths.sbtPluginReleases

resolvers += Classpaths.typesafeReleases

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("org.scoverage" %% "sbt-coveralls" % "1.2.7")
// these plugins trigger 'java.lang.AssertionError: NoDenotation.owner while compiling ...'
// when compile java and scala sources
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8")
addSbtPlugin("org.scoverage" %% "sbt-coveralls" % "1.3.11")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")

// Add the following to have Git manage your build versions
resolvers += "jgit-repo" at "https://download.eclipse.org/jgit/maven"
resolvers += Resolver.url("scoverage-bintray", url("https://dl.bintray.com/sksamuel/sbt-plugins/"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
resolvers += Resolver.url("scoverage-bintray", url("https://dl.bintray.com/sksamuel/sbt-plugins/"))(
Resolver.ivyStylePatterns
)

addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")

ThisBuild / libraryDependencySchemes ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)
43 changes: 27 additions & 16 deletions src/main/scala/fabricator/Alphanumeric.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ case class Alphanumeric(private val random: Random = new Random()) {
(min to max by step toList).asJava

}

def randomIntsRange(min: Int, max: Int, step: Int): List[Int] = {
if (step <= 0) throw new IllegalArgumentException("Step should be more then 0")
min to max by step toList
Expand All @@ -35,7 +36,6 @@ case class Alphanumeric(private val random: Random = new Random()) {

def randomLong(min: Long, max: Long): Long = min + (Math.random() * (max - min)).toLong


def randomLongsRange(min: Long, max: Long, step: Long): List[Long] = {
if (step <= 0) throw new IllegalArgumentException("Step should be more then 0")
min to max by step toList
Expand All @@ -53,7 +53,7 @@ case class Alphanumeric(private val random: Random = new Random()) {

def randomDoublesRangeAsJavaList(min: Double, max: Double, step: Double): java.util.List[Double] = {
if (step <= 0) throw new IllegalArgumentException("Step should be more then 0")
((BigDecimal(min) to BigDecimal(max) by step).map(_.toDouble).toList).asJava
(BigDecimal(min) to BigDecimal(max) by step).map(_.toDouble).toList.asJava
}

def randomDoublesRange(min: Double, max: Double, step: Double): List[Double] = {
Expand All @@ -69,12 +69,12 @@ case class Alphanumeric(private val random: Random = new Random()) {

def randomFloatsRangeAsJavaList(min: Float, max: Float, step: Float): java.util.List[Float] = {
if (step <= 0) throw new IllegalArgumentException("Step should be more then 0")
((BigDecimal(min) to BigDecimal(max) by step).map(_.toFloat).toList).asJava
(BigDecimal(min) to BigDecimal(max) by BigDecimal(step)).map(_.toFloat).toList.asJava
}

def randomFloatsRange(min: Float, max: Float, step: Float): List[Float] = {
if (step <= 0) throw new IllegalArgumentException("Step should be more then 0")
(BigDecimal(min) to BigDecimal(max) by step).map(_.toFloat).toList
(BigDecimal(min) to BigDecimal(max) by BigDecimal(step)).map(_.toFloat).toList
}

def randomBoolean: Boolean = random.nextBoolean()
Expand All @@ -88,23 +88,26 @@ case class Alphanumeric(private val random: Random = new Random()) {
def randomStringsAsJavaList: util.List[String] = randomStrings(5, 100, 100).asJava

def randomStrings(minLength: Int, maxLength: Int, amount: Int): List[String] = {
if (minLength != maxLength )List.fill(amount)(randomString(randomInt(minLength, maxLength))) else
if (minLength != maxLength) List.fill(amount)(randomString(randomInt(minLength, maxLength)))
else
List.fill(amount)(randomString(minLength))
}

def randomStringsAsJavaList(minLength: Int, maxLength: Int, amount: Int): java.util.List[String] = {
if (minLength != maxLength )List.fill(amount)(randomString(randomInt(minLength, maxLength))).asJava else
if (minLength != maxLength) List.fill(amount)(randomString(randomInt(minLength, maxLength))).asJava
else
List.fill(amount)(randomString(minLength)).asJava
}

def randomString(length: Int): String = randomString("0123456789abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_", length)
def randomString(length: Int): String =
randomString("0123456789abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_", length)

def randomString(charSeq: String, max: Int): String = string(charSeq, max)

private def string(charsSequence: String, max: Int): String = {
val builder = new StringBuilder
(0 until max).foreach {
_ => builder.append(charsSequence.charAt(random.nextInt(charsSequence.length - 1)))
(0 until max).foreach { _ =>
builder.append(charsSequence.charAt(random.nextInt(charsSequence.length - 1)))
}
builder.toString()
}
Expand All @@ -113,24 +116,26 @@ case class Alphanumeric(private val random: Random = new Random()) {

def randomHash(length: Int): String = string("0123456789abcdef", length)

def randomHashList: List[String] = randomHashList(40,40, 100)
def randomHashList: List[String] = randomHashList(40, 40, 100)

def randomHashList(minLength: Int, maxLength: Int, amount: Int): List[String] = {
if (minLength != maxLength )List.fill(amount)(randomHash(randomInt(minLength, maxLength))) else
if (minLength != maxLength) List.fill(amount)(randomHash(randomInt(minLength, maxLength)))
else
List.fill(amount)(randomHash(minLength))
}

def randomHashAsJavaList: util.List[String] = randomHashList(40,40, 100).asJava
def randomHashAsJavaList: util.List[String] = randomHashList(40, 40, 100).asJava

def randomHashAsJavaList(minLength: Int, maxLength: Int, amount: Int): util.List[String] = {
if (minLength != maxLength )List.fill(amount)(randomHash(randomInt(minLength, maxLength))).asJava else
if (minLength != maxLength) List.fill(amount)(randomHash(randomInt(minLength, maxLength))).asJava
else
List.fill(amount)(randomHash(minLength)).asJava
}

def randomGuid: String = randomGuid(5)

def randomGuid(version: Int): String = {
val guidPool = "abcdef1234567890"
val guidPool = "abcdef1234567890"
val variantPool = "ab89"
string(guidPool, 8) + "-" +
string(guidPool, 4) + "-" +
Expand Down Expand Up @@ -158,7 +163,10 @@ case class Alphanumeric(private val random: Random = new Random()) {
def botifyAsJavaList(pattern: String, amount: Int): util.List[String] = botifyList(pattern, amount).asJava

def numerify(pattern: String): String = {
pattern.map { case '#' => random.nextInt(10).toString case letter => letter}.mkString
pattern.map {
case '#' => random.nextInt(10).toString
case letter => letter
}.mkString
}

def numerifyList(pattern: String, amount: Int): List[String] = List.fill(amount)(numerify(pattern))
Expand All @@ -167,7 +175,10 @@ case class Alphanumeric(private val random: Random = new Random()) {

def letterify(pattern: String): String = {
val chars = ('a' to 'z') ++ ('A' to 'Z')
pattern.map { case '?' => chars(random.nextInt(chars.length)) case letter => letter}.mkString
pattern.map {
case '?' => chars(random.nextInt(chars.length))
case letter => letter
}.mkString
}

def letterifyList(pattern: String, amount: Int): List[String] = List.fill(amount)(letterify(pattern))
Expand Down
Loading