Skip to content

Commit

Permalink
Apply feedback to code.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukaby committed Apr 4, 2015
1 parent 11aeee7 commit 4575ab4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import org.scalatra.ScalatraBase
trait EnvFeature extends ScalatraBase {

/**
* Env string value from "skinny.env", "org.scalatra.environment" or default value "development".
* Env string value from "skinny.env" or "org.scalatra.environment".
*
* @return env string such as "production"
*/
// Skinny is unified lower case. Therefore, convert to lower case.
def skinnyEnv: Option[String] = SkinnyEnv.get().orElse(Option(environment.toLowerCase))

def skinnyEnv: Option[String] = SkinnyEnv.get().orElse {
// convert upper cased "org.scalatra.environment" (e.g. DEVELOPMENT) to skinny's style here
Option(environment).map(_.toLowerCase(java.util.Locale.ENGLISH))
}
/**
* Predicates current env is "development" or "dev".
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class EnvFeatureSpec extends FlatSpec with Matchers {
}
}

it should "Scalatra default value should be converted to lower case" in {
it should "convert the default value of Scalatra's environment to lower cased one" in {
class Controller extends SkinnyApiController {
skinnyEnv should equal(Option("development"))
skinnyEnv should equal(Some("development"))
}
}

Expand Down

0 comments on commit 4575ab4

Please sign in to comment.