Skip to content

Commit 166d6b1

Browse files
committed
1st step
1 parent f0f9d03 commit 166d6b1

File tree

110 files changed

+1155
-957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1155
-957
lines changed

build.sbt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
val scala211 = "2.11.12"
3+
val scala212 = "2.12.12"
4+
val scala213 = "2.13.3"
5+
6+
val cucumberVersion = "6.8.2"
7+
val jacksonVersion = "2.11.3"
8+
val mockitoScalaVersion = "1.16.0"
9+
val junitVersion = "4.13.1"
10+
11+
lazy val commonSettings = Seq(
12+
organization := "io.cucumber",
13+
scalaVersion := scala213,
14+
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test
15+
)
16+
17+
lazy val root = project
18+
.in(file("."))
19+
.settings(commonSettings)
20+
.aggregate(
21+
cucumberScala,
22+
examples
23+
)
24+
25+
lazy val cucumberScala = project
26+
.in(file("cucumber-scala"))
27+
.settings(commonSettings)
28+
.settings(
29+
name := "cucumber-scala",
30+
libraryDependencies ++= Seq(
31+
"io.cucumber" % "cucumber-core" % cucumberVersion,
32+
33+
// Users have to provide it (for JacksonDefaultDataTableTransformer)
34+
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion % Provided,
35+
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion % Provided,
36+
37+
"junit" % "junit" % junitVersion % Test,
38+
"io.cucumber" % "cucumber-junit" % cucumberVersion % Test,
39+
"org.mockito" %% "mockito-scala" % mockitoScalaVersion % Test
40+
)
41+
)
42+
43+
lazy val examples = project
44+
.in(file("examples"))
45+
.settings(commonSettings)
46+
.settings(
47+
name := "scala-examples",
48+
libraryDependencies ++= Seq(
49+
"io.cucumber" % "cucumber-junit" % cucumberVersion % Test,
50+
"junit" % "junit" % junitVersion % Test
51+
)
52+
)
53+
.dependsOn(cucumberScala % Test)
54+
55+
// TODO cross build
56+
57+
// TODO code generation for i18n
58+
59+
// TODO scla compiler flags
60+
61+
// TODO OSS publish settings
62+
// But not the examples
63+
64+
// TODO src jar ?
65+
// TODO javadoc jar
File renamed without changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Generates the I18n.scala file.
3+
*/
4+
5+
import io.cucumber.gherkin.GherkinDialectProvider
6+
7+
import scala.jdk.CollectionConverters._
8+
9+
val dialectProvider = new GherkinDialectProvider()
10+
11+
val unsupported = Seq("em")
12+
val allLanguages = dialectProvider.getLanguages().asScala.filterNot(l => unsupported.contains(l))
13+
14+
def keywordVal(kw: String): String = {
15+
val keyworkValName = java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)
16+
s"""val $keyworkValName = new Step("$keyworkValName")"""
17+
}
18+
19+
def traitCode(language: String): String = {
20+
val traitName = language.replaceAll("[\\s-]", "_").toUpperCase()
21+
val keywords = dialectProvider
22+
.getDialect(language, null).getStepKeywords()
23+
.asScala
24+
.filter(kw => !kw.contains('*') && !kw.matches("^\\d.*"))
25+
.sorted
26+
.distinct
27+
28+
s"""
29+
|trait $traitName {
30+
| this: ScalaDsl =>
31+
|${keywords.map(kw => keywordVal(kw)).mkString("\n\n")}
32+
|}
33+
|""".stripMargin
34+
}
35+
36+
val i18n = s"""
37+
|package io.cucumber.scala
38+
|
39+
|${allLanguages.map(l => traitCode(l)).mkString("\n\n")}
40+
|""".stripMargin
41+
42+
println(i18n)

0 commit comments

Comments
 (0)