Skip to content

Commit 184b817

Browse files
committed
refactor: Rename some symbols to dependsOn... in Serializer code
1 parent ed3a12d commit 184b817

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/TaskSerializer/DataviewTaskSerializer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const DATAVIEW_SYMBOLS = {
7676
cancelledDateSymbol: 'cancelled::',
7777
recurrenceSymbol: 'repeat::',
7878
idSymbol: 'id::',
79-
blockedBySymbol: 'blockedBy::',
79+
dependsOnSymbol: 'blockedBy::',
8080
TaskFormatRegularExpressions: {
8181
priorityRegex: toInlineFieldRegex(/priority:: *(highest|high|medium|low|lowest)/),
8282
startDateRegex: toInlineFieldRegex(/start:: *(\d{4}-\d{2}-\d{2})/),
@@ -86,7 +86,7 @@ export const DATAVIEW_SYMBOLS = {
8686
doneDateRegex: toInlineFieldRegex(/completion:: *(\d{4}-\d{2}-\d{2})/),
8787
cancelledDateRegex: toInlineFieldRegex(/cancelled:: *(\d{4}-\d{2}-\d{2})/),
8888
recurrenceRegex: toInlineFieldRegex(/repeat:: *([a-zA-Z0-9, !]+)/),
89-
blockedByRegex: toInlineFieldRegex(/blockedBy:: *([a-z0-9]+( *, *[a-z0-9]+ *)*)$/),
89+
dependsOnRegex: toInlineFieldRegex(/blockedBy:: *([a-z0-9]+( *, *[a-z0-9]+ *)*)$/),
9090
idRegex: toInlineFieldRegex(/id:: *([a-z0-9]+)/),
9191
},
9292
} as const;

src/TaskSerializer/DefaultTaskSerializer.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface DefaultTaskSerializerSymbols {
3030
readonly cancelledDateSymbol: string;
3131
readonly recurrenceSymbol: string;
3232
readonly idSymbol: string;
33-
readonly blockedBySymbol: string;
33+
readonly dependsOnSymbol: string;
3434
readonly TaskFormatRegularExpressions: {
3535
priorityRegex: RegExp;
3636
startDateRegex: RegExp;
@@ -41,7 +41,7 @@ export interface DefaultTaskSerializerSymbols {
4141
cancelledDateRegex: RegExp;
4242
recurrenceRegex: RegExp;
4343
idRegex: RegExp;
44-
blockedByRegex: RegExp;
44+
dependsOnRegex: RegExp;
4545
};
4646
}
4747

@@ -66,7 +66,7 @@ export const DEFAULT_SYMBOLS: DefaultTaskSerializerSymbols = {
6666
doneDateSymbol: '✅',
6767
cancelledDateSymbol: '❌',
6868
recurrenceSymbol: '🔁',
69-
blockedBySymbol: '⛔️',
69+
dependsOnSymbol: '⛔️',
7070
idSymbol: '🆔',
7171
TaskFormatRegularExpressions: {
7272
// The following regex's end with `$` because they will be matched and
@@ -79,7 +79,7 @@ export const DEFAULT_SYMBOLS: DefaultTaskSerializerSymbols = {
7979
doneDateRegex: / *(\d{4}-\d{2}-\d{2})$/u,
8080
cancelledDateRegex: / *(\d{4}-\d{2}-\d{2})$/u,
8181
recurrenceRegex: /🔁 ?([a-zA-Z0-9, !]+)$/iu,
82-
blockedByRegex: / *([a-z0-9]+( *, *[a-z0-9]+ *)*)$/iu,
82+
dependsOnRegex: / *([a-z0-9]+( *, *[a-z0-9]+ *)*)$/iu,
8383
idRegex: /🆔 *([a-z0-9]+)$/iu,
8484
},
8585
} as const;
@@ -130,7 +130,7 @@ export class DefaultTaskSerializer implements TaskSerializer {
130130
cancelledDateSymbol,
131131
recurrenceSymbol,
132132
dueDateSymbol,
133-
blockedBySymbol,
133+
dependsOnSymbol,
134134
idSymbol,
135135
} = this.symbols;
136136

@@ -172,7 +172,7 @@ export class DefaultTaskSerializer implements TaskSerializer {
172172
return symbolAndStringValue(shortMode, recurrenceSymbol, task.recurrence.toText());
173173
case TaskLayoutComponent.BlockedBy: {
174174
if (task.blockedBy.length === 0) return '';
175-
return symbolAndStringValue(shortMode, blockedBySymbol, task.blockedBy.join(','));
175+
return symbolAndStringValue(shortMode, dependsOnSymbol, task.blockedBy.join(','));
176176
}
177177
case TaskLayoutComponent.Id:
178178
return symbolAndStringValue(shortMode, idSymbol, task.id);
@@ -233,7 +233,7 @@ export class DefaultTaskSerializer implements TaskSerializer {
233233
let recurrenceRule: string = '';
234234
let recurrence: Recurrence | null = null;
235235
let id: string = '';
236-
let blockedBy: string[] | [] = [];
236+
let dependsOn: string[] | [] = [];
237237
// Tags that are removed from the end while parsing, but we want to add them back for being part of the description.
238238
// In the original task description they are possibly mixed with other components
239239
// (e.g. #tag1 <due date> #tag2), they do not have to all trail all task components,
@@ -323,11 +323,11 @@ export class DefaultTaskSerializer implements TaskSerializer {
323323
matched = true;
324324
}
325325

326-
const blockedByMatch = line.match(TaskFormatRegularExpressions.blockedByRegex);
326+
const dependsOnMatch = line.match(TaskFormatRegularExpressions.dependsOnRegex);
327327

328-
if (blockedByMatch != null) {
329-
line = line.replace(TaskFormatRegularExpressions.blockedByRegex, '').trim();
330-
blockedBy = blockedByMatch[1]
328+
if (dependsOnMatch != null) {
329+
line = line.replace(TaskFormatRegularExpressions.dependsOnRegex, '').trim();
330+
dependsOn = dependsOnMatch[1]
331331
.replace(' ', '')
332332
.split(',')
333333
.filter((item) => item !== '');
@@ -364,7 +364,7 @@ export class DefaultTaskSerializer implements TaskSerializer {
364364
cancelledDate,
365365
recurrence,
366366
id,
367-
blockedBy,
367+
blockedBy: dependsOn,
368368
tags: Task.extractHashtags(line),
369369
};
370370
}

tests/TaskSerializer/DefaultTaskSerializer.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe.each(symbolMap)("DefaultTaskSerializer with '$taskFormat' symbols", ({
3333
dueDateSymbol,
3434
doneDateSymbol,
3535
idSymbol,
36-
blockedBySymbol,
36+
dependsOnSymbol,
3737
} = symbols;
3838

3939
describe('deserialize', () => {
@@ -73,13 +73,13 @@ describe.each(symbolMap)("DefaultTaskSerializer with '$taskFormat' symbols", ({
7373
});
7474

7575
it('should parse depends on one task', () => {
76-
const id = `${blockedBySymbol} 123456`;
76+
const id = `${dependsOnSymbol} 123456`;
7777
const taskDetails = deserialize(id);
7878
expect(taskDetails).toMatchTaskDetails({ blockedBy: ['123456'] });
7979
});
8080

8181
it('should parse depends on two tasks', () => {
82-
const id = `${blockedBySymbol} 123456,abc123`;
82+
const id = `${dependsOnSymbol} 123456,abc123`;
8383
const taskDetails = deserialize(id);
8484
expect(taskDetails).toMatchTaskDetails({ blockedBy: ['123456', 'abc123'] });
8585
});
@@ -141,7 +141,7 @@ describe.each(symbolMap)("DefaultTaskSerializer with '$taskFormat' symbols", ({
141141
it('should serialize depends on', () => {
142142
const task = new TaskBuilder().description('').dependsOn(['123456', 'abc123']).build();
143143
const serialized = serialize(task);
144-
expect(serialized).toEqual(` ${blockedBySymbol} 123456,abc123`);
144+
expect(serialized).toEqual(` ${dependsOnSymbol} 123456,abc123`);
145145
});
146146

147147
it('should serialize id', () => {

0 commit comments

Comments
 (0)