ltsv

Build Status Gem Version Dependency Status

Description

An reader/writer library for the LTSV(Labeled Tab Separated Values) format. See LTSV specs http://ltsv.org/.

Usage

require 'ltsv'

LTSV.parse_line "key1:val1  key2:val2\n" #=> {:key1=>"val1", :key2=>"val2"}

LTSV.parse 'key1:val1   key2:val2
key1:val1   key2:val2   key3:val3' #=> [{:key1=>"val1", :key2=>"val2"}, {:key1=>"val1", :key2=>"val2", :key3=>"val3"}]

LTSV.foreach foo.log.ltsv do |entry|
  p entry # calls the block with parsed hash
end

LTSV.for_io STDIN do |entry|
  p entry # calls the block with parsed hash
end

LTSV.line_from_hash({:key1=>"val1", :key2=>"val2"}) #=> "key1:val1  key2:val2"
LTSV.line_from_hash valid: "with\ttab" #=> LTSV::MalformedDataError

Requirements

Install

gem install ya_ltsv

Link

License

The MIT X11 License
Copyright (c) 2013 Kenichi Kamiya
See MIT-LICENSE for further details.