occam-model 1.0.484

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.swcrc +5 -0
  2. package/README.md +78 -0
  3. package/lib/constants.js +34 -0
  4. package/lib/dependencies.js +114 -0
  5. package/lib/dependency.js +81 -0
  6. package/lib/directory.js +107 -0
  7. package/lib/entries.js +245 -0
  8. package/lib/file.js +162 -0
  9. package/lib/fileNames.js +49 -0
  10. package/lib/files.js +121 -0
  11. package/lib/index.js +83 -0
  12. package/lib/mixins/bnf.js +43 -0
  13. package/lib/mixins/entries.js +99 -0
  14. package/lib/mixins/files.js +46 -0
  15. package/lib/mixins/metaJSON.js +36 -0
  16. package/lib/mixins/vocabulary.js +43 -0
  17. package/lib/multiplers.js +26 -0
  18. package/lib/project.js +98 -0
  19. package/lib/projects.js +112 -0
  20. package/lib/propertyNames.js +26 -0
  21. package/lib/release.js +152 -0
  22. package/lib/releases.js +112 -0
  23. package/lib/shortenedVersion.js +105 -0
  24. package/lib/types.js +22 -0
  25. package/lib/utilities/content.js +42 -0
  26. package/lib/utilities/filePath.js +105 -0
  27. package/lib/utilities/files.js +99 -0
  28. package/lib/utilities/metaJSON.js +197 -0
  29. package/lib/utilities/name.js +18 -0
  30. package/lib/utilities/query.js +36 -0
  31. package/lib/utilities/validate.js +26 -0
  32. package/lib/utilities/version.js +71 -0
  33. package/lib/version.js +160 -0
  34. package/license.txt +48 -0
  35. package/package.json +34 -0
  36. package/src/constants.js +7 -0
  37. package/src/dependencies.js +65 -0
  38. package/src/dependency.js +43 -0
  39. package/src/directory.js +60 -0
  40. package/src/entries.js +206 -0
  41. package/src/file.js +113 -0
  42. package/src/fileNames.js +18 -0
  43. package/src/files.js +66 -0
  44. package/src/index.js +18 -0
  45. package/src/mixins/bnf.js +51 -0
  46. package/src/mixins/entries.js +69 -0
  47. package/src/mixins/files.js +61 -0
  48. package/src/mixins/metaJSON.js +44 -0
  49. package/src/mixins/vocabulary.js +51 -0
  50. package/src/multiplers.js +5 -0
  51. package/src/project.js +63 -0
  52. package/src/projects.js +54 -0
  53. package/src/propertyNames.js +5 -0
  54. package/src/release.js +151 -0
  55. package/src/releases.js +54 -0
  56. package/src/shortenedVersion.js +71 -0
  57. package/src/types.js +4 -0
  58. package/src/utilities/content.js +22 -0
  59. package/src/utilities/filePath.js +66 -0
  60. package/src/utilities/files.js +114 -0
  61. package/src/utilities/metaJSON.js +254 -0
  62. package/src/utilities/name.js +13 -0
  63. package/src/utilities/query.js +25 -0
  64. package/src/utilities/validate.js +5 -0
  65. package/src/utilities/version.js +70 -0
  66. package/src/version.js +123 -0
package/src/file.js ADDED
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ import { FILE_TYPE } from "./types";
4
+ import { convertContentTabsToWhitespace } from "./utilities/content"
5
+
6
+ export default class File {
7
+ constructor(path, content, released) {
8
+ this.path = path;
9
+ this.content = content;
10
+ this.released = released;
11
+ }
12
+
13
+ getPath() {
14
+ return this.path;
15
+ }
16
+
17
+ getContent() {
18
+ return this.content;
19
+ }
20
+
21
+ isReleased() {
22
+ return this.released;
23
+ }
24
+
25
+ isFile() {
26
+ const file = true;
27
+
28
+ return file;
29
+ }
30
+
31
+ isDirectory() {
32
+ const directory = false;
33
+
34
+ return directory;
35
+ }
36
+
37
+ setPath(path) {
38
+ this.path = path;
39
+ }
40
+
41
+ setContent(content) {
42
+ this.content = content;
43
+ }
44
+
45
+ setReleased(released) {
46
+ this.released = released;
47
+ }
48
+
49
+ matchFilePath(filePath) {
50
+ const filePathMatches = (this.path === filePath);
51
+
52
+ return filePathMatches;
53
+ }
54
+
55
+ toJSON() {
56
+ const { type } = File,
57
+ path = this.path,
58
+ content = this.content,
59
+ released = this.released,
60
+ json = {
61
+ type,
62
+ path,
63
+ content,
64
+ released
65
+ };
66
+
67
+ return json;
68
+ }
69
+
70
+ static type = FILE_TYPE;
71
+
72
+ static fromJSON(json) {
73
+ let file = null;
74
+
75
+ if (json !== null) {
76
+ const { type } = json;
77
+
78
+ if (type === FILE_TYPE) {
79
+ let { content } = json;
80
+
81
+ const { path, released } = json;
82
+
83
+ content = convertContentTabsToWhitespace(content); ///
84
+
85
+ file = new File(path, content, released);
86
+ }
87
+ }
88
+
89
+ return file;
90
+ }
91
+
92
+ static fromDocument(document) {
93
+ const filePath = document.getFilePath(),
94
+ released = document.isReleased(),
95
+ path = filePath; ///
96
+
97
+ let content = document.getContent();
98
+
99
+ content = convertContentTabsToWhitespace(content); ///
100
+
101
+ const file = new File(path, content, released);
102
+
103
+ return file;
104
+ }
105
+
106
+ static fromPathContentAndReleased(path, content, released) {
107
+ content = convertContentTabsToWhitespace(content); ///
108
+
109
+ const file = new File(path, content, released);
110
+
111
+ return file;
112
+ }
113
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ export const README_MD_FILE_NAME = "README.md";
4
+ export const META_JSON_FILE_NAME = "meta.json";
5
+
6
+ export const TERM_BNF_FILE_NAME = "term.bnf";
7
+ export const STATEMENT_BNF_FILE_NAME = "statement.bnf";
8
+ export const TYPE_VOCABULARY_FILE_NAME = "type.vcb";
9
+ export const SYMBOL_VOCABULARY_FILE_NAME = "symbol.vcb";
10
+
11
+ export default {
12
+ README_MD_FILE_NAME,
13
+ META_JSON_FILE_NAME,
14
+ TERM_BNF_FILE_NAME,
15
+ STATEMENT_BNF_FILE_NAME,
16
+ TYPE_VOCABULARY_FILE_NAME,
17
+ SYMBOL_VOCABULARY_FILE_NAME
18
+ };
package/src/files.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ import File from "./file";
4
+
5
+ export default class Files {
6
+ constructor(array) {
7
+ this.array = array;
8
+ }
9
+
10
+ getFilePaths() {
11
+ const filePaths = this.mapFile((file) => {
12
+ const filePath = file.getPath();
13
+
14
+ return filePath;
15
+ });
16
+
17
+ return filePaths;
18
+ }
19
+
20
+ addFile(file) { this.array.push(file); }
21
+
22
+ mapFile(callback) { return this.array.map(callback); }
23
+
24
+ someFile(callback) { return this.array.some(callback); }
25
+
26
+ reduceFile(callback, initialValue) { return this.array.reduce(callback, initialValue); }
27
+
28
+ forEachFile(callback) { this.array.forEach(callback); }
29
+
30
+ findFile(callback) { return this.array.find(callback) || null; } ///
31
+
32
+ toJSON() {
33
+ const filesJSON = this.array.map((file) => {
34
+ const fileJSON = (file !== null) ?
35
+ file.toJSON() :
36
+ null;
37
+
38
+ return fileJSON;
39
+ }),
40
+ json = filesJSON; ///
41
+
42
+ return json;
43
+ }
44
+
45
+ static fromJSON(json) {
46
+ const filesJSON = json, ///
47
+ array = [],
48
+ files = new Files(array);
49
+
50
+ filesJSON.forEach((fileJSON) => {
51
+ const json = fileJSON, ///
52
+ file = File.fromJSON(json);
53
+
54
+ files.addFile(file);
55
+ });
56
+
57
+ return files;
58
+ }
59
+
60
+ static fromNothing() {
61
+ const array = [],
62
+ files = new Files(array);
63
+
64
+ return files;
65
+ }
66
+ }
package/src/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ export { default as File } from "./file";
4
+ export { default as Files } from "./files";
5
+ export { default as Version } from "./version";
6
+ export { default as Entries } from "./entries";
7
+ export { default as Project } from "./project";
8
+ export { default as Release } from "./release";
9
+ export { default as Projects } from "./projects";
10
+ export { default as Releases } from "./releases";
11
+ export { default as Directory } from "./directory";
12
+ export { default as fileNames } from "./fileNames";
13
+ export { default as Dependency } from "./dependency";
14
+ export { default as Dependencies } from "./dependencies";
15
+ export { default as ShortenedVersion } from "./shortenedVersion";
16
+ export { default as contentUtilities } from "./utilities/content";
17
+ export { default as filePathUtilities } from "./utilities/filePath";
18
+ export { default as metaJSONUtilities } from "./utilities/metaJSON";
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ import { EMPTY_STRING } from "../constants";
4
+ import { fileNameFromFilePath } from "../utilities/name";
5
+ import { TERM_BNF_FILE_NAME, STATEMENT_BNF_FILE_NAME } from "../fileNames";
6
+
7
+ function getBNF(bnfFileName) {
8
+ let bnf = EMPTY_STRING;
9
+
10
+ const customGrammarBNFFiles = this.getCustomGrammarBNFFiles(),
11
+ customGrammarBNFFile = customGrammarBNFFiles.find((customGrammarBNFFile) => {
12
+ const customGrammarBNFFilePath = customGrammarBNFFile.getPath(),
13
+ customGrammarBNFFileName = fileNameFromFilePath(customGrammarBNFFilePath);
14
+
15
+ if (customGrammarBNFFileName === bnfFileName) {
16
+ return true;
17
+ }
18
+ }) || null;
19
+
20
+ if (customGrammarBNFFile !== null) {
21
+ const customGrammarBNFFileContent = customGrammarBNFFile.getContent();
22
+
23
+ bnf = customGrammarBNFFileContent; ///
24
+ }
25
+
26
+ return bnf;
27
+ }
28
+
29
+ function getTermBNF() {
30
+ const fileName = TERM_BNF_FILE_NAME, ///
31
+ bnf = this.getBNF(fileName),
32
+ termBNF = bnf; ///
33
+
34
+ return termBNF;
35
+ }
36
+
37
+ function getStatementBNF() {
38
+ const fileName = STATEMENT_BNF_FILE_NAME, ///
39
+ bnf = this.getBNF(fileName),
40
+ statementBNF = bnf; ///
41
+
42
+ return statementBNF;
43
+ }
44
+
45
+ const bnfMixins = {
46
+ getBNF,
47
+ getTermBNF,
48
+ getStatementBNF
49
+ };
50
+
51
+ export default bnfMixins;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ function forEachFile(callback) { return this.entries.forEachFile(callback); }
4
+
5
+ function findFile(filePath) { return this.entries.findFile(filePath); }
6
+
7
+ function getBNF() { return this.entries.getBNF(); }
8
+
9
+ function getFiles() { return this.entries.getFiles(); }
10
+
11
+ function getTermBNF() { return this.entries.getTermBNF(); }
12
+
13
+ function getVersion() { return this.entries.getVersion(); }
14
+
15
+ function getFilePaths() { return this.entries.getFilePaths(); }
16
+
17
+ function getVocabulary() { return this.entries.getVocabulary(); }
18
+
19
+ function getRepository() { return this.entries.getRepository(); }
20
+
21
+ function getReadmeFile() { return this.entries.getReadmeFile(); }
22
+
23
+ function getStatementBNF() { return this.entries.getStatementBNF(); }
24
+
25
+ function getDependencies() { return this.entries.getDependencies(); }
26
+
27
+ function getTypeVocabulary() { return this.entries.getTypeVocabulary(); }
28
+
29
+ function getSymbolVocabulary() { return this.entries.getSymbolVocabulary(); }
30
+
31
+ function getMetaJSONFile() { return this.entries.getMetaJSONFile(); }
32
+
33
+ function getFurtleFiles() { return this.entries.getFurtleFiles(); }
34
+
35
+ function getNominalFiles() { return this.entries.getNominalFiles(); }
36
+
37
+ function getDirectoryPaths() { return this.entries.getDirectoryPaths(); }
38
+
39
+ function getDependencyNames() { return this.entries.getDependencyNames(); }
40
+
41
+ function getCustomGrammarBNFFiles() { return this.entries.getCustomGrammarBNFFiles(); }
42
+
43
+ function getCustomGrammarVocabularyFiles() { return this.entries.getCustomGrammarVocabularyFiles(); }
44
+
45
+ const entriesMixins = {
46
+ forEachFile,
47
+ findFile,
48
+ getBNF,
49
+ getFiles,
50
+ getTermBNF,
51
+ getVersion,
52
+ getFilePaths,
53
+ getVocabulary,
54
+ getRepository,
55
+ getReadmeFile,
56
+ getStatementBNF,
57
+ getDependencies,
58
+ getTypeVocabulary,
59
+ getSymbolVocabulary,
60
+ getMetaJSONFile,
61
+ getFurtleFiles,
62
+ getNominalFiles,
63
+ getDirectoryPaths,
64
+ getDependencyNames,
65
+ getCustomGrammarBNFFiles,
66
+ getCustomGrammarVocabularyFiles
67
+ };
68
+
69
+ export default entriesMixins;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ import { readmeFileFromFiles,
4
+ furtleFilesFromFiles,
5
+ nominalFilesFromFiles,
6
+ metaJSONFileFromFiles,
7
+ customGrammarBNFFilesFromFiles,
8
+ customGrammarVocabularyFilesFromFiles } from "../utilities/files";
9
+
10
+ function getReadmeFile() {
11
+ const files = this.getFiles(),
12
+ readmeFile = readmeFileFromFiles(files);
13
+
14
+ return readmeFile;
15
+ }
16
+
17
+ function getFurtleFiles() {
18
+ const files = this.getFiles(),
19
+ furtleFiles = furtleFilesFromFiles(files);
20
+
21
+ return furtleFiles;
22
+ }
23
+
24
+ function getNominalFiles() {
25
+ const files = this.getFiles(),
26
+ nominalFiles = nominalFilesFromFiles(files);
27
+
28
+ return nominalFiles;
29
+ }
30
+
31
+ function getMetaJSONFile() {
32
+ const files = this.getFiles(),
33
+ metaJSONFile = metaJSONFileFromFiles(files);
34
+
35
+ return metaJSONFile;
36
+ }
37
+
38
+ function getCustomGrammarBNFFiles() {
39
+ const files = this.getFiles(),
40
+ customGrammarBNFFiles = customGrammarBNFFilesFromFiles(files);
41
+
42
+ return customGrammarBNFFiles;
43
+ }
44
+
45
+ function getCustomGrammarVocabularyFiles() {
46
+ const files = this.getFiles(),
47
+ customGrammarVocabularyFiles = customGrammarVocabularyFilesFromFiles(files);
48
+
49
+ return customGrammarVocabularyFiles;
50
+ }
51
+
52
+ const filesMixins = {
53
+ getReadmeFile,
54
+ getFurtleFiles,
55
+ getNominalFiles,
56
+ getMetaJSONFile,
57
+ getCustomGrammarBNFFiles,
58
+ getCustomGrammarVocabularyFiles
59
+ };
60
+
61
+ export default filesMixins;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ import { versionFromDocumentNode, repositoryFromDocumentNode, dependenciesFromDocumentNode, dependencyNamesFromDocumentNode, documentNodeFromMetaJSONFile } from "../utilities/metaJSON";
4
+
5
+ function getVersion() {
6
+ const metaJSONFile = this.getMetaJSONFile(),
7
+ documentNode = documentNodeFromMetaJSONFile(metaJSONFile),
8
+ version = versionFromDocumentNode(documentNode);
9
+
10
+ return version;
11
+ }
12
+
13
+ function getRepository() {
14
+ const metaJSONFile = this.getMetaJSONFile(),
15
+ documentNode = documentNodeFromMetaJSONFile(metaJSONFile),
16
+ repository = repositoryFromDocumentNode(documentNode);
17
+
18
+ return repository;
19
+ }
20
+
21
+ function getDependencies() {
22
+ const metaJSONFile = this.getMetaJSONFile(),
23
+ documentNode = documentNodeFromMetaJSONFile(metaJSONFile),
24
+ dependencies = dependenciesFromDocumentNode(documentNode);
25
+
26
+ return dependencies;
27
+ }
28
+
29
+ function getDependencyNames() {
30
+ const metaJSONFile = this.getMetaJSONFile(),
31
+ documentNode = documentNodeFromMetaJSONFile(metaJSONFile),
32
+ dependencyNames = dependencyNamesFromDocumentNode(documentNode);
33
+
34
+ return dependencyNames;
35
+ }
36
+
37
+ const metaJSONMixins = {
38
+ getVersion,
39
+ getRepository,
40
+ getDependencies,
41
+ getDependencyNames
42
+ };
43
+
44
+ export default metaJSONMixins;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ import { EMPTY_STRING } from "../constants";
4
+ import { fileNameFromFilePath } from "../utilities/name";
5
+ import { TYPE_VOCABULARY_FILE_NAME, SYMBOL_VOCABULARY_FILE_NAME } from "../fileNames";
6
+
7
+ function getVocabulary(vocabularyFileName) {
8
+ let vocabulary = EMPTY_STRING;
9
+
10
+ const customGrammarVocabularyFiles = this.getCustomGrammarVocabularyFiles(),
11
+ customGrammarVocabularyFile = customGrammarVocabularyFiles.find((customGrammarVocabularyFile) => {
12
+ const customGrammarVocabularyFilePath = customGrammarVocabularyFile.getPath(),
13
+ customGrammarVocabularyFileName = fileNameFromFilePath(customGrammarVocabularyFilePath);
14
+
15
+ if (customGrammarVocabularyFileName === vocabularyFileName) {
16
+ return true;
17
+ }
18
+ }) || null;
19
+
20
+ if (customGrammarVocabularyFile !== null) {
21
+ const customGrammarVocabularyFileContent = customGrammarVocabularyFile.getContent();
22
+
23
+ vocabulary = customGrammarVocabularyFileContent; ///
24
+ }
25
+
26
+ return vocabulary;
27
+ }
28
+
29
+ function getTypeVocabulary() {
30
+ const fileName = TYPE_VOCABULARY_FILE_NAME, ///
31
+ vocabulary = this.getVocabulary(fileName),
32
+ typeVocabulary = vocabulary; ///
33
+
34
+ return typeVocabulary;
35
+ }
36
+
37
+ function getSymbolVocabulary() {
38
+ const fileName = SYMBOL_VOCABULARY_FILE_NAME, ///
39
+ vocabulary = this.getVocabulary(fileName),
40
+ symbolVocabulary = vocabulary; ///
41
+
42
+ return symbolVocabulary;
43
+ }
44
+
45
+ const vocabularyMixins = {
46
+ getVocabulary,
47
+ getTypeVocabulary,
48
+ getSymbolVocabulary
49
+ };
50
+
51
+ export default vocabularyMixins;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export const MAJOR_NUMBER_MULTIPLIER = 1e12;
4
+ export const MINOR_NUMBER_MULTIPLIER = 1e6;
5
+ export const PATCH_NUMBER_MULTIPLIER = 1e0;
package/src/project.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ import Entries from "./entries";
4
+ import entriesMixins from "./mixins/entries";
5
+
6
+ class Project {
7
+ constructor(name, entries) {
8
+ this.name = name;
9
+ this.entries = entries;
10
+ }
11
+
12
+ getName() {
13
+ return this.name;
14
+ }
15
+
16
+ getEntries() {
17
+ return this.entries;
18
+ }
19
+
20
+ toJSON() {
21
+ const entriesJSON = this.entries.toJSON(),
22
+ name = this.name,
23
+ entries = entriesJSON, ///
24
+ json = {
25
+ name,
26
+ entries
27
+ };
28
+
29
+ return json;
30
+ }
31
+
32
+ static fromJSON(json) {
33
+ let { entries } = json;
34
+
35
+ const { name } = json,
36
+ entriesJSON = entries; ///
37
+
38
+ json = entriesJSON; ///
39
+
40
+ entries = Entries.fromJSON(json); ///
41
+
42
+ const project = new Project(name, entries);
43
+
44
+ return project;
45
+ }
46
+
47
+ static fromName(name) {
48
+ const entries = Entries.fromNothing(),
49
+ project = new Project(name, entries);
50
+
51
+ return project;
52
+ }
53
+
54
+ static fromNameAndEntries(name, entries) {
55
+ const project = new Project(name, entries);
56
+
57
+ return project;
58
+ }
59
+ }
60
+
61
+ Object.assign(Project.prototype, entriesMixins);
62
+
63
+ export default Project;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ import { asynchronousUtilities } from "necessary";
4
+
5
+ import Project from "./project";
6
+
7
+ const { forEach } = asynchronousUtilities;
8
+
9
+ export default class Projects {
10
+ constructor(array) {
11
+ this.array = array;
12
+ }
13
+
14
+ getLength() { return this.array.length; }
15
+
16
+ addProject(project) { this.array.push(project); }
17
+
18
+ mapProject(callback) { return this.array.map(callback); }
19
+
20
+ reduceProject(callback, initialValue) { return this.array.reduce(callback, initialValue); }
21
+
22
+ forEachProject(callback) { this.array.forEach(callback); }
23
+
24
+ asynchronousForEachProject(callback, done) { forEach(this.array, callback, done); }
25
+
26
+ toJSON() {
27
+ const json = this.array.map((project) => {
28
+ const projectJSON = project.toJSON();
29
+
30
+ return projectJSON;
31
+ });
32
+
33
+ return json;
34
+ }
35
+
36
+ static fromJSON(json) {
37
+ const array = json.map((json) => { ///
38
+ const project = Project.fromJSON(json);
39
+
40
+ return project;
41
+ }),
42
+ projects = new Projects(array);
43
+
44
+ return projects;
45
+ }
46
+
47
+ static fromNothing() {
48
+ const array = [],
49
+ projects = new Projects(array);
50
+
51
+ return projects;
52
+ }
53
+ }
54
+
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export const VERSION_PROPERTY_NAME = "version";
4
+ export const REPOSITORY_PROPERTY_NAME = "repository";
5
+ export const DEPENDENCIES_PROPERTY_NAME = "dependencies";