1 package jp.ymir.taskReporter.core
2 import scala.collection.immutable.StringLike
3 import jp.ymir.taskReporter.core._
8 def decode[A: FromRecord](tsv: StringLike[_]): Seq[A] = {
9 def toTuple(col: String): (Symbol, Field) = {
10 val pattern = """^([^:]+):(.*)$""".r
12 case pattern(label, value) =>
13 (Symbol(label), Field(value))
16 val lines = tsv.split('\n').filter(!_.isEmpty)
17 val records = lines.map(line => Record(line.split('\t').map(toTuple).toMap))
18 return records.map { r =>
19 runParser(r.parseRecord[A]) match {
21 case Left(e) => throw new DecodeFailedException(e)
27 object LTSV extends TSVTypes with LTSVFunctions