Skip to content

Commit

Permalink
Merge pull request #21 from jpbnetley/feature/config-file(#15)
Browse files Browse the repository at this point in the history
fixed read config from file if not exists
  • Loading branch information
jpbnetley authored May 17, 2020
2 parents ba3f1be + fdcb821 commit 6ca8e88
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object Main extends TaskApp {
db <- EitherT.liftF[Task, Exception, MongoDatabase](database.getDatabase(config, mongoClient))
userInput <- EitherT(promptUser())
csvFiles <- EitherT(FileHelper.getCsvFiles(userInput.folderPath, userInput.skipFiles))
orderedFiles = csvFiles.zipWithIndex.toOrderedFile()
orderedFiles = csvFiles.zipWithIndex.toOrderedFile
_ <- EitherT(Processing.csvFiles(orderedFiles)(db))
} yield {
database.close(mongoClient)
Expand Down
7 changes: 5 additions & 2 deletions src/main/scala/util/config/ConfigFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import util.Logging.log
import util.ImplicitConversions.RichConfig
import util.models.enums.MongoDbEnvironmentNames

import scala.reflect.io.{Directory, Path}

case object ConfigFile extends SystemConfigProperties {
/** validate of the configeration method is present
/** validate of the configuration method is present
*
* @return Boolean, true if it exists
*/
override def exists: Boolean = {
val exist = !ConfigFactory.load().isEmpty
val configPath = Path("src/main/resources/application.conf")
val exist = Directory(configPath).exists
log.info(s"Check if config file: application.conf exists: $exist")
exist
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/util/config/EnvironmentVariables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import util.Logging.log
import util.models.enums.MongoDbEnvironmentNames

case object EnvironmentVariables extends SystemConfigProperties {
/** validate of the configeration method is present
/** validate of the configuration method is present
*
* @return Boolean, true if it exists
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package util.databaseProvider
import util.models.SystemConfigPropertiesResponse

trait SystemConfigProperties {
/** validate of the configeration method is present
/** validate of the configuration method is present
*
* @return Boolean, true if it exists
*/
Expand Down

0 comments on commit 6ca8e88

Please sign in to comment.