-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from SAP/gen_filter
added generator filter logic
- Loading branch information
Showing
12 changed files
with
455 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
{ | ||
"require": ["ts-node/register/transpile-only"], | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["src/run-configuration*", "src/cfView.ts", "src/cfViewCommands.ts", "src/sql-tools.ts"], | ||
"reporter": ["lcov", "text"], | ||
"extension": [".ts"], | ||
"all": true, | ||
"temp-dir": "./reports/.nyc_output", | ||
"report-dir": "./reports/coverage", | ||
"check-coverage": true, | ||
"branches": 0, | ||
"lines": 24, | ||
"functions": 17, | ||
"statements": 25 | ||
"branches": 22, | ||
"lines": 41, | ||
"functions": 30, | ||
"statements": 41 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,42 @@ | ||
export enum Type { | ||
import * as _ from "lodash"; | ||
|
||
export enum GeneratorType { | ||
project = "project", | ||
module = "module" | ||
} | ||
module = "module", | ||
all = "all" | ||
} | ||
|
||
function getCategories(filterObject?: any): string[] { | ||
const categories: string[] = _.get(filterObject, 'categories', []); | ||
if (_.isArray(categories)) { | ||
const strValues = _.filter(categories, category => { | ||
return _.isString(category); | ||
}); | ||
if (_.isEmpty(_.difference(categories, strValues))) { | ||
return categories; | ||
} | ||
} | ||
|
||
return []; | ||
} | ||
|
||
function getType(filterObject?: any): GeneratorType { | ||
const genType: GeneratorType = _.get(filterObject, "type", GeneratorType.all); | ||
if (_.includes(_.values(GeneratorType), genType)) { | ||
return genType; | ||
} | ||
|
||
return GeneratorType.all; | ||
} | ||
|
||
export class GeneratorFilter { | ||
constructor(public readonly type: GeneratorType, | ||
public readonly categories: string[]) {} | ||
|
||
public static create(filterObject?: any) { | ||
const categories: string[] = getCategories(filterObject); | ||
const type: GeneratorType = getType(filterObject); | ||
|
||
return new GeneratorFilter(type, categories); | ||
} | ||
} |
Oops, something went wrong.