Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
fix(draft) Markdown transform 0.10.0 + fixes to drafting conditional …
Browse files Browse the repository at this point in the history
…variables

Signed-off-by: Jerome Simeon <[email protected]>
jeromesimeon committed Feb 18, 2020
1 parent 1ac046d commit ff27cb4
Showing 9 changed files with 48 additions and 56 deletions.
4 changes: 2 additions & 2 deletions extraction/stdlib/template.ergo
Original file line number Diff line number Diff line change
@@ -29,8 +29,8 @@ define function variableTagAs(variableName:String,text:String,format:String) : S
define function ifBlockTag(variableName:String,condition:Boolean,whenTrue:String,whenFalse:String) : String {
if getOptions().wrapVariables
then
let conditionText = if condition then "true" else "false";
return "<if id=\"" ++ variableName ++ "\" value=\"" ++ conditionText ++ "\" whenTrue=\"" ++ encode(whenTrue) ++ "\" whenFalse=\"" ++ encode(whenFalse) ++ "\"/>"
let conditionText = if condition then whenTrue else whenFalse;
return "<if id=\"" ++ variableName ++ "\" value=\"" ++ encode(conditionText) ++ "\" whenTrue=\"" ++ encode(whenTrue) ++ "\" whenFalse=\"" ++ encode(whenFalse) ++ "\"/>"
else
let conditionText = if condition then whenTrue else whenFalse;
return conditionText
2 changes: 1 addition & 1 deletion mechanization/Backend/ErgoBackend.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(*
(*
* 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
24 changes: 12 additions & 12 deletions mechanization/Version.v
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(*
* 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.
*)
* 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.
*)

(** This module defines Ergo version number *)

52 changes: 22 additions & 30 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/ergo-cli/extracted/ergoccore.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/ergo-cli/extracted/ergotopcore.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions packages/ergo-cli/test/commands.js
Original file line number Diff line number Diff line change
@@ -221,37 +221,37 @@ describe('#draft', function () {
const ctoPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenalty', 'model/model.cto');
const contractPath = { file: Path.join(EXAMPLES_DIR, 'latedeliveryandpenalty', 'data.json') };
const result = await Commands.draft(null, [ergoPath, grammarPath, ctoPath], contractPath, '1970-01-01T00:00:00Z', { wrapVariables: true });
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="true" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse=""/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="%20except%20for%20Force%20Majeure%20cases%2C" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse=""/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
});
it('should draft text for a late delivery and penalty contract without force majeure (wrap variable)', async function () {
const grammarPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenalty', 'text/grammar.tem.md');
const ergoPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenalty', 'logic/logic.ergo');
const ctoPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenalty', 'model/model.cto');
const contractPath = { file: Path.join(EXAMPLES_DIR, 'latedeliveryandpenalty', 'data-noforcemajeure.json') };
const result = await Commands.draft(null, [ergoPath, grammarPath, ctoPath], contractPath, '1970-01-01T00:00:00Z', { wrapVariables: true });
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="false" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse=""/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse=""/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
});
it('should draft text for a late delivery and penalty contract (from directory)', async function () {
const templatePath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenalty');
const contractPath = { file: Path.join(EXAMPLES_DIR, 'latedeliveryandpenalty', 'data.json') };
const result = await Commands.draft(templatePath, [], contractPath, '1970-01-01T00:00:00Z', { wrapVariables: true });
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="true" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse=""/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="%20except%20for%20Force%20Majeure%20cases%2C" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse=""/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
});
it('should draft text for a late delivery and penalty contract with else (wrap variable)', async function () {
const grammarPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenaltyelse', 'text/grammar.tem.md');
const ergoPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenaltyelse', 'logic/logic.ergo');
const ctoPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenaltyelse', 'model/model.cto');
const contractPath = { file: Path.join(EXAMPLES_DIR, 'latedeliveryandpenaltyelse', 'data.json') };
const result = await Commands.draft(null, [ergoPath, grammarPath, ctoPath], contractPath, '1970-01-01T00:00:00Z', { wrapVariables: true });
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="true" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse="%20even%20in%20cases%20of%20Force%20Majeure%2C"/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="%20except%20for%20Force%20Majeure%20cases%2C" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse="%20even%20in%20cases%20of%20Force%20Majeure%2C"/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
});
it('should draft text for a late delivery and penalty contract without force majeure with else (wrap variable)', async function () {
const grammarPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenaltyelse', 'text/grammar.tem.md');
const ergoPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenaltyelse', 'logic/logic.ergo');
const ctoPath = Path.join(EXAMPLES_DIR, 'latedeliveryandpenaltyelse', 'model/model.cto');
const contractPath = { file: Path.join(EXAMPLES_DIR, 'latedeliveryandpenaltyelse', 'data-noforcemajeure.json') };
const result = await Commands.draft(null, [ergoPath, grammarPath, ctoPath], contractPath, '1970-01-01T00:00:00Z', { wrapVariables: true });
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="false" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse="%20even%20in%20cases%20of%20Force%20Majeure%2C"/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
result.response.should.equal('Late Delivery and Penalty. In case of delayed delivery<if id="forceMajeure" value="%20even%20in%20cases%20of%20Force%20Majeure%2C" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse="%20even%20in%20cases%20of%20Force%20Majeure%2C"/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="2%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="10.5"/>% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="55.0"/>% of the total value of the Equipment involved in late delivery. If the delay is more than <variable id="termination" value="15%20days"/>, the Buyer is entitled to terminate this Contract.');
});
it('should throw when smart Ergo clause without a cto', async function () {
const ergoPath = Path.join(EXAMPLES_DIR, 'interests', 'logic/logic.ergo');
2 changes: 1 addition & 1 deletion packages/ergo-compiler/extracted/compilercore.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/ergo-compiler/package.json
Original file line number Diff line number Diff line change
@@ -27,8 +27,8 @@
},
"dependencies": {
"@accordproject/concerto-core": "0.82.6",
"@accordproject/markdown-cicero": "0.9.8",
"@accordproject/markdown-common": "0.9.8",
"@accordproject/markdown-cicero": "0.10.0",
"@accordproject/markdown-common": "0.10.0",
"acorn": "5.1.2",
"debug": "4.1.0",
"doctrine": "3.0.0",

0 comments on commit ff27cb4

Please sign in to comment.