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

Ignore maximum line length #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alexc155
Copy link
Contributor

Add an option to allow GEDCOM lines to be longer than 250 characters.

Normally, lines longer than this would fail a validation check, but depending on requirements, it might be OK to allow longer lines in incoming GEDCOMs.

The option is supplied by a new config setting conversion-options which points to a yaml file.

If the yaml file is not supplied, the included file is used and the setting defaults to false.

Example:

=> options/conversion.yaml

Options:
  - IgnoreMaxLineLength: true

=> examples/longAddress.ged

0 @Abraham_Simpson@ INDI
1 NAME Abraham /Simpson/
1 ADDR Unit 1, The centre of the village, the middle of the town, right of the other place, left of the city square, somewhere in the midlands of the region, a bit to the north of the state, around the corner from the country, located centrally in the continent, somewhere in the world.
$: ts-node src/console.ts --path 'examples/longAddress.ged' --out 'test.json' --conversion-options 'options/conversion.yaml'

RESULT:

{
 "Individuals": [
  {
   "Id": "@Abraham_Simpson@",
   "Fullname": "Abraham /Simpson/",
   "Address": "Unit 1, The centre of the village, the middle of the town, right of the other place, left of the city square, somewhere in the midlands of the region, a bit to the north of the state, around the corner from the country, located centrally in the continent, somewhere in the world."
  }
 ]
}

Comment on lines +1 to +2
Options:
- IgnoreMaxLineLength: false
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
Options:
- IgnoreMaxLineLength: false
Validation:
IgnoreMaxLineLength: false

Because the whole file are the options and the "-" marks an array in yaml but this isnt needed here

Copy link
Owner

Choose a reason for hiding this comment

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

export class Options {
  Validation?: ValidationOptions = new ValidationOptions();
}

export class ValidationOptions {
  IgnoreMaxLineLength: boolean = false;
}

this would be the needed models

Copy link
Owner

Choose a reason for hiding this comment

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

i think it would be better to do something like this:

let options: ValidationOptions = new ValidationOptions();

export function SetValidationOptions(validationOptions: ValidationOptions) {
  options = validationOptions;
}

an than use the options here instead of doing this via a parameter

Comment on lines +55 to +61
if (conversionYamlOptions) {
const yamlConfig = JSON.parse(JSON.stringify(conversionYamlOptions)).Options;
if (yamlConfig) {
const configOptions: any = Object.assign({}, ...yamlConfig);
ignoreMaxLineLength = configOptions.IgnoreMaxLineLength.toString() === 'true';
}
}
Copy link
Owner

@Jisco Jisco Mar 16, 2024

Choose a reason for hiding this comment

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

Suggested change
if (conversionYamlOptions) {
const yamlConfig = JSON.parse(JSON.stringify(conversionYamlOptions)).Options;
if (yamlConfig) {
const configOptions: any = Object.assign({}, ...yamlConfig);
ignoreMaxLineLength = configOptions.IgnoreMaxLineLength.toString() === 'true';
}
}
const conversionYamlOptions = (yaml.safeLoad(conversionOptions ?? '') as Options) ?? new Options();
SetValidationOptions(conversionYamlOptions.Validation ?? new ValidationOptions());

Why so complicated?!

Comment on lines +153 to +159
if (conversionYamlOptions) {
const yamlConfig = JSON.parse(JSON.stringify(conversionYamlOptions)).Options;
if (yamlConfig) {
const configOptions: any = Object.assign({}, ...yamlConfig);
ignoreMaxLineLength = configOptions.IgnoreMaxLineLength.toString() === 'true';
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

same as above

@@ -151,7 +186,7 @@ function ExecuteParseFile(

lr.on('line', function (line: any) {
lr.pause();
ProcessNewLine(lastLevel, lineNumber, line, nextLine);
ProcessNewLine(lastLevel, lineNumber, line, nextLine, ignoreMaxLineLength);
Copy link
Owner

Choose a reason for hiding this comment

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

alle parameters like this are not needed anymore

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