Skip to content

Instantly share code, notes, and snippets.

@reyman
Created January 3, 2013 10:38
Show Gist options
  • Save reyman/4442515 to your computer and use it in GitHub Desktop.
Save reyman/4442515 to your computer and use it in GitHub Desktop.
csvtask
object CSVTask {
def apply(name: String, file: File)(implicit plugins: PluginSet) =
new TaskBuilder { builder ⇒
private var _columns = new ListBuffer[(String, Prototype[_])]
def columns = _columns.toList
def addColumn(proto: Prototype[_]): this.type = this.addColumn(proto.name, proto)
def addColumn(name: String, proto: Prototype[_]): builder.type = {
_columns += (name -> proto)
this
}
def toTask = new CSVTask(name, file) {
val inputs = builder.inputs
val outputs = builder.outputs
val parameters = builder.parameters
val columns = builder.columns
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment