--- /dev/null
+package jp.ymir.taskReporter.core
+import scala.collection.immutable.StringLike
+import jp.ymir.taskReporter.core._
+
+trait LTSVFunctions {
+ import TSV._
+
+ def decode[A: FromRecord](tsv: StringLike[_]): Seq[A] = {
+ def toTuple(col: String): (Symbol, Field) = {
+ val pattern = """^([^:]+):(.*)$""".r
+ col match {
+ case pattern(label, value) =>
+ (Symbol(label), Field(value))
+ }
+ }
+ val lines = tsv.split('\n').filter(!_.isEmpty)
+ val records = lines.map(line => Record(line.split('\t').map(toTuple).toMap))
+ return records.map { r =>
+ runParser(r.parseRecord[A]) match {
+ case Right(a) => a
+ case Left(e) => throw new DecodeFailedException(e)
+ }
+ }
+ }
+}
+
+object LTSV extends TSVTypes with LTSVFunctions