From 29ce490e8e732f8c98781810254f0547e7a9bbb9 Mon Sep 17 00:00:00 2001 From: philippus Date: Mon, 25 Sep 2023 20:24:06 +0200 Subject: [PATCH] Update scalafmt settings and run scalafmt --- .scalafmt.conf | 10 ++++ build.sbt | 12 ++-- .../sbtdotenv/DirtyEnvironmentHack.scala | 42 ++++++-------- .../au/com/onegeek/sbtdotenv/SbtDotenv.scala | 45 +++++++-------- .../onegeek/sbtdotenv/VariableExpansion.scala | 37 ++++++------ .../com/onegeek/sbtdotenv/SbtDotenvSpec.scala | 33 +++++------ .../sbtdotenv/VariableExpansionSpec.scala | 56 +++++++++---------- 7 files changed, 108 insertions(+), 127 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index a306a4b..a369c33 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,3 +1,13 @@ version = 3.7.14 +align.preset = most +literals.double = Upper +literals.float = Upper +maxColumn = 120 +newlines.source = keep +rewriteTokens = { + "⇒": "=>" + "→": "->" + "←": "<-" +} runner.dialect = scala212 diff --git a/build.sbt b/build.sbt index 455d79e..1cc5a95 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ -name := "sbt-dotenv" -organization := "nl.gn0s1s" -description := "An sbt plugin to load environment variables from .env into the JVM System Environment for local development. Assists with 'Twelve Factor App' development principle 3 'Store config in the environment'." -startYear := Some(2014) -homepage := Some(url("https://github.com/philippus/sbt-dotenv")) +name := "sbt-dotenv" +organization := "nl.gn0s1s" +description := "An sbt plugin to load environment variables from .env into the JVM System Environment for local development. Assists with 'Twelve Factor App' development principle 3 'Store config in the environment'." +startYear := Some(2014) +homepage := Some(url("https://github.com/philippus/sbt-dotenv")) licenses += ("MIT" -> url("http://opensource.org/licenses/MIT")) developers := List( @@ -21,7 +21,7 @@ developers := List( ) enablePlugins(SbtPlugin) -sbtPlugin := true +sbtPlugin := true pluginCrossBuild / sbtVersion := "1.3.9" // minimum version we target because of using Native.load, see https://github.com/Philippus/sbt-dotenv/issues/81 libraryDependencies ++= Seq( diff --git a/src/main/scala/au/com/onegeek/sbtdotenv/DirtyEnvironmentHack.scala b/src/main/scala/au/com/onegeek/sbtdotenv/DirtyEnvironmentHack.scala index 14f5bdd..36028ac 100644 --- a/src/main/scala/au/com/onegeek/sbtdotenv/DirtyEnvironmentHack.scala +++ b/src/main/scala/au/com/onegeek/sbtdotenv/DirtyEnvironmentHack.scala @@ -2,23 +2,18 @@ * * Copyright (c) 2014 Matt Fellows (OneGeek) * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the + * Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package au.com.onegeek.sbtdotenv @@ -28,8 +23,7 @@ import scala.util.control.NonFatal /** Rewrite the runtime Environment, embedding entries from the .env file. * - * Taken from: - * http://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java/7201825#7201825 + * Taken from: http://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java/7201825#7201825 * * Created by mfellows on 20/07/2014. */ @@ -42,7 +36,7 @@ object DirtyEnvironmentHack { val theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment") theEnvironmentField.setAccessible(true) - val env = theEnvironmentField + val env = theEnvironmentField .get(null) .asInstanceOf[java.util.Map[String, String]] // scalastyle:off null env.putAll(newEnv) @@ -52,7 +46,7 @@ object DirtyEnvironmentHack { "theCaseInsensitiveEnvironment" ) theCaseInsensitiveEnvironmentField.setAccessible(true) - val ciEnv = theCaseInsensitiveEnvironmentField + val ciEnv = theCaseInsensitiveEnvironmentField .get(null) .asInstanceOf[java.util.Map[String, String]] // scalastyle:off null ciEnv.putAll(newEnv) @@ -60,13 +54,13 @@ object DirtyEnvironmentHack { case Failure(_: NoSuchFieldException) => Try({ val classes = classOf[Collections].getDeclaredClasses - val env = System.getenv + val env = System.getenv classes .filter(_.getName == "java.util.Collections$UnmodifiableMap") .foreach(cl => { val field = cl.getDeclaredField("m") field.setAccessible(true) - val map = + val map = field.get(env).asInstanceOf[java.util.Map[String, String]] map.clear() map.putAll(newEnv) @@ -74,11 +68,11 @@ object DirtyEnvironmentHack { }) match { case Failure(NonFatal(e2)) => e2.printStackTrace() - case Success(_) => + case Success(_) => } - case Failure(NonFatal(e1)) => + case Failure(NonFatal(e1)) => e1.printStackTrace() - case Success(_) => + case Success(_) => } } } diff --git a/src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala b/src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala index 1010171..e2b4038 100644 --- a/src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala +++ b/src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala @@ -2,23 +2,18 @@ * * Copyright (c) 2014 Matt Fellows (OneGeek) * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the + * Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package au.com.onegeek.sbtdotenv @@ -28,17 +23,16 @@ import sbt._ import scala.collection.JavaConverters._ import scala.io.Source -/** sbt-dotenv - a dotenv (https://github.com/bkeepers/dotenv) implementation - * for Scala sbt. +/** sbt-dotenv - a dotenv (https://github.com/bkeepers/dotenv) implementation for Scala sbt. * * Reads a file */ object SbtDotenv extends AutoPlugin { object autoImport { - lazy val envFileName = + lazy val envFileName = settingKey[String]("The file name to define variables.") - lazy val envFromFile = + lazy val envFromFile = taskKey[Map[String, String]]("Loads env configuration from file.") def dotEnv(fileName: String) = (s: State) => configureEnvironment(s, fileName) @@ -55,7 +49,7 @@ object SbtDotenv extends AutoPlugin { // Automatically configure environment on load override lazy val buildSettings = Seq( - envFileName := ".env", + envFileName := ".env", Global / onLoad := dotEnv((ThisBuild / envFileName).value) .compose((Global / onLoad).value) ) @@ -83,8 +77,8 @@ object SbtDotenv extends AutoPlugin { state: State, fileName: String ): Option[Map[String, String]] = { - val baseDirectory = state.configuration.baseDirectory - val filePath = + val baseDirectory = state.configuration.baseDirectory + val filePath = if (fileName.startsWith("/")) fileName else s"${baseDirectory}/${fileName}" state.log.debug(s"Base directory: ${baseDirectory}") @@ -117,8 +111,7 @@ object SbtDotenv extends AutoPlugin { state } - /** Parse provided file in .env format and return an immutable environment - * Map[String, String] + /** Parse provided file in .env format and return an immutable environment Map[String, String] * * @param file * .env file to read @@ -171,11 +164,11 @@ object SbtDotenv extends AutoPlugin { private def removeQuotes(value: String): String = { value.trim match { - case quoted if quoted.startsWith("'") && quoted.endsWith("'") => + case quoted if quoted.startsWith("'") && quoted.endsWith("'") => quoted.substring(1, quoted.length - 1) case quoted if quoted.startsWith("\"") && quoted.endsWith("\"") => quoted.substring(1, quoted.length - 1) - case unquoted => unquoted + case unquoted => unquoted } } diff --git a/src/main/scala/au/com/onegeek/sbtdotenv/VariableExpansion.scala b/src/main/scala/au/com/onegeek/sbtdotenv/VariableExpansion.scala index 8c97d92..3544d4b 100644 --- a/src/main/scala/au/com/onegeek/sbtdotenv/VariableExpansion.scala +++ b/src/main/scala/au/com/onegeek/sbtdotenv/VariableExpansion.scala @@ -2,23 +2,18 @@ * * Copyright (c) 2014 Matt Fellows (OneGeek) * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the + * Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package au.com.onegeek.sbtdotenv @@ -31,8 +26,8 @@ object VariableExpansion { /** Expand variables in the second map based on values in the first. * - * This recognises variables of the form "$$FOO" and "$${FOO}", and supports - * multiple levels of reference and nesting (up to 3 times). + * This recognises variables of the form "$$FOO" and "$${FOO}", and supports multiple levels of reference and nesting + * (up to 3 times). * @param defns * Key/value map that will be used to expand any variable references * @param vars @@ -77,9 +72,9 @@ object VariableExpansion { // $ and {} pair containing at least one character of anything but } // private val variableRegex: Regex = { - val start = "(?<=^|[^$])" + val start = "(?<=^|[^$])" val braceless = "\\$([^{\\$]+?)\\b" - val braces = "\\$\\{([^\\}\\$]+)\\}" + val braces = "\\$\\{([^\\}\\$]+)\\}" s"$start(?:$braceless|$braces)".r } @@ -91,8 +86,8 @@ object VariableExpansion { private def expandVarsInValue(defns: Env, value: String): String = { val replaceMatch: (Regex.Match => String) = m => { - val lookup = defns.get(variableName(m)) - val fallback = m.matched + val lookup = defns.get(variableName(m)) + val fallback = m.matched val replacement = lookup.getOrElse(fallback) Matcher.quoteReplacement(replacement) diff --git a/src/test/scala/au/com/onegeek/sbtdotenv/SbtDotenvSpec.scala b/src/test/scala/au/com/onegeek/sbtdotenv/SbtDotenvSpec.scala index f29b972..77bbc84 100644 --- a/src/test/scala/au/com/onegeek/sbtdotenv/SbtDotenvSpec.scala +++ b/src/test/scala/au/com/onegeek/sbtdotenv/SbtDotenvSpec.scala @@ -2,23 +2,18 @@ * * Copyright (c) 2014 Matt Fellows (OneGeek) * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the + * Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package au.com.onegeek.sbtdotenv @@ -32,7 +27,7 @@ class SbtDotenvSpec extends AnyWordSpec with Matchers { "The plugin parser" should { "do nothing if no .env file exists" in { val file = new File("thisfilecannotexistunlessyoucreateit") - val map = SbtDotenv.parseFile(file) + val map = SbtDotenv.parseFile(file) map should equal(None) } @@ -42,10 +37,10 @@ class SbtDotenvSpec extends AnyWordSpec with Matchers { SbtDotenv.parseFile(file) should equal( Some( Map( - "EMPTY_VARIABLE" -> "", - "MONGO_PORT" -> "17017", + "EMPTY_VARIABLE" -> "", + "MONGO_PORT" -> "17017", "COVERALLS_REPO_TOKEN" -> "aoeucaPDc2rvkFugUGlNaCGu3EOeoaeu63WLo5", - "MONGO_URL" -> "http://localhost:$MONGO_PORT/mongo#asdf" + "MONGO_URL" -> "http://localhost:$MONGO_PORT/mongo#asdf" ) ) ) diff --git a/src/test/scala/au/com/onegeek/sbtdotenv/VariableExpansionSpec.scala b/src/test/scala/au/com/onegeek/sbtdotenv/VariableExpansionSpec.scala index 67beb70..6f189cc 100644 --- a/src/test/scala/au/com/onegeek/sbtdotenv/VariableExpansionSpec.scala +++ b/src/test/scala/au/com/onegeek/sbtdotenv/VariableExpansionSpec.scala @@ -1,25 +1,19 @@ /** The MIT License (MIT) * - * Copyright (c) 2014 Matt Fellows (OneGeek) Copyright (c) 2018 Edd Steel - * (eddsteel) + * Copyright (c) 2014 Matt Fellows (OneGeek) Copyright (c) 2018 Edd Steel (eddsteel) * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the + * Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package au.com.onegeek.sbtdotenv @@ -33,10 +27,10 @@ class VariableExpansionSpec extends AnyWordSpec with Matchers { "expand variables in values" in { VariableExpansion.expandAllVars( Map("USER_NAME" -> "alice"), - Map("DB_USER" -> "$USER_NAME-") + Map("DB_USER" -> "$USER_NAME-") ) should equal(Map("DB_USER" -> "alice-")) VariableExpansion.expandAllVars( - Map("USER" -> "bob"), + Map("USER" -> "bob"), Map("CONSUMER_GROUP" -> "consumer-${USER}") ) should equal(Map("CONSUMER_GROUP" -> "consumer-bob")) } @@ -56,7 +50,7 @@ class VariableExpansionSpec extends AnyWordSpec with Matchers { VariableExpansion.expandAllVars( Map("LEVEL" -> "ONE", "LEVEL_ONE" -> "LEVEL_TWO"), - Map("NEST" -> "${LEVEL_$LEVEL}") + Map("NEST" -> "${LEVEL_$LEVEL}") ) should equal(Map("NEST" -> "LEVEL_TWO")) } @@ -69,18 +63,18 @@ class VariableExpansionSpec extends AnyWordSpec with Matchers { "dereference up to 3 times" in { val defns = Map( - "TOE_BONE" -> "${FOOT_BONE}", - "FOOT_BONE" -> "${HEEL_BONE}", - "HEEL_BONE" -> "${ANKLE_BONE}", - "ANKLE_BONE" -> "SHIN_BONE", - "LOOP" -> "${LOOP}", - "PING" -> "${PONG}", - "PONG" -> "$PING", - "YOU" -> "I", - "CAN_I_GO" -> "IS_SUPPORTED", - "DEEP_IS_SUPPORTED" -> "DEEP_IS_YOUR_STACK", + "TOE_BONE" -> "${FOOT_BONE}", + "FOOT_BONE" -> "${HEEL_BONE}", + "HEEL_BONE" -> "${ANKLE_BONE}", + "ANKLE_BONE" -> "SHIN_BONE", + "LOOP" -> "${LOOP}", + "PING" -> "${PONG}", + "PONG" -> "$PING", + "YOU" -> "I", + "CAN_I_GO" -> "IS_SUPPORTED", + "DEEP_IS_SUPPORTED" -> "DEEP_IS_YOUR_STACK", "HOW_DEEP_IS_YOUR_STACK" -> "3", - "NEST" -> "${HOW_${DEEP_${CAN_${YOU}_GO}}}" + "NEST" -> "${HOW_${DEEP_${CAN_${YOU}_GO}}}" ) VariableExpansion.expandAllVars( defns,