Skip to content

Commit

Permalink
Merge pull request #370 from matt-wittmann/feature/file-chained-formats
Browse files Browse the repository at this point in the history
Supporting multiple formats on file and directory names
  • Loading branch information
eed3si9n authored Jul 12, 2018
2 parents 624e8c2 + 6b556c8 commit 7be0a57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/src/main/scala/g8.scala
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ object G8 {
throw t
}

private def formatize(s: String) = s.replaceAll("""\$(\w+)__(\w+)\$""", """\$$1;format="$2"\$""")
private def formatize(s: String) = s.replaceAll("""\$(\w+)__([\w,]+)\$""", """\$$1;format="$2"\$""")

def decapitalize(s: String) = if (s.isEmpty) s else s(0).toLower + s.substring(1)
def startCase(s: String) = s.toLowerCase.split(" ").map(_.capitalize).mkString(" ")
Expand Down
10 changes: 10 additions & 0 deletions library/src/test/scala/giter8/IntegrationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ class IntegrationTest extends FlatSpec with IntegrationTestHelpers with Matchers
checkGeneratedProject(template, expected, actual)
}

it should "apply multiple filters to files and directories" in testCase {
case (template, expected, actual) =>
"""
| test = Foo Bar
""".stripMargin >> (template / "src" / "main" / "g8" / "default.properties")
"""$test;format="lower,word"$""" >> (template / "src" / "main" / "g8" / """$test__lower,word$""" / """$test__lower,word$""")
"foobar" >> (expected / "foobar" / "foobar")
checkGeneratedProject(template, expected, actual)
}

private def testCase(test: (File, File, File) => Unit): Unit = {
tempDirectory { tmp =>
val templateDir = mkdir(tmp / "template")
Expand Down

0 comments on commit 7be0a57

Please sign in to comment.