Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make #headers public on CsvBuilder #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dzfolio
Copy link

@dzfolio dzfolio commented Jun 8, 2024

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

Copy link
Owner

@danielfone danielfone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

context 'with hetreogenous records' do
context 'with heterogeneous records' do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏻

@dzfolio dzfolio changed the title add headers_only options to csv_builder to only generate headers make #headers public on CsvBuilder Jun 9, 2024
@dzfolio
Copy link
Author

dzfolio commented Jun 9, 2024

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

@danielfone
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants