Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reading files #69

Merged
merged 7 commits into from
Nov 11, 2017
Merged

Add support for reading files #69

merged 7 commits into from
Nov 11, 2017

Conversation

vlovgr
Copy link
Owner

@vlovgr vlovgr commented Nov 11, 2017

Add file and fileWithName methods for reading the contents of files, optionally modifying the read file contents before attempting the type conversion, and optionally specifying a charset. Note that this is currently only implemented for the JVM. Also adds the following in support of the functionality: ConfigKeyType#File, ConfigSource#File, ConfigReader#mapEntryValue, ConfigSourceEntry#mapValue.

❯ cat /tmp/num.txt
3
scala> import ciris._
import ciris._

scala> fileWithName[Int]("/tmp/num.txt")
res0: ciris.ConfigValue[Int] =
ConfigValue(Left(WrongType((/tmp/num.txt,UTF-8), 3
, Int, ConfigKeyType(file), Some(java.lang.NumberFormatException: For input string: "3
"))))

scala> fileWithName[Int]("/tmp/num.txt", _.trim)
res1: ciris.ConfigValue[Int] = ConfigValue(Right(3))

@codecov
Copy link

codecov bot commented Nov 11, 2017

Codecov Report

Merging #69 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #69   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          28     31    +3     
  Lines         433    446   +13     
  Branches        3      3           
=====================================
+ Hits          433    446   +13
Impacted Files Coverage Δ
...ore/shared/src/main/scala/ciris/ConfigSource.scala 100% <ø> (ø) ⬆️
...les/core/shared/src/main/scala/ciris/package.scala 100% <ø> (ø) ⬆️
...re/shared/src/main/scala/ciris/ConfigKeyType.scala 100% <ø> (ø) ⬆️
...in/scala/ciris/ConfigKeyTypePlatformSpecific.scala 100% <100%> (ø)
...hared/src/main/scala/ciris/ConfigSourceEntry.scala 100% <100%> (ø) ⬆️
...ore/shared/src/main/scala/ciris/ConfigReader.scala 100% <100%> (ø) ⬆️
...ain/scala/ciris/ConfigSourcePlatformSpecific.scala 100% <100%> (ø)
...m/src/main/scala/ciris/CirisPlatformSpecific.scala 100% <100%> (ø)
.../shared/src/main/scala/ciris/ConfigException.scala 100% <0%> (ø) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f74cb31...ca94697. Read the comment docs.

@vlovgr vlovgr merged commit 0d5c4c6 into master Nov 11, 2017
@vlovgr vlovgr deleted the file-support branch November 11, 2017 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant