Skip to content

Commit

Permalink
Fixes multi-line descriptions for CSV serialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Drekorian committed Dec 2, 2020
1 parent f744de9 commit 5015960
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ data class Product(
private const val PRODUCT_ID_PADDING = '0'
private const val TRUE = -1
private const val FALSE = 0
private const val LINE_SEPARATOR = "____"
}

/**
Expand All @@ -46,9 +47,13 @@ data class Product(
|${if (valid) TRUE else FALSE}
|${if (isNew) TRUE else FALSE}
|${if (isOnSale) TRUE else FALSE}
|$description
|${description
.lines()
.joinToString(separator = LINE_SEPARATOR)
}
$ingredients"""
.lines()
.filterIndexed { index, _ -> index != 0 }
.joinToString(separator = CSV_SEPARATOR) { it.trimMargin("|") }
.replace(LINE_SEPARATOR, "\n")
}

0 comments on commit 5015960

Please sign in to comment.