mirror of
https://github.com/scratchfoundation/scratch-analysis.git
synced 2025-08-28 22:09:00 -04:00
Add backdrops data to analysis output for sb2 projects
This commit is contained in:
parent
fb0d6a46b8
commit
e0fce504c4
2 changed files with 47 additions and 0 deletions
20
lib/sb2.js
20
lib/sb2.js
|
@ -67,6 +67,24 @@ const extract = function (project, attribute, id, hash) {
|
|||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Extract summary information about backdrops including
|
||||
* count, list of backdrop names and list of backdrop hashes.
|
||||
* Backdrops are a subset of all costumes.
|
||||
* Backdrops are a costumes from the stage object.
|
||||
* @param {object} project Project object (SB2 format)
|
||||
* @return {object} Summary information
|
||||
*/
|
||||
const backdrops = function (project) {
|
||||
let stageCostumes = project.costumes;
|
||||
|
||||
return {
|
||||
count: stageCostumes.length,
|
||||
id: stageCostumes.map((sc) => sc.costumeName),
|
||||
hash: stageCostumes.map((sc) => sc.baseLayerMD5)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Extract number of sprites from a project object. Will attempt to ignore
|
||||
* "children" which are not sprites.
|
||||
|
@ -227,6 +245,8 @@ module.exports = function (project, callback) {
|
|||
costumes: extract(project, 'costumes', 'costumeName', 'baseLayerMD5')
|
||||
};
|
||||
|
||||
meta.backdrops = backdrops(project);
|
||||
|
||||
meta.cloud = cloud(project, meta.variables.id);
|
||||
|
||||
// Sprites
|
||||
|
|
|
@ -56,6 +56,15 @@ test('default (object)', t => {
|
|||
'3696356a03a8d938318876a593572843.svg'
|
||||
]);
|
||||
|
||||
t.type(result.backdrops, 'object');
|
||||
t.equal(result.backdrops.count, 1);
|
||||
t.same(result.backdrops.id, [
|
||||
'backdrop1'
|
||||
]);
|
||||
t.same(result.backdrops.hash, [
|
||||
'739b5e2a2435f6e1ec2993791b423146.png'
|
||||
]);
|
||||
|
||||
t.type(result.sprites, 'object');
|
||||
t.equal(result.sprites.count, 1);
|
||||
|
||||
|
@ -119,6 +128,15 @@ test('default (binary)', t => {
|
|||
'6e8bd9ae68fdb02b7e1e3df656a75635.svg'
|
||||
]);
|
||||
|
||||
t.type(result.backdrops, 'object');
|
||||
t.equal(result.backdrops.count, 1);
|
||||
t.same(result.backdrops.id, [
|
||||
'backdrop1'
|
||||
]);
|
||||
t.same(result.backdrops.hash, [
|
||||
'739b5e2a2435f6e1ec2993791b423146.png'
|
||||
]);
|
||||
|
||||
t.type(result.sprites, 'object');
|
||||
t.equal(result.sprites.count, 1);
|
||||
|
||||
|
@ -185,6 +203,15 @@ test('complex (binary)', t => {
|
|||
'6e8bd9ae68fdb02b7e1e3df656a75635.svg'
|
||||
]);
|
||||
|
||||
t.type(result.backdrops, 'object');
|
||||
t.equal(result.backdrops.count, 1);
|
||||
t.same(result.backdrops.id, [
|
||||
'backdrop1'
|
||||
]);
|
||||
t.same(result.backdrops.hash, [
|
||||
'5b465b3b07d39019109d8dc6d6ee6593.svg'
|
||||
]);
|
||||
|
||||
t.type(result.sprites, 'object');
|
||||
t.equal(result.sprites.count, 1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue