Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Rename folio to folios
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaasonen committed Jul 16, 2018
1 parent 48efad7 commit 7c8a495
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ node index.js <path to the CSV file>

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.
8 changes: 4 additions & 4 deletions lib/parseCsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = /^(?:(?<name>.*) )(?<number>[^ ]+)$/.exec(entry)
return {
name: match.groups.name || '',
Expand Down Expand Up @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions spec/csvHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const csvDefaults = {
collection: 'collection',
script: 'script',
date: 'date',
folio: '',
folios: '',
record: '',
transliteration: 'transliteration',
notes: 'notes',
Expand All @@ -25,7 +25,7 @@ const csvDefaults = {
const objectDefaults = {
...csvDefaults,
joins: [],
folio: [],
folios: [],
record: [],
width: {},
length: {},
Expand All @@ -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')
}

Expand Down
4 changes: 2 additions & 2 deletions spec/parseCsv.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 7c8a495

Please sign in to comment.