kantan.csv
kantan.csv copied to clipboard
Add HeaderDecoder with custom header name matching
Closes #315
Adds a new set of decoderWith
operators to the HeaderDecoder
and HeaderCodec
companion objects. The old method decoder
method now delegates to decoderWith
but uses the default equality check for strings.
This allows users to override how the strings are compared when trying to determine the order of the headers in the mapping, e.g. when comparing the strings in a case insensitive manner.
Right, this is really something I should put in the contribution guidelines. There's no issue that I can see with your PR, aside from a purely cosmetic one: the code is not formatted according to the project's guidelines.
You just need to run the scalafmtAll
SBT task and it'll fix the problem(s).
Also: given that your use case is likely quite a common one, I wouldn't be against pre-defined helpers. We have one for case-sensitive headers, why not:
[#
def caseInsensitiveDecoder[[#A1: CellDecoder#], R]([#f1: String#])(f: ([#A1#]) => R): HeaderDecoder[R] =
decoderWith([#f1#])(_.equalsIgnoreCase(_))(f)#
]
@nrinaudo comments addressed
I, err... were they? I'm not as used to the Github UI as I should be, but checking out the latest version of the branch locally still has }}
rather than }}}
in GeneratedHeaderDecoders
, which triggers compile time warnings (and probably disable some doctests, although I haven't checked).
Ah ok, I switched computers because scalafmt on my windows was going crazy, so I must have lost that change. Will fix
Ok I think they should be fixed now 🤞
Apologies I lost track of this and #319 until I got the notification this morning. Anyway I think I addressed your comments @nrinaudo let me know if there is anything else you want on this.