Conversation
The block form of #lines has been deprecated in Ruby 2.4
RSpec 2 fails to run on Ruby 3
The default parser doesn't consider begin, end, version, or fn fields while parsing. This leads to odd behaviour if you give it an invalid vCard - such as one without an begin or end line; without a version or full name - where it parses it as if it were valid. This problem is most obvious if you give the parser a file that contains multiple cards, it will merge all the cards into a single large card.
monorkin
force-pushed
the
add-ability-to-parse-multiple-cards
branch
from
April 20, 2024 16:21
e72658e to
65c41da
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, I've noticed that VCardigan behaves a bit odd if I parse with it a file that contains multiple vCards.
I'd expect it to obey the begin and end lines of each card, but it doesn't and it ends up combining all the cards in the file into one large card with all the fields of all cards.
For instance, the following file:
if given to
.parsewould product a single vCard that combines John and Jane Doe.In this PR I've added two things:
.parse_all!method which returns an enumerator which in term yields all cards one-by-one as it parses them.parse!method which is the same as.parsebut strict in the sense that it raises an error if it encounters something unexpected while parsingCalling
.parse_all!on the file from before would product 2 vCards:While calling
.parse!on an invalid vCard produces an error, where before this would produce a vCard:The old behavior of the parse method was kept in case someone depends on it.
There are cases when that behavior is useful.
All new parser errors inherit from the old
EncodingErrorfor backwards compatibility.In the process I've also upgraded RSpec to version 3 so that it works with newer Ruby versions.