move application.yaml to collections/windows.yaml #40
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { YamlCategory, YamlScript, YamlApplication, YamlScriptingDefinition } from 'js-yaml-loader!@/application/application.yaml';
|
||||
import { CategoryData, ScriptData, CollectionData, ScriptingDefinitionData } from 'js-yaml-loader!@/*';
|
||||
|
||||
export class YamlApplicationStub implements YamlApplication {
|
||||
export class CollectionDataStub implements CollectionData {
|
||||
public os = 'windows';
|
||||
public actions: readonly YamlCategory[] = [ getCategoryStub() ];
|
||||
public scripting: YamlScriptingDefinition = getTestDefinitionStub();
|
||||
public actions: readonly CategoryData[] = [ getCategoryStub() ];
|
||||
public scripting: ScriptingDefinitionData = getTestDefinitionStub();
|
||||
|
||||
public withActions(actions: readonly YamlCategory[]): YamlApplicationStub {
|
||||
public withActions(actions: readonly CategoryData[]): CollectionDataStub {
|
||||
this.actions = actions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withOs(os: string): YamlApplicationStub {
|
||||
public withOs(os: string): CollectionDataStub {
|
||||
this.os = os;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withScripting(scripting: YamlScriptingDefinition): YamlApplicationStub {
|
||||
public withScripting(scripting: ScriptingDefinitionData): CollectionDataStub {
|
||||
this.scripting = scripting;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
export function getCategoryStub(scriptPrefix = 'testScript'): YamlCategory {
|
||||
export function getCategoryStub(scriptPrefix = 'testScript'): CategoryData {
|
||||
return {
|
||||
category: 'category name',
|
||||
children: [
|
||||
@@ -33,7 +33,7 @@ export function getCategoryStub(scriptPrefix = 'testScript'): YamlCategory {
|
||||
};
|
||||
}
|
||||
|
||||
function getTestDefinitionStub(): YamlScriptingDefinition {
|
||||
function getTestDefinitionStub(): ScriptingDefinitionData {
|
||||
return {
|
||||
fileExtension: '.bat',
|
||||
language: ScriptingLanguage[ScriptingLanguage.batchfile],
|
||||
@@ -42,7 +42,7 @@ function getTestDefinitionStub(): YamlScriptingDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
function getScriptStub(scriptName: string, level: RecommendationLevel = RecommendationLevel.Standard): YamlScript {
|
||||
function getScriptStub(scriptName: string, level: RecommendationLevel = RecommendationLevel.Standard): ScriptData {
|
||||
return {
|
||||
name: scriptName,
|
||||
code: 'script code',
|
||||
@@ -1,16 +1,16 @@
|
||||
import { IScriptCompiler } from '@/application/Parser/Compiler/IScriptCompiler';
|
||||
import { IScriptCode } from '@/domain/IScriptCode';
|
||||
import { YamlScript } from 'js-yaml-loader!@/application.yaml';
|
||||
import { ScriptData } from 'js-yaml-loader!@/*';
|
||||
|
||||
export class ScriptCompilerStub implements IScriptCompiler {
|
||||
public compilables = new Map<YamlScript, IScriptCode>();
|
||||
public canCompile(script: YamlScript): boolean {
|
||||
public compilables = new Map<ScriptData, IScriptCode>();
|
||||
public canCompile(script: ScriptData): boolean {
|
||||
return this.compilables.has(script);
|
||||
}
|
||||
public compile(script: YamlScript): IScriptCode {
|
||||
public compile(script: ScriptData): IScriptCode {
|
||||
return this.compilables.get(script);
|
||||
}
|
||||
public withCompileAbility(script: YamlScript, result?: IScriptCode): ScriptCompilerStub {
|
||||
public withCompileAbility(script: ScriptData, result?: IScriptCode): ScriptCompilerStub {
|
||||
this.compilables.set(script, result ||
|
||||
{ execute: `compiled code of ${script.name}`, revert: `compiled revert code of ${script.name}` });
|
||||
return this;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
import { ScriptFunctionCall, YamlScript } from 'js-yaml-loader!@/application.yaml';
|
||||
import { ScriptFunctionCallData, ScriptData } from 'js-yaml-loader!@/*';
|
||||
|
||||
export class YamlScriptStub implements YamlScript {
|
||||
public static createWithCode(): YamlScriptStub {
|
||||
return new YamlScriptStub()
|
||||
export class ScriptDataStub implements ScriptData {
|
||||
public static createWithCode(): ScriptDataStub {
|
||||
return new ScriptDataStub()
|
||||
.withCode('stub-code')
|
||||
.withRevertCode('stub-revert-code');
|
||||
}
|
||||
public static createWithCall(call?: ScriptFunctionCall): YamlScriptStub {
|
||||
let instance = new YamlScriptStub();
|
||||
public static createWithCall(call?: ScriptFunctionCallData): ScriptDataStub {
|
||||
let instance = new ScriptDataStub();
|
||||
if (call) {
|
||||
instance = instance.withCall(call);
|
||||
} else {
|
||||
@@ -16,8 +16,8 @@ export class YamlScriptStub implements YamlScript {
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public static createWithoutCallOrCodes(): YamlScriptStub {
|
||||
return new YamlScriptStub();
|
||||
public static createWithoutCallOrCodes(): ScriptDataStub {
|
||||
return new ScriptDataStub();
|
||||
}
|
||||
|
||||
public name = 'valid-name';
|
||||
@@ -29,38 +29,38 @@ export class YamlScriptStub implements YamlScript {
|
||||
|
||||
private constructor() { }
|
||||
|
||||
public withName(name: string): YamlScriptStub {
|
||||
public withName(name: string): ScriptDataStub {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withDocs(docs: string[]): YamlScriptStub {
|
||||
public withDocs(docs: string[]): ScriptDataStub {
|
||||
this.docs = docs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withCode(code: string): YamlScriptStub {
|
||||
public withCode(code: string): ScriptDataStub {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withRevertCode(revertCode: string): YamlScriptStub {
|
||||
public withRevertCode(revertCode: string): ScriptDataStub {
|
||||
this.revertCode = revertCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withMockCall(): YamlScriptStub {
|
||||
public withMockCall(): ScriptDataStub {
|
||||
this.call = { function: 'func', parameters: [] };
|
||||
return this;
|
||||
}
|
||||
|
||||
public withCall(call: ScriptFunctionCall): YamlScriptStub {
|
||||
public withCall(call: ScriptFunctionCallData): ScriptDataStub {
|
||||
this.call = call;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public withRecommend(recommend: string): YamlScriptStub {
|
||||
public withRecommend(recommend: string): ScriptDataStub {
|
||||
this.recommend = recommend;
|
||||
return this;
|
||||
}
|
||||
Reference in New Issue
Block a user