Skip to content

Commit

Permalink
Remove cursor to source conversions or make them private
Browse files Browse the repository at this point in the history
  • Loading branch information
ruippeixotog committed Aug 29, 2019
1 parent 613d92d commit aafe9e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
25 changes: 5 additions & 20 deletions core/src/main/scala/pureconfig/ConfigSource.scala
Expand Up @@ -148,24 +148,6 @@ object ConfigObjectSource {
*/
def apply(conf: => Result[Config]): ConfigObjectSource =
new ConfigObjectSource(() => conf)

/**
* Creates a `ConfigObjectSource` from a `ConfigObjectCursor`.
*
* @param cur the cursor to be provided by this source
* @return a `ConfigObjectSource` providing the given cursor.
*/
def fromCursor(cur: ConfigObjectCursor): ConfigObjectSource =
new ConfigObjectSource(() => Right(cur.value.toConfig))

/**
* Creates a `ConfigObjectSource` from a `FluentConfigCursor`.
*
* @param cur the cursor to be provided by this source
* @return a `ConfigObjectSource` providing the given cursor.
*/
def fromCursor(cur: FluentConfigCursor): ConfigObjectSource =
new ConfigObjectSource(() => cur.asObjectCursor.right.map(_.value.toConfig))
}

/**
Expand Down Expand Up @@ -314,8 +296,9 @@ object ConfigSource {
* @param cur the cursor to be provided by this source
* @return a `ConfigSource` providing the given cursor.
*/
def fromCursor(cur: ConfigCursor): ConfigSource = new ConfigSource {
private[pureconfig] def fromCursor(cur: ConfigCursor): ConfigSource = new ConfigSource {
def value(): Result[ConfigValue] = Right(cur.value)
override def cursor() = Right(cur)
}

/**
Expand All @@ -324,7 +307,9 @@ object ConfigSource {
* @param cur the cursor to be provided by this source
* @return a `ConfigSource` providing the given cursor.
*/
def fromCursor(cur: FluentConfigCursor): ConfigSource = new ConfigSource {
private[pureconfig] def fromCursor(cur: FluentConfigCursor): ConfigSource = new ConfigSource {
def value(): Result[ConfigValue] = cur.cursor.right.map(_.value)
override def cursor() = cur.cursor
override def fluentCursor() = cur
}
}
10 changes: 0 additions & 10 deletions tests/src/test/scala/pureconfig/ConfigSourceSuite.scala
Expand Up @@ -193,16 +193,6 @@ class ConfigSourceSuite extends BaseSuite {
}
}

it should "allow reading to and from a cursor" in {
case class Conf(d: Double, i: Int)
val conf = ConfigFactory.parseString("{ d: 0.5, i: 10 }")
val cursor = ConfigCursor(conf.root(), Nil)

ConfigSource.fromCursor(cursor).load[Conf] shouldBe Right(Conf(0.5D, 10))
ConfigSource.fromCursor(cursor).cursor() shouldBe Right(cursor)
ConfigSource.fromCursor(cursor.fluent).fluentCursor() shouldBe cursor.fluent
}

it should "define an empty source" in {
ConfigSource.empty.load[Config] shouldBe Right(ConfigFactory.empty)
}
Expand Down

0 comments on commit aafe9e9

Please sign in to comment.