Skip to content

Commit

Permalink
Merge branch 'master' into run-doc-in-travis
Browse files Browse the repository at this point in the history
  • Loading branch information
derekmorr committed May 20, 2017
2 parents c68e191 + 4293480 commit 78787b0
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
making them easier to compose.
- New mechanism to read and write [value classes](http://docs.scala-lang.org/overviews/core/value-classes.html).
The readers and writers of the inner type are used instead of the ones for products.
- `ConfigReader` and `ConfigWriter` for `java.io.File`
- Bug fixes
- `Duration.Undefined` is correctly handled when reading and writing configurations. [[#184](https://github.com/melrief/pureconfig/issues/184)]

Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -115,6 +115,7 @@ Currently supported types for fields are:
- `Map` with `String` keys and any value type that is in this list;
- everything in [`java.time`](https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html) (must be
configured first - see [Configurable converters](docs/configurable-converters.md));
- [`java.io.File`](https://docs.oracle.com/javase/8/docs/api/java/io/File.html);
- [`java.util.UUID`](https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html);
- [`java.nio.file.Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html);
- Typesafe `ConfigValue`, `ConfigObject` and `ConfigList`;
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/pureconfig/BasicReaders.scala
@@ -1,5 +1,6 @@
package pureconfig

import java.io.File
import java.net.{ URI, URL }
import java.nio.file.{ Path, Paths }
import java.time._
Expand Down Expand Up @@ -40,6 +41,7 @@ trait UriAndPathReaders {
implicit val urlConfigReader = ConfigReader.fromNonEmptyString[URL](catchReadError(new URL(_)))
implicit val uuidConfigReader = ConfigReader.fromNonEmptyString[UUID](catchReadError(UUID.fromString))
implicit val pathConfigReader = ConfigReader.fromString[Path](catchReadError(Paths.get(_)))
implicit val fileConfigReader = ConfigReader.fromString[File](catchReadError(new File(_)))
implicit val uriConfigReader = ConfigReader.fromString[URI](catchReadError(new URI(_)))
}

Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/pureconfig/BasicWriters.scala
@@ -1,5 +1,6 @@
package pureconfig

import java.io.File
import java.net.{ URI, URL }
import java.nio.file.Path
import java.time._
Expand Down Expand Up @@ -32,6 +33,7 @@ trait UriAndPathWriters {
implicit val urlConfigWriter = ConfigWriter.toDefaultString[URL]
implicit val uuidConfigWriter = ConfigWriter.toDefaultString[UUID]
implicit val pathConfigWriter = ConfigWriter.toDefaultString[Path]
implicit val fileConfigWriter = ConfigWriter.toDefaultString[File]
implicit val uriConfigWriter = ConfigWriter.toDefaultString[URI]
}

Expand Down
1 change: 1 addition & 0 deletions core/src/main/tut/README.md
Expand Up @@ -115,6 +115,7 @@ Currently supported types for fields are:
- `Map` with `String` keys and any value type that is in this list;
- everything in [`java.time`](https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html) (must be
configured first - see [Configurable converters](docs/configurable-converters.md));
- [`java.io.File`](https://docs.oracle.com/javase/8/docs/api/java/io/File.html);
- [`java.util.UUID`](https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html);
- [`java.nio.file.Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html);
- Typesafe `ConfigValue`, `ConfigObject` and `ConfigList`;
Expand Down
4 changes: 3 additions & 1 deletion core/src/test/scala/pureconfig/BasicConvertersSuite.scala
@@ -1,5 +1,6 @@
package pureconfig

import java.io.File
import java.net.{ URI, URL }
import java.nio.file.Path
import java.time._
Expand All @@ -10,7 +11,6 @@ import com.typesafe.config._
import pureconfig.arbitrary._
import pureconfig.data.Percentage
import pureconfig.error.{ CannotConvert, EmptyStringFound }

import scala.collection.JavaConverters._
import scala.collection.immutable
import scala.concurrent.duration.{ Duration, FiniteDuration }
Expand Down Expand Up @@ -68,6 +68,8 @@ class BasicConvertersSuite extends BaseSuite {

checkArbitrary[Path]

checkArbitrary[File]

checkArbitrary[immutable.HashSet[String]]

checkArbitrary[immutable.List[Float]]
Expand Down
1 change: 1 addition & 0 deletions core/src/test/scala/pureconfig/arbitrary/package.scala
Expand Up @@ -15,6 +15,7 @@ package object arbitrary {
implicit val arbYear = Arbitrary(genYear)
implicit val arbUUID = Arbitrary(Gen.uuid)
implicit val arbPath = Arbitrary(genPath)
implicit val arbFile = Arbitrary(genFile)
implicit val arbPercentage = Arbitrary(genPercentage)
implicit val arbJodaDateTime = Arbitrary(genJodaDateTime)
}
5 changes: 4 additions & 1 deletion core/src/test/scala/pureconfig/gen/package.scala
@@ -1,13 +1,13 @@
package pureconfig

import java.io.File
import java.nio.file.{ Path, Paths }
import java.time._
import java.time.{ Duration => JavaDuration }

import org.scalacheck.{ Arbitrary, Gen }
import pureconfig.configurable.ConfigurableSuite
import pureconfig.data._

import scala.collection.JavaConverters._
import scala.concurrent.duration.{ Duration, FiniteDuration }

Expand Down Expand Up @@ -55,6 +55,9 @@ package object gen {
val genPath: Gen[Path] =
Gen.nonEmptyListOf(Gen.alphaNumStr).map(parts => parts.map(str => Paths.get(str)).reduce(_ resolve _))

val genFile: Gen[File] =
genPath.map(_.toFile)

val genPercentage: Gen[Percentage] =
Gen.choose[Int](0, 100).map(Percentage.apply)

Expand Down

0 comments on commit 78787b0

Please sign in to comment.