Skip to content

Commit 49ad2b9

Browse files
committed
Refactor: Completely decoupled the name and image recipe from IQ Puzzles
1 parent 6566232 commit 49ad2b9

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/recipes/name_and_image/NameAndImageRecipe.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ export class NameAndImageRecipe<ParsedElement extends NameAndImage> implements R
3636
return await updater.update(
3737
content,
3838

39-
this.#markdownTableStringToPuzzles.bind(this),
40-
this.#scrapePuzzles.bind(this),
41-
this.#puzzlesToMarkdownTableString.bind(this)
39+
this.#markdownTableStringToItems.bind(this),
40+
this.#scrapeItems.bind(this),
41+
this.#itemsToMarkdownTableString.bind(this)
4242
);
4343
}
4444

45-
async #scrapePuzzles(): Promise<ParsedElement[]> {
45+
async #scrapeItems(): Promise<ParsedElement[]> {
4646
const scraper = new WebsiteScraper(
4747
this.scrapeURLs.map(url => ({ url }))
4848
);
@@ -53,30 +53,30 @@ export class NameAndImageRecipe<ParsedElement extends NameAndImage> implements R
5353
);
5454
}
5555

56-
#puzzlesToMarkdownTableString(headers: string[], puzzles: ParsedElement[]): string {
56+
#itemsToMarkdownTableString(headers: string[], items: ParsedElement[]): string {
5757
const headerRow = this.markdownTableFactory.tableRowNode(
5858
headers.map(header => this.markdownTableFactory.textTableCellNode(header))
5959
);
60-
const puzzleRows = puzzles
60+
const itemRows = items
6161
.sort((first, second) =>
6262
first.name.localeCompare(second.name, undefined, {
6363
numeric: true,
6464
sensitivity: 'base'
6565
})
6666
)
67-
.map(puzzle =>
67+
.map(item =>
6868
this.markdownTableFactory.tableRowNode([
69-
this.markdownTableFactory.textTableCellNode(puzzle.name),
70-
this.markdownTableFactory.imageTableCellNode(puzzle.imageLink, 100),
71-
this.markdownTableFactory.textTableCellNode(puzzle.status)
69+
this.markdownTableFactory.textTableCellNode(item.name),
70+
this.markdownTableFactory.imageTableCellNode(item.imageLink, 100),
71+
this.markdownTableFactory.textTableCellNode(item.status)
7272
])
7373
);
74-
const table = this.markdownTableFactory.table(headerRow, puzzleRows);
74+
const table = this.markdownTableFactory.table(headerRow, itemRows);
7575

7676
return this.markdownTableConverter.tableToString(table);
7777
}
7878

79-
#markdownTableStringToPuzzles(markdownTableString: string): ParsedElement[] {
79+
#markdownTableStringToItems(markdownTableString: string): ParsedElement[] {
8080
const arrayOfArrays = this.markdownTableConverter.arrayOfArraysFromString(markdownTableString);
8181
const imageLinkRegex = new RegexFactory().imageMarkdownLinkRegex();
8282

0 commit comments

Comments
 (0)