Skip to content

Simplify backends#4

Open
ghost wants to merge 4 commits intomasterfrom
simplify-backends
Open

Simplify backends#4
ghost wants to merge 4 commits intomasterfrom
simplify-backends

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Sep 14, 2023

The general idea is to avoid being clever with backends, and prefer explicit customization by users.

@ghost ghost requested a review from thib-stpl September 14, 2023 15:25
@ghost ghost self-assigned this Sep 14, 2023
@ghost ghost force-pushed the simplify-backends branch from 1663895 to 48264df Compare September 14, 2023 15:28
Copy link
Copy Markdown

@thib-stpl thib-stpl left a comment

Choose a reason for hiding this comment

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

Je ne me prononce pas sur la simplification de l'auto-détection des backends. Je ne me rends pas compte à quel point c'est lié à la modification sur les options du backend CSV.

Pour les options en tout cas cela m'arrange, et j'ai pu valider que j'avais le comportement attendu en utilisant cette branche.

@csv = CSV.new(io, **CSV_OPTS)
@headers = detect_headers(@csv)
@cols_count = @headers.size
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

On obtient maintenant les options CSV depuis une méthode plutôt qu'une constante, c'est plus pratique.

Vu que c'est une méthode « de classe », cela nous oblige toujours à surcharger #initialize sauf erreur de ma part. En tout cas si on veut définir cette option dynamiquement en fonction de l'IO, qui n'est accessible que lorsque la classe est instanciée.

Cela permet d'utiliser super et simplifier un peu :
https://github.com/steeple-org/obelix/commit/416619d3ba94110dc02a018210e20ecaa91ff49d#diff-1fbd58936604235acab1b8ddf9ec5b3f038276a1c14e8ede2c2fcddfac03cf1b

Copy link
Copy Markdown

@thib-stpl thib-stpl left a comment

Choose a reason for hiding this comment

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

Supprimer/extraire la modification sur le codage de caractères.

col_sep: self.class.defaults[:col_sep],
quote_char: self.class.defaults[:quote_char]
)
ensure_utf8(io)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Si possible, supprimer/extraire cette modification sur le codage de caractère.

Par contre après sur la mise à jour correcte de la gem je rencontre un petit soucis, rapport à la modification sur le codage de l'IO :
https://github.com/steeple-org/obelix/commit/524e250aebd41d9622c23e6da48faed774c23708
Notre internal_encoding est nil dans ce cas, et je suis pas convaincu que ce soit une bonne idée de le forcer. external_encoding ne correspond pas non plus dans ce cas (ASCII-8bit).

Donc je vais attendre que tu extrais ou supprimes cette partie là pour me remettre dessus.

Erwan Thomas added 3 commits October 12, 2023 13:11
The CSV backend should not have an opinion on the encoding(s) of the IO
object it is given. The IO is supposed to be configured with consistent
encodings, and that's it.
@ghost ghost force-pushed the simplify-backends branch from 48264df to b18c834 Compare October 12, 2023 11:16
@ghost ghost marked this pull request as ready for review October 12, 2023 11:19
@ghost ghost requested a review from thib-stpl October 12, 2023 11:19
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.

1 participant