-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(core): Add distinct AstModelManager
Signed-off-by: Jerome Simeon <[email protected]>
- Loading branch information
Jerome Simeon
authored and
Jerome Simeon
committed
Mar 15, 2022
1 parent
2c3bf4e
commit a7665fd
Showing
5 changed files
with
101 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const BaseModelManager = require('./basemodelmanager'); | ||
|
||
// How to create a modelfile from a cto file | ||
const astProcessFile = (name, data) => { | ||
return { | ||
ast: data, | ||
definitions: null, | ||
fileName: name, | ||
}; | ||
}; | ||
|
||
/** | ||
* Manages the Concerto model files in AST format. | ||
* | ||
* The structure of {@link Resource}s (Assets, Transactions, Participants) is modelled | ||
* in a set of Concerto files. The contents of these files are managed | ||
* by the {@link ModelManager}. Each Concerto file has a single namespace and contains | ||
* a set of asset, transaction and participant type definitions. | ||
* | ||
* Concerto applications load their Concerto files and then call the {@link ModelManager#addModelFile addModelFile} | ||
* method to register the Concerto file(s) with the ModelManager. | ||
* | ||
* @memberof module:concerto-core | ||
*/ | ||
class AstModelManager extends BaseModelManager { | ||
/** | ||
* Create the ModelManager. | ||
* @constructor | ||
* @param {object} [options] - Serializer options | ||
*/ | ||
constructor(options) { | ||
super(options, astProcessFile); | ||
} | ||
} | ||
|
||
module.exports = AstModelManager; |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const AstModelManager = require('../lib/astmodelmanager'); | ||
|
||
const chai = require('chai'); | ||
chai.should(); | ||
chai.use(require('chai-things')); | ||
chai.use(require('chai-as-promised')); | ||
const sinon = require('sinon'); | ||
|
||
describe('AstModelManager', () => { | ||
let sandbox; | ||
let modelManager; | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.createSandbox(); | ||
modelManager = new AstModelManager(); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
describe('#isModelManager', () => { | ||
it('should return true', () => { | ||
modelManager.isModelManager().should.be.true; | ||
}); | ||
}); | ||
|
||
}); |