trusty-cms 4.1.8 → 4.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +121 -121
  4. data/INSTALL.md +2 -0
  5. data/LICENSE.md +1 -1
  6. data/app/assets/javascripts/admin/custom_file_upload.js +7 -0
  7. data/app/controllers/admin/pages_controller.rb +1 -1
  8. data/app/controllers/admin/preferences_controller.rb +1 -1
  9. data/app/controllers/admin/resource_controller.rb +1 -1
  10. data/app/controllers/admin/users_controller.rb +1 -1
  11. data/app/helpers/admin/node_helper.rb +1 -1
  12. data/app/models/asset.rb +3 -3
  13. data/app/models/page.rb +3 -3
  14. data/app/models/standard_tags.rb +3 -3
  15. data/app/models/user.rb +1 -1
  16. data/app/views/admin/assets/new.html.haml +2 -0
  17. data/config/database.mysql.yml +10 -2
  18. data/config/environments/development.rb +2 -0
  19. data/db/migrate/20210331134718_create_active_storage_tables.active_storage.rb +36 -0
  20. data/lib/generators/extension/USAGE +30 -0
  21. data/lib/generators/extension/extension_generator.rb +97 -0
  22. data/lib/generators/extension/templates/README.md +6 -0
  23. data/lib/generators/extension/templates/RSpecRakefile +109 -0
  24. data/lib/generators/extension/templates/Rakefile +25 -0
  25. data/lib/generators/extension/templates/cucumber.yml +1 -0
  26. data/lib/generators/extension/templates/cucumber_env.rb +11 -0
  27. data/lib/generators/extension/templates/cucumber_paths.rb +22 -0
  28. data/lib/generators/extension/templates/en.yml +3 -0
  29. data/lib/generators/extension/templates/extension.rb +21 -0
  30. data/lib/generators/extension/templates/functional_test.rb +15 -0
  31. data/lib/generators/extension/templates/gemspec.rb +29 -0
  32. data/lib/generators/extension/templates/lib.rb +8 -0
  33. data/lib/generators/extension/templates/migration.rb +9 -0
  34. data/lib/generators/extension/templates/radiant_config.rb +3 -0
  35. data/lib/generators/extension/templates/routes.rb +5 -0
  36. data/lib/generators/extension/templates/spec.opts +6 -0
  37. data/lib/generators/extension/templates/spec_helper.rb +42 -0
  38. data/lib/generators/extension/templates/tasks.rake +47 -0
  39. data/lib/generators/extension/templates/test_helper.rb +24 -0
  40. data/lib/generators/extension_controller/USAGE +36 -0
  41. data/lib/generators/extension_controller/extension_controller_generator.rb +84 -0
  42. data/lib/generators/extension_controller/templates/controller.rb +10 -0
  43. data/lib/generators/extension_controller/templates/controller_spec.rb +23 -0
  44. data/lib/generators/extension_controller/templates/functional_test.rb +11 -0
  45. data/lib/generators/extension_controller/templates/helper.rb +2 -0
  46. data/lib/generators/extension_controller/templates/helper_spec.rb +11 -0
  47. data/lib/generators/extension_controller/templates/helper_test.rb +4 -0
  48. data/lib/generators/extension_controller/templates/view.html.erb +2 -0
  49. data/lib/generators/extension_controller/templates/view_spec.rb +12 -0
  50. data/lib/generators/extension_mailer/USAGE +17 -0
  51. data/lib/generators/extension_mailer/extension_mailer_generator.rb +68 -0
  52. data/lib/generators/extension_mailer/templates/fixture.erb +3 -0
  53. data/lib/generators/extension_mailer/templates/mailer.rb +15 -0
  54. data/lib/generators/extension_mailer/templates/unit_test.rb +21 -0
  55. data/lib/generators/extension_mailer/templates/view.erb +3 -0
  56. data/lib/generators/extension_migration/USAGE +34 -0
  57. data/lib/generators/extension_migration/extension_migration_generator.rb +25 -0
  58. data/lib/generators/extension_migration/templates/migration.rb +11 -0
  59. data/lib/generators/extension_model/USAGE +35 -0
  60. data/lib/generators/extension_model/extension_model_generator.rb +68 -0
  61. data/lib/generators/extension_model/templates/fixtures.yml +19 -0
  62. data/lib/generators/extension_model/templates/migration.rb +16 -0
  63. data/lib/generators/extension_model/templates/model.rb +2 -0
  64. data/lib/generators/extension_model/templates/model_spec.rb +11 -0
  65. data/lib/generators/extension_model/templates/unit_test.rb +8 -0
  66. data/lib/generators/generator_base_extension.rb +18 -0
  67. data/lib/generators/instance/instance_generator.rb +148 -0
  68. data/lib/generators/instance/templates/databases/db2.yml +40 -0
  69. data/lib/generators/instance/templates/databases/mysql.yml +47 -0
  70. data/lib/generators/instance/templates/databases/postgresql.yml +44 -0
  71. data/lib/generators/instance/templates/databases/sqlite3.yml +16 -0
  72. data/lib/generators/instance/templates/databases/sqlserver.yml +21 -0
  73. data/lib/generators/instance/templates/instance_boot.rb +122 -0
  74. data/lib/generators/instance/templates/instance_config.ru +2 -0
  75. data/lib/generators/instance/templates/instance_environment.rb +93 -0
  76. data/lib/generators/instance/templates/instance_gemfile +78 -0
  77. data/lib/generators/instance/templates/instance_generate +6 -0
  78. data/lib/generators/instance/templates/instance_radiant_config.rb +16 -0
  79. data/lib/generators/instance/templates/instance_rakefile +3 -0
  80. data/lib/generators/instance/templates/instance_routes.rb +1 -0
  81. data/lib/generators/language_extension/USAGE +27 -0
  82. data/lib/generators/language_extension/language_extension_generator.rb +71 -0
  83. data/lib/generators/language_extension/templates/README +3 -0
  84. data/lib/generators/language_extension/templates/RSpecRakefile +123 -0
  85. data/lib/generators/language_extension/templates/Rakefile +25 -0
  86. data/lib/generators/language_extension/templates/available_tags.yml +553 -0
  87. data/lib/generators/language_extension/templates/cucumber.yml +1 -0
  88. data/lib/generators/language_extension/templates/cucumber_env.rb +16 -0
  89. data/lib/generators/language_extension/templates/cucumber_paths.rb +14 -0
  90. data/lib/generators/language_extension/templates/extension.rb +12 -0
  91. data/lib/generators/language_extension/templates/functional_test.rb +15 -0
  92. data/lib/generators/language_extension/templates/gemspec.rb +24 -0
  93. data/lib/generators/language_extension/templates/lang.yml +181 -0
  94. data/lib/generators/language_extension/templates/lib.rb +8 -0
  95. data/lib/generators/language_extension/templates/spec.opts +6 -0
  96. data/lib/generators/language_extension/templates/spec_helper.rb +36 -0
  97. data/lib/generators/language_extension/templates/tasks.rake +28 -0
  98. data/lib/generators/language_extension/templates/test_helper.rb +26 -0
  99. data/lib/generators/trusty_cms/USAGE +8 -0
  100. data/lib/generators/trusty_cms/templates/Rakefile.erb +7 -0
  101. data/lib/generators/trusty_cms/templates/application.rb.erb +149 -0
  102. data/lib/generators/trusty_cms/templates/boot.rb.erb +9 -0
  103. data/lib/generators/trusty_cms/templates/config.ru.erb +4 -0
  104. data/lib/generators/trusty_cms/templates/database.yml.erb +28 -0
  105. data/lib/generators/trusty_cms/templates/environment.rb.erb +5 -0
  106. data/lib/generators/trusty_cms/templates/environments/development.rb.erb +24 -0
  107. data/lib/generators/trusty_cms/templates/environments/production.rb.erb +26 -0
  108. data/lib/generators/trusty_cms/templates/environments/test.rb.erb +35 -0
  109. data/lib/generators/trusty_cms/templates/initializers/secret_token.rb.erb +13 -0
  110. data/lib/generators/trusty_cms/templates/initializers/session_store.rb.erb +8 -0
  111. data/lib/generators/trusty_cms/templates/initializers/trusty_cms_config.rb.erb +16 -0
  112. data/lib/generators/trusty_cms/templates/preinitializer.rb.erb +18 -0
  113. data/lib/generators/trusty_cms/templates/routes.rb.erb +0 -0
  114. data/lib/generators/trusty_cms/trusty_cms_generator.rb +32 -0
  115. data/lib/login_system.rb +1 -1
  116. data/lib/trusty_cms.rb +1 -1
  117. data/lib/trusty_cms/setup.rb +8 -8
  118. data/spec/dummy/config/database.yml +6 -2
  119. data/trusty_cms.gemspec +5 -6
  120. data/vendor/extensions/clipped-extension/lib/asset_tags.rb +4 -4
  121. data/yarn.lock +6 -6
  122. metadata +487 -118
  123. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +0 -126
  124. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +0 -4
  125. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +0 -56
  126. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +0 -43
  127. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +0 -28
  128. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +0 -36
  129. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +0 -76
  130. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +0 -23
  131. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +0 -87
  132. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +0 -157
  133. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +0 -142
  134. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +0 -81
  135. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +0 -114
  136. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
  137. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +0 -114
  138. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +0 -17
  139. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +0 -37
  140. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +0 -34
  141. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +0 -40
  142. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +0 -62
  143. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +0 -60
  144. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +0 -35
  145. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +0 -97
  146. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +0 -131
  147. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +0 -105
  148. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +0 -80
  149. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +0 -91
  150. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +0 -93
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.strOptions = exports.nullOptions = exports.boolOptions = exports.binaryOptions = void 0;
7
-
8
- var _constants = require("../constants");
9
-
10
- const binaryOptions = {
11
- defaultType: _constants.Type.BLOCK_LITERAL,
12
- lineWidth: 76
13
- };
14
- exports.binaryOptions = binaryOptions;
15
- const boolOptions = {
16
- trueStr: 'true',
17
- falseStr: 'false'
18
- };
19
- exports.boolOptions = boolOptions;
20
- const nullOptions = {
21
- nullStr: 'null'
22
- };
23
- exports.nullOptions = nullOptions;
24
- const strOptions = {
25
- defaultType: _constants.Type.PLAIN,
26
- doubleQuoted: {
27
- jsonEncoding: false,
28
- minMultiLineLength: 40
29
- },
30
- fold: {
31
- lineWidth: 80,
32
- minContentWidth: 20
33
- }
34
- };
35
- exports.strOptions = strOptions;
@@ -1,97 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _constants = require("../../constants");
9
-
10
- var _errors = require("../../errors");
11
-
12
- var _stringify = require("../../stringify");
13
-
14
- var _string = require("../failsafe/string");
15
-
16
- var _options = require("../options");
17
-
18
- /* global atob, btoa, Buffer */
19
- var _default = {
20
- identify: value => value instanceof Uint8Array,
21
- // Buffer inherits from Uint8Array
22
- default: false,
23
- tag: 'tag:yaml.org,2002:binary',
24
-
25
- /**
26
- * Returns a Buffer in node and an Uint8Array in browsers
27
- *
28
- * To use the resulting buffer as an image, you'll want to do something like:
29
- *
30
- * const blob = new Blob([buffer], { type: 'image/jpeg' })
31
- * document.querySelector('#photo').src = URL.createObjectURL(blob)
32
- */
33
- resolve: (doc, node) => {
34
- const src = (0, _string.resolveString)(doc, node);
35
-
36
- if (typeof Buffer === 'function') {
37
- return Buffer.from(src, 'base64');
38
- } else if (typeof atob === 'function') {
39
- // On IE 11, atob() can't handle newlines
40
- const str = atob(src.replace(/[\n\r]/g, ''));
41
- const buffer = new Uint8Array(str.length);
42
-
43
- for (let i = 0; i < str.length; ++i) buffer[i] = str.charCodeAt(i);
44
-
45
- return buffer;
46
- } else {
47
- const msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
48
- doc.errors.push(new _errors.YAMLReferenceError(node, msg));
49
- return null;
50
- }
51
- },
52
- options: _options.binaryOptions,
53
- stringify: ({
54
- comment,
55
- type,
56
- value
57
- }, ctx, onComment, onChompKeep) => {
58
- let src;
59
-
60
- if (typeof Buffer === 'function') {
61
- src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
62
- } else if (typeof btoa === 'function') {
63
- let s = '';
64
-
65
- for (let i = 0; i < value.length; ++i) s += String.fromCharCode(value[i]);
66
-
67
- src = btoa(s);
68
- } else {
69
- throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
70
- }
71
-
72
- if (!type) type = _options.binaryOptions.defaultType;
73
-
74
- if (type === _constants.Type.QUOTE_DOUBLE) {
75
- value = src;
76
- } else {
77
- const {
78
- lineWidth
79
- } = _options.binaryOptions;
80
- const n = Math.ceil(src.length / lineWidth);
81
- const lines = new Array(n);
82
-
83
- for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
84
- lines[i] = src.substr(o, lineWidth);
85
- }
86
-
87
- value = lines.join(type === _constants.Type.BLOCK_LITERAL ? '\n' : ' ');
88
- }
89
-
90
- return (0, _stringify.stringifyString)({
91
- comment,
92
- type,
93
- value
94
- }, ctx, onComment, onChompKeep);
95
- }
96
- };
97
- exports.default = _default;
@@ -1,131 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _Scalar = _interopRequireDefault(require("../../schema/Scalar"));
9
-
10
- var _stringify = require("../../stringify");
11
-
12
- var _failsafe = _interopRequireDefault(require("../failsafe"));
13
-
14
- var _options = require("../options");
15
-
16
- var _binary = _interopRequireDefault(require("./binary"));
17
-
18
- var _omap = _interopRequireDefault(require("./omap"));
19
-
20
- var _pairs = _interopRequireDefault(require("./pairs"));
21
-
22
- var _set = _interopRequireDefault(require("./set"));
23
-
24
- var _timestamp = require("./timestamp");
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- const boolStringify = ({
29
- value
30
- }) => value ? _options.boolOptions.trueStr : _options.boolOptions.falseStr;
31
-
32
- var _default = _failsafe.default.concat([{
33
- identify: value => value == null,
34
- createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
35
- default: true,
36
- tag: 'tag:yaml.org,2002:null',
37
- test: /^(?:~|[Nn]ull|NULL)?$/,
38
- resolve: () => null,
39
- options: _options.nullOptions,
40
- stringify: () => _options.nullOptions.nullStr
41
- }, {
42
- identify: value => typeof value === 'boolean',
43
- default: true,
44
- tag: 'tag:yaml.org,2002:bool',
45
- test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
46
- resolve: () => true,
47
- options: _options.boolOptions,
48
- stringify: boolStringify
49
- }, {
50
- identify: value => typeof value === 'boolean',
51
- default: true,
52
- tag: 'tag:yaml.org,2002:bool',
53
- test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
54
- resolve: () => false,
55
- options: _options.boolOptions,
56
- stringify: boolStringify
57
- }, {
58
- identify: value => typeof value === 'number',
59
- default: true,
60
- tag: 'tag:yaml.org,2002:int',
61
- format: 'BIN',
62
- test: /^0b([0-1_]+)$/,
63
- resolve: (str, bin) => parseInt(bin.replace(/_/g, ''), 2),
64
- stringify: ({
65
- value
66
- }) => '0b' + value.toString(2)
67
- }, {
68
- identify: value => typeof value === 'number',
69
- default: true,
70
- tag: 'tag:yaml.org,2002:int',
71
- format: 'OCT',
72
- test: /^[-+]?0([0-7_]+)$/,
73
- resolve: (str, oct) => parseInt(oct.replace(/_/g, ''), 8),
74
- stringify: ({
75
- value
76
- }) => (value < 0 ? '-0' : '0') + value.toString(8)
77
- }, {
78
- identify: value => typeof value === 'number',
79
- default: true,
80
- tag: 'tag:yaml.org,2002:int',
81
- test: /^[-+]?[0-9][0-9_]*$/,
82
- resolve: str => parseInt(str.replace(/_/g, ''), 10),
83
- stringify: _stringify.stringifyNumber
84
- }, {
85
- identify: value => typeof value === 'number',
86
- default: true,
87
- tag: 'tag:yaml.org,2002:int',
88
- format: 'HEX',
89
- test: /^0x([0-9a-fA-F_]+)$/,
90
- resolve: (str, hex) => parseInt(hex.replace(/_/g, ''), 16),
91
- stringify: ({
92
- value
93
- }) => (value < 0 ? '-0x' : '0x') + value.toString(16)
94
- }, {
95
- identify: value => typeof value === 'number',
96
- default: true,
97
- tag: 'tag:yaml.org,2002:float',
98
- test: /^(?:[-+]?\.inf|(\.nan))$/i,
99
- resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
100
- stringify: _stringify.stringifyNumber
101
- }, {
102
- identify: value => typeof value === 'number',
103
- default: true,
104
- tag: 'tag:yaml.org,2002:float',
105
- format: 'EXP',
106
- test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
107
- resolve: str => parseFloat(str.replace(/_/g, '')),
108
- stringify: ({
109
- value
110
- }) => Number(value).toExponential()
111
- }, {
112
- identify: value => typeof value === 'number',
113
- default: true,
114
- tag: 'tag:yaml.org,2002:float',
115
- test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
116
-
117
- resolve(str, frac) {
118
- const node = new _Scalar.default(parseFloat(str.replace(/_/g, '')));
119
-
120
- if (frac) {
121
- const f = frac.replace(/_/g, '');
122
- if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
123
- }
124
-
125
- return node;
126
- },
127
-
128
- stringify: _stringify.stringifyNumber
129
- }], _binary.default, _omap.default, _pairs.default, _set.default, _timestamp.intTime, _timestamp.floatTime, _timestamp.timestamp);
130
-
131
- exports.default = _default;
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.YAMLOMap = void 0;
7
-
8
- var _errors = require("../../errors");
9
-
10
- var _toJSON = _interopRequireDefault(require("../../toJSON"));
11
-
12
- var _Map = _interopRequireDefault(require("../../schema/Map"));
13
-
14
- var _Pair = _interopRequireDefault(require("../../schema/Pair"));
15
-
16
- var _Scalar = _interopRequireDefault(require("../../schema/Scalar"));
17
-
18
- var _Seq = _interopRequireDefault(require("../../schema/Seq"));
19
-
20
- var _pairs = require("./pairs");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
-
26
- class YAMLOMap extends _Seq.default {
27
- constructor() {
28
- super();
29
-
30
- _defineProperty(this, "add", _Map.default.prototype.add.bind(this));
31
-
32
- _defineProperty(this, "delete", _Map.default.prototype.delete.bind(this));
33
-
34
- _defineProperty(this, "get", _Map.default.prototype.get.bind(this));
35
-
36
- _defineProperty(this, "has", _Map.default.prototype.has.bind(this));
37
-
38
- _defineProperty(this, "set", _Map.default.prototype.set.bind(this));
39
-
40
- this.tag = YAMLOMap.tag;
41
- }
42
-
43
- toJSON(_, ctx) {
44
- const map = new Map();
45
- if (ctx && ctx.onCreate) ctx.onCreate(map);
46
-
47
- for (const pair of this.items) {
48
- let key, value;
49
-
50
- if (pair instanceof _Pair.default) {
51
- key = (0, _toJSON.default)(pair.key, '', ctx);
52
- value = (0, _toJSON.default)(pair.value, key, ctx);
53
- } else {
54
- key = (0, _toJSON.default)(pair, '', ctx);
55
- }
56
-
57
- if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
58
- map.set(key, value);
59
- }
60
-
61
- return map;
62
- }
63
-
64
- }
65
-
66
- exports.YAMLOMap = YAMLOMap;
67
-
68
- _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
69
-
70
- function parseOMap(doc, cst) {
71
- const pairs = (0, _pairs.parsePairs)(doc, cst);
72
- const seenKeys = [];
73
-
74
- for (const {
75
- key
76
- } of pairs.items) {
77
- if (key instanceof _Scalar.default) {
78
- if (seenKeys.includes(key.value)) {
79
- const msg = 'Ordered maps must not include duplicate keys';
80
- throw new _errors.YAMLSemanticError(cst, msg);
81
- } else {
82
- seenKeys.push(key.value);
83
- }
84
- }
85
- }
86
-
87
- return Object.assign(new YAMLOMap(), pairs);
88
- }
89
-
90
- function createOMap(schema, iterable, ctx) {
91
- const pairs = (0, _pairs.createPairs)(schema, iterable, ctx);
92
- const omap = new YAMLOMap();
93
- omap.items = pairs.items;
94
- return omap;
95
- }
96
-
97
- var _default = {
98
- identify: value => value instanceof Map,
99
- nodeClass: YAMLOMap,
100
- default: false,
101
- tag: 'tag:yaml.org,2002:omap',
102
- resolve: parseOMap,
103
- createNode: createOMap
104
- };
105
- exports.default = _default;
@@ -1,80 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parsePairs = parsePairs;
7
- exports.createPairs = createPairs;
8
- exports.default = void 0;
9
-
10
- var _errors = require("../../errors");
11
-
12
- var _Map = _interopRequireDefault(require("../../schema/Map"));
13
-
14
- var _Pair = _interopRequireDefault(require("../../schema/Pair"));
15
-
16
- var _parseSeq = _interopRequireDefault(require("../../schema/parseSeq"));
17
-
18
- var _Seq = _interopRequireDefault(require("../../schema/Seq"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function parsePairs(doc, cst) {
23
- const seq = (0, _parseSeq.default)(doc, cst);
24
-
25
- for (let i = 0; i < seq.items.length; ++i) {
26
- let item = seq.items[i];
27
- if (item instanceof _Pair.default) continue;else if (item instanceof _Map.default) {
28
- if (item.items.length > 1) {
29
- const msg = 'Each pair must have its own sequence indicator';
30
- throw new _errors.YAMLSemanticError(cst, msg);
31
- }
32
-
33
- const pair = item.items[0] || new _Pair.default();
34
- if (item.commentBefore) pair.commentBefore = pair.commentBefore ? `${item.commentBefore}\n${pair.commentBefore}` : item.commentBefore;
35
- if (item.comment) pair.comment = pair.comment ? `${item.comment}\n${pair.comment}` : item.comment;
36
- item = pair;
37
- }
38
- seq.items[i] = item instanceof _Pair.default ? item : new _Pair.default(item);
39
- }
40
-
41
- return seq;
42
- }
43
-
44
- function createPairs(schema, iterable, ctx) {
45
- const pairs = new _Seq.default(schema);
46
- pairs.tag = 'tag:yaml.org,2002:pairs';
47
-
48
- for (const it of iterable) {
49
- let key, value;
50
-
51
- if (Array.isArray(it)) {
52
- if (it.length === 2) {
53
- key = it[0];
54
- value = it[1];
55
- } else throw new TypeError(`Expected [key, value] tuple: ${it}`);
56
- } else if (it && it instanceof Object) {
57
- const keys = Object.keys(it);
58
-
59
- if (keys.length === 1) {
60
- key = keys[0];
61
- value = it[key];
62
- } else throw new TypeError(`Expected { key: value } tuple: ${it}`);
63
- } else {
64
- key = it;
65
- }
66
-
67
- const pair = schema.createPair(key, value, ctx);
68
- pairs.items.push(pair);
69
- }
70
-
71
- return pairs;
72
- }
73
-
74
- var _default = {
75
- default: false,
76
- tag: 'tag:yaml.org,2002:pairs',
77
- resolve: parsePairs,
78
- createNode: createPairs
79
- };
80
- exports.default = _default;