Commit 09d5cb70 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Renamed serializer methods and DRY'd codeclimate reported code

parent 7760d3b2
......@@ -267,24 +267,30 @@ const RepoHelper = {
},
/* eslint-enable no-param-reassign */
blobToSimpleBlob(blob) {
return {
type: 'blob',
name: blob.name,
url: blob.url,
icon: this.toFA(blob.icon),
lastCommitMessage: blob.last_commit.message,
lastCommitUpdate: blob.last_commit.committed_date,
level: 0,
};
serializeBlob(blob) {
const simpleBlob = this.serializeRepoEntity('blob', blob);
simpleBlob.lastCommitMessage = blob.last_commit.message;
simpleBlob.lastCommitUpdate = blob.last_commit.committed_date;
return simpleBlob;
},
serializeTree(tree) {
return this.serializeRepoEntity('tree', tree);
},
serializeSubmodule(submodule) {
return this.serializeRepoEntity('submodule', submodule);
},
treeToSimpleTree(tree) {
serializeRepoEntity(type, entity) {
const { url, name, icon } = entity;
return {
type: 'tree',
name: tree.name,
url: tree.url,
icon: this.toFA(tree.icon),
type,
name,
url,
icon: this.toFA(icon),
level: 0,
};
},
......@@ -294,21 +300,15 @@ const RepoHelper = {
// push in blobs
data.blobs.forEach((blob) => {
a.push(this.blobToSimpleBlob(blob));
a.push(this.serializeBlob(blob));
});
data.trees.forEach((tree) => {
a.push(this.treeToSimpleTree(tree));
a.push(this.serializeTree(tree));
});
data.submodules.forEach((submodule) => {
a.push({
type: 'submodule',
name: submodule.name,
url: submodule.url,
icon: this.toFA(submodule.icon),
level: 0,
});
a.push(this.serializeSubmodule(submodule));
});
return a;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment