as_csv icon indicating copy to clipboard operation
as_csv copied to clipboard

make #headers public on CsvBuilder

Open dzfolio opened this issue 1 year ago • 2 comments

we have a use case where we'd like to generate only the headers. in order to generate the headers correctly we do need to look at all rows and collect/uniq them, why is why I am adding it to csv_builder

please let me know feedback

dzfolio avatar Jun 08 '24 14:06 dzfolio

Hi @dzfolio. Thanks for the contribution! I don't mind this feature, but I wonder if it would be simpler to just make the AsCSV::CSVBuilder#headers method public? I realise this isn't functionally equivalent, but then if you only want the headers you can call headers on the CSVBuilder object instead of to_csv. How does this sound?

sure sounds reasonable to me. should I break out tests for #headers or do you think it's covered enough from existing tests

dzfolio avatar Jun 09 '24 23:06 dzfolio

should I break out tests for #headers or

Good question. I think since it's now part of the public interface it's worth having a few basic tests against it. You can even just copy the relevant to_csv contexts/specs and change the assertions to check the headers. I don't mind if the spec is not DRY in this case.

danielfone avatar Jun 09 '24 23:06 danielfone