Skip to content

atais/Fixed-Length

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fixed-length Build Status codecov license

A simple Scala library for parsing fixed-length format.

A graceful playground for Shapeless and Cats libraries.

Installation

You can find the fixed-length library on Maven Central

Add the library to your dependencies:

Library is cross-compiled for Scala 2.12 and 2.13.

libraryDependencies += "com.github.atais" %% "fixed-length" % "1.1.0"

For Scala 2.10 and 2.11 the latest version is:

libraryDependencies += "com.github.atais" %% "fixed-length" % "0.4.1"

Examples

Please find example test scenarios describing simple use cases:

Usage

Describe your class with an Encoder, Decoder or Codec typeclass and Parse away!

Parameters

start: Int

A fixed position in line, where the field begins

end: Int

A fixed position in line, where the field ends

align: Alignment

(default value is Alignment.Left)

Alignment of the field's value in the given area of size end - start

Available options:

  • Alignment.Left
  • Alignment.Right

padding: Char

(default value is ' ')

Fills the remaining space in the given area with the padding Char.

Warning! Wrong selection of padding char may cause decoding issues!

truncate: Truncation

(default value is Truncation.None)

Truncates a field according to the specified start and end position. Keeping the left most characters with Truncation.Left and the right most characters with Truncation.Right.

Available options:

  • Truncation.Left
  • Truncation.Right
  • Truncation.None

defaultValue: A (Decoder only)

(default value is null)

The default value of a field, which will be used in case of any decoding error.

Warning! This will surpress any decoding errors!

Release

sbt release

prepare file sonatype.sbt in ~/.sbt/1.0/ with content:

credentials += Credentials("Sonatype Nexus Repository Manager",
                           "oss.sonatype.org",
                           USERNAME,
                           PASSWORD)

About

Scala library for parsing fixed length file format

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages