ci: use Gitea API for releases #2
+25
-1
@@ -46,5 +46,29 @@
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { parseStudyLoadTable };
|
function parseProfilePage(html) {
|
||||||
|
const result = {};
|
||||||
|
const bMatch = /<b>([\s\S]*?)<\/b>/i.exec(html);
|
||||||
|
if (bMatch) result.program = cleanText(bMatch[1]);
|
||||||
|
|
||||||
|
const smallMatch = /<small>([\s\S]*?)<\/small>/i.exec(html);
|
||||||
|
if (smallMatch) {
|
||||||
|
const lines = smallMatch[1].split(/<br\s*\/?>/i).map(cleanText).filter(Boolean);
|
||||||
|
result.semester = lines[lines.length - 1] || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const kvRe = /<td[^>]*>([\s\S]*?)<\/td>\s*<td[^>]*class="bold"[^>]*>([\s\S]*?)<\/td>/gi;
|
||||||
|
let m;
|
||||||
|
while ((m = kvRe.exec(html)) !== null) {
|
||||||
|
const key = cleanText(m[1]);
|
||||||
|
const val = cleanText(m[2]);
|
||||||
|
if (/full name/i.test(key)) result.fullName = val;
|
||||||
|
else if (/student id/i.test(key)) result.studentId = val;
|
||||||
|
else if (/year level/i.test(key)) result.yearLevel = val;
|
||||||
|
else if (/student type/i.test(key)) result.studentType = val;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { parseStudyLoadTable, parseProfilePage };
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ const assert = require('node:assert');
|
|||||||
const fs = require('node:fs');
|
const fs = require('node:fs');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const { parseStudyLoadTable } = require('../parsers.js');
|
const { parseStudyLoadTable } = require('../parsers.js');
|
||||||
|
const { parseProfilePage } = require('../parsers.js');
|
||||||
|
|
||||||
const fixture = fs.readFileSync(path.join(__dirname, 'fixtures', 'study-load-table.html'), 'utf8');
|
const fixture = fs.readFileSync(path.join(__dirname, 'fixtures', 'study-load-table.html'), 'utf8');
|
||||||
|
const profileFixture = fs.readFileSync(path.join(__dirname, 'fixtures', 'profile.html'), 'utf8');
|
||||||
|
|
||||||
test('parseStudyLoadTable extracts all course rows', () => {
|
test('parseStudyLoadTable extracts all course rows', () => {
|
||||||
const rows = parseStudyLoadTable(fixture);
|
const rows = parseStudyLoadTable(fixture);
|
||||||
@@ -26,3 +28,12 @@ test('parseStudyLoadTable handles empty faculty', () => {
|
|||||||
const it4102 = rows.find(r => r.courseCode === 'IT 4102N');
|
const it4102 = rows.find(r => r.courseCode === 'IT 4102N');
|
||||||
assert.strictEqual(it4102.faculty, '');
|
assert.strictEqual(it4102.faculty, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('parseProfilePage extracts header fields', () => {
|
||||||
|
const p = parseProfilePage(profileFixture);
|
||||||
|
assert.strictEqual(p.fullName, 'ADRIAN ALFRED CHIONG BONPIN');
|
||||||
|
assert.strictEqual(p.studentId, '22103625');
|
||||||
|
assert.strictEqual(p.yearLevel, '4');
|
||||||
|
assert.strictEqual(p.program, 'BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY');
|
||||||
|
assert.strictEqual(p.semester, '1ST Semester 2026');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user