From 7c8a4951a0902e71a5f41609cf5471ad4f285a12 Mon Sep 17 00:00:00 2001 From: Jussi Laasonen Date: Mon, 16 Jul 2018 15:36:56 +0200 Subject: [PATCH] Rename folio to folios --- README.md | 6 +++--- lib/parseCsv.js | 8 ++++---- spec/csvHelpers.js | 8 ++++---- spec/parseCsv.spec.js | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f6780a0..c29100e 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ node index.js The CSV must contain a header and have the following columns: ``` -_id,cdliNumber,bmIdNumber,accession,genre,fincke,publication,joins,subcollection,description,length,width,thickness,collection,script,date,folio,register,transliteration,notes,museum +_id,cdliNumber,bmIdNumber,accession,genre,fincke,publication,joins,subcollection,description,length,width,thickness,collection,script,date,folios,record,transliteration,notes,museum ``` - `joins` is parsed to and array with ` + ` or `\u000b` as separator. -- `folio` is parsed to an array with ` ₤ ` as separator. -- `register` is parsed to an array of objects with ` ₤ ` as separator for array entries and `€` as separator for object properties. The resulting objects will have properties `user`, `date`, and `type`. +- `folios` is parsed to an array with ` ₤ ` as separator. +- `record` is parsed to an array of objects with ` ₤ ` as separator for array entries and `€` as separator for object properties. The resulting objects will have properties `user`, `date`, and `type`. - `\u000b` outside `joins` is parsed to `\n`. - `\u000b` in the beginning of string is omitted. \ No newline at end of file diff --git a/lib/parseCsv.js b/lib/parseCsv.js index 75e5671..cdf48c4 100644 --- a/lib/parseCsv.js +++ b/lib/parseCsv.js @@ -7,9 +7,9 @@ function parseJoins (joins) { return joins ? joins.split(joinsSeparator) : [] } -function parseFolio (folio) { - return folio - ? folio.split(poundSeparator).map(entry => { +function parseFolios (folios) { + return folios + ? folios.split(poundSeparator).map(entry => { const match = /^(?:(?.*) )(?[^ ]+)$/.exec(entry) return { name: match.groups.name || '', @@ -58,7 +58,7 @@ module.exports = async function parseCsv (csv) { resolve(data.map(rawObject => ({ ...rawObject, joins: parseJoins(rawObject.joins), - folio: parseFolio(rawObject.folio), + folios: parseFolios(rawObject.folios), record: parseRecord(rawObject.record), script: parseScript(rawObject.script), length: parseMeasure(rawObject.length), diff --git a/spec/csvHelpers.js b/spec/csvHelpers.js index ec55423..3174bb1 100644 --- a/spec/csvHelpers.js +++ b/spec/csvHelpers.js @@ -15,7 +15,7 @@ const csvDefaults = { collection: 'collection', script: 'script', date: 'date', - folio: '', + folios: '', record: '', transliteration: 'transliteration', notes: 'notes', @@ -25,7 +25,7 @@ const csvDefaults = { const objectDefaults = { ...csvDefaults, joins: [], - folio: [], + folios: [], record: [], width: {}, length: {}, @@ -46,8 +46,8 @@ function buildCsv (...rowParams) { })) return [ - '_id,cdliNumber,bmIdNumber,accession,genre,fincke,publication,joins,subcollection,description,length,width,thickness,collection,script,date,folio,record,transliteration,notes,museum', - ...objects.map(object => `"${object._id}","${object.cdliNumber}","${object.bmIdNumber}","${object.accession}","${object.genre}","${object.fincke}","${object.publication}","${object.joins}","${object.subcollection}","${object.description}","${object.length}","${object.width}","${object.thickness}","${object.collection}","${object.script}","${object.date}","${object.folio}","${object.record}","${object.transliteration}","${object.notes}","${object.museum}"`) + '_id,cdliNumber,bmIdNumber,accession,genre,fincke,publication,joins,subcollection,description,length,width,thickness,collection,script,date,folios,record,transliteration,notes,museum', + ...objects.map(object => `"${object._id}","${object.cdliNumber}","${object.bmIdNumber}","${object.accession}","${object.genre}","${object.fincke}","${object.publication}","${object.joins}","${object.subcollection}","${object.description}","${object.length}","${object.width}","${object.thickness}","${object.collection}","${object.script}","${object.date}","${object.folios}","${object.record}","${object.transliteration}","${object.notes}","${object.museum}"`) ].join('\n') } diff --git a/spec/parseCsv.spec.js b/spec/parseCsv.spec.js index 67dff35..d408323 100644 --- a/spec/parseCsv.spec.js +++ b/spec/parseCsv.spec.js @@ -36,8 +36,8 @@ describe('parseCsv', () => { expectCsv({joins: 'join1\u000bjoin2\u000bjoin3'}).toParseTo({joins: ['join1', 'join2', 'join3']}) }) - it('parses ₤ folio', () => { - expectCsv({folio: 'ABC folio1 ₤ folio2'}).toParseTo({folio: [ + it('parses ₤ folios', () => { + expectCsv({folios: 'ABC folio1 ₤ folio2'}).toParseTo({folios: [ { name: 'ABC', number: 'folio1'