Skip to content
This repository was archived by the owner on Aug 17, 2019. It is now read-only.

Commit f01f93c

Browse files
committed
Using converters
1 parent aa05c4e commit f01f93c

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

Diff for: project/build.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
project.organization=com.ckkloverdos
44
project.name=sysprop
55
sbt.version=0.7.7
6-
project.version=0.1.0
6+
project.version=0.2.0-SNAPSHOT
77
publish.remote=false
8-
build.scala.versions=2.9.1 2.8.2 2.8.1
8+
build.scala.versions=2.9.1
99
project.initialize=false

Diff for: project/build/SysProp.scala

+3-11
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,12 @@ class SysProp(info: ProjectInfo) extends DefaultProject(info) {
5656
<developer>
5757
<id>loverdos</id>
5858
<name>Christos KK Loverdos</name>
59+
<email>loverdos@gmail.com</email>
5960
</developer>
6061
</developers>;
6162

62-
// val lib_slf4j = "org.slf4j" % "slf4j-api" % "1.6.1" % "compile" withSources()
63-
// val lib_logback_simple = "ch.qos.logback" % "logback-classic" % "0.9.28" % "test" withSources()
64-
// val lib_junit_interface = "com.novocode" % "junit-interface" % "0.7" % "test"
65-
// val lib_scalatest = "org.scalatest" % "scalatest_2.9.0" % "1.4.1" % "test" withSources()
66-
// val lib_maybe = buildScalaVersion match {
67-
// case "2.8.2" => "com.ckkloverdos" % "maybe_2.8.2" % "0.1.0" % "compile" withSources()
68-
// case "2.9.1" => "com.ckkloverdos" % "maybe_2.9.1" % "0.1.0" % "compile" withSources()
69-
// case v => error("Unsupported Scala version " + v)
70-
// }
71-
72-
val lib_maybe = "com.ckkloverdos" % "maybe_%s".format(buildScalaVersion) % "0.3.0" % "compile" withSources()
63+
val lib_maybe = "com.ckkloverdos" %% "maybe" % "0.4.0-SNAPSHOT" % "compile" withSources()
64+
val lib_converter = "com.ckkloverdos" %% "converter" % "0.4.0-SNAPSHOT" % "compile" withSources()
7365

7466
override def testOptions =
7567
super.testOptions ++

Diff for: src/main/scala/com/ckkloverdos/sys/SysEnv.scala

+13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.ckkloverdos.sys
1818

19+
import com.ckkloverdos.convert.Converters
20+
1921
/**
2022
* Abstraction for environment variables.
2123
*
@@ -53,4 +55,15 @@ object SysEnv {
5355
lazy val LC_CTYPE = this("LC_CTYPE")
5456

5557
def apply(name: String): SysEnv = new SysEnv(name)
58+
59+
def isSysEnvTrue(name: String)(implicit converters: Converters = Converters.DefaultConverters): Boolean = {
60+
val maybeValue = for {
61+
propValue <- SysEnv(name)
62+
booleanValue <- converters.convertToBoolean(propValue)
63+
} yield {
64+
booleanValue
65+
}
66+
67+
maybeValue.getOr(false)
68+
}
5669
}

Diff for: src/main/scala/com/ckkloverdos/sys/SysProp.scala

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.ckkloverdos.sys
1818

1919
import collection.immutable.SortedSet
20+
import com.ckkloverdos.convert.Converters
2021

2122
/**
2223
* Abstraction for jvm system properties.
@@ -92,4 +93,13 @@ object SysProp {
9293
)
9394

9495
def apply(name: String): SysProp = new SysProp(name)
96+
97+
def isSysPropTrue(name: String)(implicit converters: Converters = Converters.DefaultConverters): Boolean = {
98+
val maybeValue = for {
99+
propValue <- SysProp(name)
100+
booleanValue <- converters.convertToBoolean(propValue)
101+
} yield booleanValue
102+
103+
maybeValue.getOr(false)
104+
}
95105
}

0 commit comments

Comments
 (0)