Skip to content

Commit

Permalink
feat(web mode and cli interface): web mode and cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter committed Oct 7, 2021
1 parent 01086fd commit 95c924d
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 221 deletions.
19 changes: 12 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upgreat-readable/criteria",
"version": "1.1.4",
"version": "1.2.0-rc.1",
"description": "readable criterion package",
"repository": {
"type": "git",
Expand All @@ -27,6 +27,7 @@
},
"dependencies": {
"@types/node": "^14.11.5",
"commander": "^8.2.0",
"typescript": "next"
},
"scripts": {
Expand Down
15 changes: 15 additions & 0 deletions src/bin/criteriacli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/local/bin/node
import { program } from 'commander';
import fs from 'fs';
import { CriterionFabric } from '../estimate/criterionFabric';

program.requiredOption('-p, --path <path>', 'Markup file must have path');

program.parse(process.argv);
const options = program.opts();

const fileContent = fs.readFileSync(options.path).toString('utf8');
const fileContentJson = JSON.parse(fileContent);

const criteriaResult = new CriterionFabric(fileContentJson).run();
console.log(criteriaResult);
21 changes: 12 additions & 9 deletions src/estimate/criterionFabric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,33 @@ export class CriterionFabric implements iCriterion.ICriterionFabric {
this.subject = this.getSubj();
}

public run(): ArCriterions {
let subjObject = this.decisionCriterionClass(this.subject);
public run(webMode: boolean = false): ArCriterions {
let subjObject = this.decisionCriterionClass(this.subject, webMode);
return subjObject.analyze();
}

public decisionCriterionClass(subj: string): AbstractProcessor {
public decisionCriterionClass(
subj: string,
webMode: boolean,
): AbstractProcessor {
if (!subj) {
throw new Error('Не был получен код предмета.');
}

switch (subj) {
case subjCodes.russianLanguage:
return new RussianL(this.markUpExample);
return new RussianL(this.markUpExample, webMode);
case subjCodes.russianLanguageFree:
return new RussianLFree(this.markUpExample);
return new RussianLFree(this.markUpExample, webMode);
case subjCodes.literature:
return new Literature(this.markUpExample);
return new Literature(this.markUpExample, webMode);
case subjCodes.socialScience:
return new SocialScience(this.markUpExample);
return new SocialScience(this.markUpExample, webMode);
case subjCodes.history:
return new History(this.markUpExample);
return new History(this.markUpExample, webMode);
case subjCodes.englishLanguage:
case subjCodes.englishLanguageFree:
return new EnglishL(this.markUpExample);
return new EnglishL(this.markUpExample, webMode);
}

throw new Error(
Expand Down
Loading

0 comments on commit 95c924d

Please sign in to comment.