[ANN][wip] plumber: builds pipes to transform a data stream

51 views
Skip to first unread message

mhh...@gmail.com

unread,
Apr 27, 2017, 7:35:08 AM4/27/17
to golang-nuts
Hi,

Purpose

builds pipes to transform a data stream.
It comes with a generator to avoid you some copy paste,
and provide a standard bytes stream to get started with []byte.

Example

Following example reads a source of []byte, os.Stdin,
as a list of versions, one per line,
manipulates and transforms the chunks
until the data is written on the sink, os.Stdout.


//Package cmd implement a cli tool to manipulate Versions.
package main

import (
   
"os"

   
"github.com/mh-cbon/semver/cmd/stream"
)

func main
() {

    src
:= os.Stdin

    pipeSrc
:= stream.NewByteReader(src)
    pipe
:= pipeSrc.
       
Pipe(stream.NewBytesSplitter(' ', '\n')).
       
Pipe(&stream.BytesTrimer{}).
       
Pipe(&stream.VersionFromByte{SkipInvalid: true}).
       
Pipe(&stream.VersionSorter{Asc: true}).
       
Pipe(&stream.LastVersionOnly{}).
       
Pipe(&stream.VersionToByte{}).
       
Pipe(stream.NewBytesPrefixer("- ", "\n"))

    pipe
.Sink(stream.NewByteSink(dest))

   
if err := pipeSrc.Consume(); err != nil {
        panic
(err)
   
}
    os
.Exit(0)
}


URL
https://mh-cbon.github.io/plumber/
https://github.com/mh-cbon/plumber

WIP?

yeah, let s write tests ect when its needed.


HTH
Reply all
Reply to author
Forward
0 new messages