Commit Graph

34 Commits

Author SHA1 Message Date
jdb 935f1bae2f WIP documentation
- The documentation is cluttered enough as it is with the large number
  of procedures supporting vCard 3 and 4. Split common out into the
  publicly exposed bits and the private internals. This makes it obvious
  which common functionality a client can expect to have exposed on the
  main vcard module.

- Add documentation (WIP) on the vcard3 module.
2023-05-03 02:16:18 -05:00
jdb 0ec1856d1b lexer: Add comments documenting the implementation and expected behavior. 2023-05-03 01:05:02 -05:00
jdb ddddcf0af9 vcard4: Use VC_Param instead of VCParam for consistency. 2023-05-03 00:29:55 -05:00
jdb 5565087359 common: Reformat for clarity, documentation.
- Consolidate `vcard/private/util` into `vcard/private/common`.
2023-05-03 00:28:26 -05:00
jdb 98c300fee2 vcard4: Complete implementation.
- Parsers and serializers are now present for all property types.
- Tests exist to cover parsing for most value types. Many property types
  share the same parsing logic based on their value type. We have
  created unit tests to cover each value type, not neccesarily all
  properties individually.
2023-05-02 22:37:23 -05:00
jdb daa58518e3 vcard3: Unify with VCard4 implementation.
- Unify the naming pattern of types and enums. Specifically:
  - use `VC_Param` instead of `VCParam`. The goal here is to make the
    important information (Param, Source, PropertyName, etc.) easy to
    see at a glance while preserving a prefix that allows multiple
    implementation to coexist (VC3_Source vs. VC4_Source) and also be
    easily distinguishable at a glance.
  - use `pnName` instead of `cnName`. The VCard standard refers to each
    line of data as a "content line," so the original name of each was
    "Content." However, the spec more commonly refers to each piece of
    data as a "property." There is a 1-to-1 mapping of content lines to
    property instances, but property is a more accurate name.

- Introduce the idea of property cardinality to the VCard3
  implementation. The spec does not tightly define property cardinality,
  but implies it with statements like "if the NAME type is present, then
  *its* value is *the* displayable, presentation text associated..."
  (emphasis added). Similar language implies some properties must be
  present exactly once (FN, N, VERSION) or at most once (NAME, PROFILE,
  SOURCE, BDAY, CATEGORIES, PRODID, REV, SORT-STRING, UID). Any other
  properties are assumed to be allowed any number of times (including
  0).

  In the case of a VCard that contains multiple instances of properties
  expected to be singular, the parser will still parse and store these
  properties. They can be accessed via the `vcard#allPropsOfType`
  function. For example:

      # vc3 is a VCard3
      allPropsOfType[VC3_N](vc3)

  If we see over the course of time that other implementations regularly
  use multiple instances of properties we have expected to be singular,
  we are open to changing the contract to treat them so (though this
  may be a breaking change).

- Refactor the VCard3 implementation to use generated property
  accessors, following a similar pattern to the new VCard4
  implementation.

- Remove the accessor definitions that allow access via the content seq
  directly (`vc3.content.name` for example). There really isn't a reason
  for this use-case and the library is simpler without exposing this.
2023-05-02 22:36:27 -05:00
jdb 8e25c3d100 lexer, common: More descriptive error messages.
The lexer now tracks the data that has been read since the start of the
current line. While this may have use in parsers, the immediate use is
by the common error reporting procedure.

The `common#error` procedure already reports the column and line number
where an error occurs. The `common#expect` function is broadly used by
parsers and generates the majority of parser errors. It now uses the
lexer's record of the current line to format its error message with a
direct pointer to the location of the unmet expectation.
2023-05-02 22:11:00 -05:00
jdb 71107dda1c lexer: Add readLen and readRunesLen.
Convenience methods for cases where a parser knows it wants to read
multiple bytes or runes from the input stream.
2023-05-02 22:05:00 -05:00
jdb cf4c14f9f8 Makefiles: update tests to ignore the BareExcept warning.
The `unittest` library still contains a number of bare exceptions, which
now result in warnings from the compliler. Patching the standard library
to remove these warnings is outside the scope of this project, so we're
going to ignore these warnings.
2023-05-02 21:32:30 -05:00
jdb 31f47f60c2 Makefile: Updates to testing targets. 2023-04-23 22:55:41 -05:00
jdb f59403ad72 WIP - initial VCard4 implementation. 2023-04-23 21:56:15 -05:00
jdb 7d642adf2d RFC 6868: erratta for VCard4 parameter escaping mechanism. 2023-04-23 21:56:15 -05:00
jdb 3f1efe9e85 Makefile. 2023-04-23 21:56:15 -05:00
jdb 6bbcd9b6a3 lexer: Support multiple nested bookmarks. 2023-04-23 21:56:10 -05:00
jdb 8e58189a8b Re-organizing code in preparation for v4.0 implementation. 2023-04-23 21:56:04 -05:00
jdb 9d030132de Better ignore pattern for test artifacts. 2023-04-23 21:55:53 -05:00
jdb 68554920e5 Fix bug in parsing TEL content. Rework unit tests.
- newVC3_Tel was not assigning the value provided to the constructed
  object.
- Private unit tests were run every time the code was compiled due to
  how the unittest library works. These now only run as part of the unit
  tests with `nimble test`.
0.1.3
2023-04-16 03:34:14 -05:00
jdb 7b71cb2dfe Extract example from the README to a runnable location. 2023-04-16 03:31:37 -05:00
jdb 47c62cce6d Restructure to follow standard nimble package format. 0.1.2 2023-04-15 07:40:58 -05:00
jdb a1dac6eaaf Bump version. 0.1.1 2023-04-15 07:09:55 -05:00
jdb 2c625349bf README: add simple usage. 2023-04-15 07:09:03 -05:00
jdb 0f353e97ca Add test case for email preference. 2023-04-15 07:08:30 -05:00
jdb c4717b4b00 Date types default to date-time as specified.
- `parseDateOrDateTime attempts to parse times starting from the most
  specific (date and time) to least specific.
- `set` and `add` functions allow adding multiple content items at once
  using varargs.
2023-04-15 07:03:24 -05:00
jdb 419d794c68 Added RFC 6352 (CardDav). 2023-04-15 06:58:57 -05:00
jdb a0cd676521 Fix defect found testing EMAIL content types. 2023-04-10 16:10:49 -05:00
jdb 2a48974f3a Add basic description in the README. 2023-04-05 09:42:16 -05:00
jdb 82dffc1154 Initial VCard 3.0 implementation completed. 0.1.0 2023-04-04 14:31:44 -05:00
jdb c322616747 WIP lexer unit tests. 2023-04-01 17:36:01 -05:00
jdb 2bc5d5c74f WIP vcard 3.0 lexer and parser. 2023-04-01 16:29:30 -05:00
jdb 118f7f5a45 Ignore vim swap files. 2023-04-01 16:29:09 -05:00
jdb 51d80504d6 Simplified mermaid diagram of the VCard3 parsing logic. 2023-03-28 15:31:42 +01:00
jdb d6d8e1d654 WIP vcard 3.0 implementation. 2023-03-26 20:45:52 -05:00
jdb 3a7808668a Rename library to just 'vcard'. 2022-07-02 07:05:44 -05:00
jdb ee716a4801 Initial commit with Nimble library template and RFCs. 2022-07-01 23:01:09 -05:00