module HRX
Overview
This module provides methods for parsing Human Readable Archive (.hrx) format.
HRX is a plain-text, human-friendly format for defining multiple virtual text files in a single physical file, for situations when creating many physical files is undesirable, such as defining test cases for a text format.
Defined in:
file.crhrx.cr
Class Method Summary
-
.parse(input : String) : Hash(String, HRX::File)
Parse a HRX archive from a string.
-
.parse(io : IO) : Hash(String, HRX::File)
Parse a HRX archive from an IO.
-
.parse(io : IO, & : HRX::File -> )
Parse a HRX archive from an IO and yields
HRX::File
instances.
Class Method Detail
Parse a HRX archive from a string.
hrx = HRX.parse("<==> foo\nFOO\n<==> bar\nBAR")
hrx.transform_values(&.content) # => {"foo" => "FOO", "bar" => "BAR"}
Parse a HRX archive from an IO.
hrx = HRX.parse(IO::Memory.new("<==> foo\nFOO\n<==> bar\nBAR"))
hrx.transform_values(&.content) # => {"foo" => "FOO", "bar" => "BAR"}
Parse a HRX archive from an IO and yields HRX::File
instances.
files = [] of HRX::File
HRX.parse(IO::Memory.new("<==> foo\nFOO\n<==> bar\nBAR")) do |file|
files << file
end
files[0] # => HRX::File.new("foo", "FOO", nil, 1, 6)
files[1] # => HRX::File.new("bar", "BAR", nil, 3, 6)