commit | c9e82f0cc8b6609493ae891afd4f4901d68afa2c | [log] [tgz] |
---|---|---|
author | Mohamed Ishad <ishad.19@cse.mrt.ac.lk> | Thu Mar 09 18:28:29 2023 +0530 |
committer | GitHub <noreply@github.com> | Thu Mar 09 13:58:29 2023 +0100 |
tree | d045e5c5925b8d7134ce18e909c338ba6fe18a86 | |
parent | 6abc42a74b76700ad02fa1c1ebd94951b62626b9 [diff] |
Fix YamlEditor.update method leaving trailing spaces at eol (#42) * Fix for selecting the correct index in insertion * Add new test cases * Add more tests and format corrections * Update `CHANGELOG.md` * Fix leaving whitespace at eol on YamlEditor.update & update the testcases * Fix formatting * Apply proposed change * Update lib/src/map_mutations.dart Co-authored-by: Jonas Finnemann Jensen <jopsen@gmail.com> --------- Co-authored-by: Jonas Finnemann Jensen <jopsen@gmail.com>
A library for YAML manipulation while preserving comments.
A simple usage example:
import 'package:yaml_edit/yaml_edit.dart'; void main() { final yamlEditor = YamlEditor('{YAML: YAML}'); yamlEditor.update(['YAML'], "YAML Ain't Markup Language"); print(yamlEditor); // Expected output: // {YAML: YAML Ain't Markup Language} }
void main() { final jsonString = r''' { "key": "value", "list": [ "first", "second", "last entry in the list" ], "map": { "multiline": "this is a fairly long string with\nline breaks..." } } '''; final jsonValue = json.decode(jsonString); // Convert jsonValue to YAML final yamlEditor = YamlEditor(''); yamlEditor.update([], jsonValue); print(yamlEditor.toString()); }
Testing is done in two strategies: Unit testing (/test/editor_test.dart
) and Golden testing (/test/golden_test.dart
). More information on Golden testing and the input/output format can be found at /test/testdata/README.md
.
These tests are automatically run with pub run test
.