trusty-cms 4.1.7 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +131 -128
  3. data/INSTALL.md +2 -0
  4. data/LICENSE.md +1 -1
  5. data/app/controllers/admin/pages_controller.rb +1 -1
  6. data/app/controllers/admin/preferences_controller.rb +1 -1
  7. data/app/controllers/admin/resource_controller.rb +1 -1
  8. data/app/controllers/admin/users_controller.rb +1 -1
  9. data/app/helpers/admin/node_helper.rb +1 -1
  10. data/app/models/asset.rb +3 -3
  11. data/app/models/page.rb +3 -3
  12. data/app/models/standard_tags.rb +3 -3
  13. data/app/models/user.rb +1 -1
  14. data/config/database.mysql.yml +10 -2
  15. data/config/environments/development.rb +2 -0
  16. data/db/migrate/20210331134718_create_active_storage_tables.active_storage.rb +36 -0
  17. data/lib/generators/extension/USAGE +30 -0
  18. data/lib/generators/extension/extension_generator.rb +97 -0
  19. data/lib/generators/extension/templates/README.md +6 -0
  20. data/lib/generators/extension/templates/RSpecRakefile +109 -0
  21. data/lib/generators/extension/templates/Rakefile +25 -0
  22. data/lib/generators/extension/templates/cucumber.yml +1 -0
  23. data/lib/generators/extension/templates/cucumber_env.rb +11 -0
  24. data/lib/generators/extension/templates/cucumber_paths.rb +22 -0
  25. data/lib/generators/extension/templates/en.yml +3 -0
  26. data/lib/generators/extension/templates/extension.rb +21 -0
  27. data/lib/generators/extension/templates/functional_test.rb +15 -0
  28. data/lib/generators/extension/templates/gemspec.rb +29 -0
  29. data/lib/generators/extension/templates/lib.rb +8 -0
  30. data/lib/generators/extension/templates/migration.rb +9 -0
  31. data/lib/generators/extension/templates/radiant_config.rb +3 -0
  32. data/lib/generators/extension/templates/routes.rb +5 -0
  33. data/lib/generators/extension/templates/spec.opts +6 -0
  34. data/lib/generators/extension/templates/spec_helper.rb +42 -0
  35. data/lib/generators/extension/templates/tasks.rake +47 -0
  36. data/lib/generators/extension/templates/test_helper.rb +24 -0
  37. data/lib/generators/extension_controller/USAGE +36 -0
  38. data/lib/generators/extension_controller/extension_controller_generator.rb +84 -0
  39. data/lib/generators/extension_controller/templates/controller.rb +10 -0
  40. data/lib/generators/extension_controller/templates/controller_spec.rb +23 -0
  41. data/lib/generators/extension_controller/templates/functional_test.rb +11 -0
  42. data/lib/generators/extension_controller/templates/helper.rb +2 -0
  43. data/lib/generators/extension_controller/templates/helper_spec.rb +11 -0
  44. data/lib/generators/extension_controller/templates/helper_test.rb +4 -0
  45. data/lib/generators/extension_controller/templates/view.html.erb +2 -0
  46. data/lib/generators/extension_controller/templates/view_spec.rb +12 -0
  47. data/lib/generators/extension_mailer/USAGE +17 -0
  48. data/lib/generators/extension_mailer/extension_mailer_generator.rb +68 -0
  49. data/lib/generators/extension_mailer/templates/fixture.erb +3 -0
  50. data/lib/generators/extension_mailer/templates/mailer.rb +15 -0
  51. data/lib/generators/extension_mailer/templates/unit_test.rb +21 -0
  52. data/lib/generators/extension_mailer/templates/view.erb +3 -0
  53. data/lib/generators/extension_migration/USAGE +34 -0
  54. data/lib/generators/extension_migration/extension_migration_generator.rb +25 -0
  55. data/lib/generators/extension_migration/templates/migration.rb +11 -0
  56. data/lib/generators/extension_model/USAGE +35 -0
  57. data/lib/generators/extension_model/extension_model_generator.rb +68 -0
  58. data/lib/generators/extension_model/templates/fixtures.yml +19 -0
  59. data/lib/generators/extension_model/templates/migration.rb +16 -0
  60. data/lib/generators/extension_model/templates/model.rb +2 -0
  61. data/lib/generators/extension_model/templates/model_spec.rb +11 -0
  62. data/lib/generators/extension_model/templates/unit_test.rb +8 -0
  63. data/lib/generators/generator_base_extension.rb +18 -0
  64. data/lib/generators/instance/instance_generator.rb +148 -0
  65. data/lib/generators/instance/templates/databases/db2.yml +40 -0
  66. data/lib/generators/instance/templates/databases/mysql.yml +47 -0
  67. data/lib/generators/instance/templates/databases/postgresql.yml +44 -0
  68. data/lib/generators/instance/templates/databases/sqlite3.yml +16 -0
  69. data/lib/generators/instance/templates/databases/sqlserver.yml +21 -0
  70. data/lib/generators/instance/templates/instance_boot.rb +122 -0
  71. data/lib/generators/instance/templates/instance_config.ru +2 -0
  72. data/lib/generators/instance/templates/instance_environment.rb +93 -0
  73. data/lib/generators/instance/templates/instance_gemfile +78 -0
  74. data/lib/generators/instance/templates/instance_generate +6 -0
  75. data/lib/generators/instance/templates/instance_radiant_config.rb +16 -0
  76. data/lib/generators/instance/templates/instance_rakefile +3 -0
  77. data/lib/generators/instance/templates/instance_routes.rb +1 -0
  78. data/lib/generators/language_extension/USAGE +27 -0
  79. data/lib/generators/language_extension/language_extension_generator.rb +71 -0
  80. data/lib/generators/language_extension/templates/README +3 -0
  81. data/lib/generators/language_extension/templates/RSpecRakefile +123 -0
  82. data/lib/generators/language_extension/templates/Rakefile +25 -0
  83. data/lib/generators/language_extension/templates/available_tags.yml +553 -0
  84. data/lib/generators/language_extension/templates/cucumber.yml +1 -0
  85. data/lib/generators/language_extension/templates/cucumber_env.rb +16 -0
  86. data/lib/generators/language_extension/templates/cucumber_paths.rb +14 -0
  87. data/lib/generators/language_extension/templates/extension.rb +12 -0
  88. data/lib/generators/language_extension/templates/functional_test.rb +15 -0
  89. data/lib/generators/language_extension/templates/gemspec.rb +24 -0
  90. data/lib/generators/language_extension/templates/lang.yml +181 -0
  91. data/lib/generators/language_extension/templates/lib.rb +8 -0
  92. data/lib/generators/language_extension/templates/spec.opts +6 -0
  93. data/lib/generators/language_extension/templates/spec_helper.rb +36 -0
  94. data/lib/generators/language_extension/templates/tasks.rake +28 -0
  95. data/lib/generators/language_extension/templates/test_helper.rb +26 -0
  96. data/lib/generators/trusty_cms/USAGE +8 -0
  97. data/lib/generators/trusty_cms/templates/Rakefile.erb +7 -0
  98. data/lib/generators/trusty_cms/templates/application.rb.erb +149 -0
  99. data/lib/generators/trusty_cms/templates/boot.rb.erb +9 -0
  100. data/lib/generators/trusty_cms/templates/config.ru.erb +4 -0
  101. data/lib/generators/trusty_cms/templates/database.yml.erb +28 -0
  102. data/lib/generators/trusty_cms/templates/environment.rb.erb +5 -0
  103. data/lib/generators/trusty_cms/templates/environments/development.rb.erb +24 -0
  104. data/lib/generators/trusty_cms/templates/environments/production.rb.erb +26 -0
  105. data/lib/generators/trusty_cms/templates/environments/test.rb.erb +35 -0
  106. data/lib/generators/trusty_cms/templates/initializers/secret_token.rb.erb +13 -0
  107. data/lib/generators/trusty_cms/templates/initializers/session_store.rb.erb +8 -0
  108. data/lib/generators/trusty_cms/templates/initializers/trusty_cms_config.rb.erb +16 -0
  109. data/lib/generators/trusty_cms/templates/preinitializer.rb.erb +18 -0
  110. data/lib/generators/trusty_cms/templates/routes.rb.erb +0 -0
  111. data/lib/generators/trusty_cms/trusty_cms_generator.rb +32 -0
  112. data/lib/login_system.rb +1 -1
  113. data/lib/trusty_cms.rb +1 -1
  114. data/lib/trusty_cms/setup.rb +8 -8
  115. data/spec/dummy/config/database.yml +6 -2
  116. data/trusty_cms.gemspec +4 -5
  117. data/vendor/extensions/clipped-extension/lib/asset_tags.rb +4 -4
  118. data/yarn.lock +3 -3
  119. metadata +144 -84
  120. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +0 -126
  121. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +0 -4
  122. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +0 -56
  123. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +0 -43
  124. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +0 -28
  125. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +0 -36
  126. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +0 -76
  127. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +0 -23
  128. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +0 -87
  129. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +0 -157
  130. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +0 -142
  131. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +0 -81
  132. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +0 -114
  133. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
  134. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +0 -114
  135. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +0 -17
  136. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +0 -37
  137. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +0 -34
  138. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +0 -40
  139. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +0 -62
  140. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +0 -60
  141. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +0 -35
  142. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +0 -97
  143. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +0 -131
  144. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +0 -105
  145. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +0 -80
  146. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +0 -91
  147. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +0 -93
@@ -1,157 +0,0 @@
1
- import Scalar from '../../schema/Scalar';
2
- import { stringifyNumber } from '../../stringify';
3
- import failsafe from '../failsafe';
4
- import { boolOptions, nullOptions } from '../options';
5
- import binary from './binary';
6
- import omap from './omap';
7
- import pairs from './pairs';
8
- import set from './set';
9
- import { intTime, floatTime, timestamp } from './timestamp';
10
-
11
- var boolStringify = function boolStringify(_ref) {
12
- var value = _ref.value;
13
- return value ? boolOptions.trueStr : boolOptions.falseStr;
14
- };
15
-
16
- export default failsafe.concat([{
17
- identify: function identify(value) {
18
- return value == null;
19
- },
20
- createNode: function createNode(schema, value, ctx) {
21
- return ctx.wrapScalars ? new Scalar(null) : null;
22
- },
23
- default: true,
24
- tag: 'tag:yaml.org,2002:null',
25
- test: /^(?:~|[Nn]ull|NULL)?$/,
26
- resolve: function resolve() {
27
- return null;
28
- },
29
- options: nullOptions,
30
- stringify: function stringify() {
31
- return nullOptions.nullStr;
32
- }
33
- }, {
34
- identify: function identify(value) {
35
- return typeof value === 'boolean';
36
- },
37
- default: true,
38
- tag: 'tag:yaml.org,2002:bool',
39
- test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
40
- resolve: function resolve() {
41
- return true;
42
- },
43
- options: boolOptions,
44
- stringify: boolStringify
45
- }, {
46
- identify: function identify(value) {
47
- return typeof value === 'boolean';
48
- },
49
- default: true,
50
- tag: 'tag:yaml.org,2002:bool',
51
- test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
52
- resolve: function resolve() {
53
- return false;
54
- },
55
- options: boolOptions,
56
- stringify: boolStringify
57
- }, {
58
- identify: function identify(value) {
59
- return typeof value === 'number';
60
- },
61
- default: true,
62
- tag: 'tag:yaml.org,2002:int',
63
- format: 'BIN',
64
- test: /^0b([0-1_]+)$/,
65
- resolve: function resolve(str, bin) {
66
- return parseInt(bin.replace(/_/g, ''), 2);
67
- },
68
- stringify: function stringify(_ref2) {
69
- var value = _ref2.value;
70
- return '0b' + value.toString(2);
71
- }
72
- }, {
73
- identify: function identify(value) {
74
- return typeof value === 'number';
75
- },
76
- default: true,
77
- tag: 'tag:yaml.org,2002:int',
78
- format: 'OCT',
79
- test: /^[-+]?0([0-7_]+)$/,
80
- resolve: function resolve(str, oct) {
81
- return parseInt(oct.replace(/_/g, ''), 8);
82
- },
83
- stringify: function stringify(_ref3) {
84
- var value = _ref3.value;
85
- return (value < 0 ? '-0' : '0') + value.toString(8);
86
- }
87
- }, {
88
- identify: function identify(value) {
89
- return typeof value === 'number';
90
- },
91
- default: true,
92
- tag: 'tag:yaml.org,2002:int',
93
- test: /^[-+]?[0-9][0-9_]*$/,
94
- resolve: function resolve(str) {
95
- return parseInt(str.replace(/_/g, ''), 10);
96
- },
97
- stringify: stringifyNumber
98
- }, {
99
- identify: function identify(value) {
100
- return typeof value === 'number';
101
- },
102
- default: true,
103
- tag: 'tag:yaml.org,2002:int',
104
- format: 'HEX',
105
- test: /^0x([0-9a-fA-F_]+)$/,
106
- resolve: function resolve(str, hex) {
107
- return parseInt(hex.replace(/_/g, ''), 16);
108
- },
109
- stringify: function stringify(_ref4) {
110
- var value = _ref4.value;
111
- return (value < 0 ? '-0x' : '0x') + value.toString(16);
112
- }
113
- }, {
114
- identify: function identify(value) {
115
- return typeof value === 'number';
116
- },
117
- default: true,
118
- tag: 'tag:yaml.org,2002:float',
119
- test: /^(?:[-+]?\.inf|(\.nan))$/i,
120
- resolve: function resolve(str, nan) {
121
- return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
122
- },
123
- stringify: stringifyNumber
124
- }, {
125
- identify: function identify(value) {
126
- return typeof value === 'number';
127
- },
128
- default: true,
129
- tag: 'tag:yaml.org,2002:float',
130
- format: 'EXP',
131
- test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
132
- resolve: function resolve(str) {
133
- return parseFloat(str.replace(/_/g, ''));
134
- },
135
- stringify: function stringify(_ref5) {
136
- var value = _ref5.value;
137
- return Number(value).toExponential();
138
- }
139
- }, {
140
- identify: function identify(value) {
141
- return typeof value === 'number';
142
- },
143
- default: true,
144
- tag: 'tag:yaml.org,2002:float',
145
- test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
146
- resolve: function resolve(str, frac) {
147
- var node = new Scalar(parseFloat(str.replace(/_/g, '')));
148
-
149
- if (frac) {
150
- var f = frac.replace(/_/g, '');
151
- if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
152
- }
153
-
154
- return node;
155
- },
156
- stringify: stringifyNumber
157
- }], binary, omap, pairs, set, intTime, floatTime, timestamp);
@@ -1,142 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
6
- import _inherits from "@babel/runtime/helpers/inherits";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- import { YAMLSemanticError } from '../../errors';
9
- import _toJSON from '../../toJSON';
10
- import YAMLMap from '../../schema/Map';
11
- import Pair from '../../schema/Pair';
12
- import Scalar from '../../schema/Scalar';
13
- import YAMLSeq from '../../schema/Seq';
14
- import { createPairs, parsePairs } from './pairs';
15
- export var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
16
- _inherits(YAMLOMap, _YAMLSeq);
17
-
18
- function YAMLOMap() {
19
- var _this;
20
-
21
- _classCallCheck(this, YAMLOMap);
22
-
23
- _this = _possibleConstructorReturn(this, _getPrototypeOf(YAMLOMap).call(this));
24
-
25
- _defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this)));
26
-
27
- _defineProperty(_assertThisInitialized(_this), "delete", YAMLMap.prototype.delete.bind(_assertThisInitialized(_this)));
28
-
29
- _defineProperty(_assertThisInitialized(_this), "get", YAMLMap.prototype.get.bind(_assertThisInitialized(_this)));
30
-
31
- _defineProperty(_assertThisInitialized(_this), "has", YAMLMap.prototype.has.bind(_assertThisInitialized(_this)));
32
-
33
- _defineProperty(_assertThisInitialized(_this), "set", YAMLMap.prototype.set.bind(_assertThisInitialized(_this)));
34
-
35
- _this.tag = YAMLOMap.tag;
36
- return _this;
37
- }
38
-
39
- _createClass(YAMLOMap, [{
40
- key: "toJSON",
41
- value: function toJSON(_, ctx) {
42
- var map = new Map();
43
- if (ctx && ctx.onCreate) ctx.onCreate(map);
44
- var _iteratorNormalCompletion = true;
45
- var _didIteratorError = false;
46
- var _iteratorError = undefined;
47
-
48
- try {
49
- for (var _iterator = this.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
50
- var pair = _step.value;
51
- var key = void 0,
52
- value = void 0;
53
-
54
- if (pair instanceof Pair) {
55
- key = _toJSON(pair.key, '', ctx);
56
- value = _toJSON(pair.value, key, ctx);
57
- } else {
58
- key = _toJSON(pair, '', ctx);
59
- }
60
-
61
- if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
62
- map.set(key, value);
63
- }
64
- } catch (err) {
65
- _didIteratorError = true;
66
- _iteratorError = err;
67
- } finally {
68
- try {
69
- if (!_iteratorNormalCompletion && _iterator.return != null) {
70
- _iterator.return();
71
- }
72
- } finally {
73
- if (_didIteratorError) {
74
- throw _iteratorError;
75
- }
76
- }
77
- }
78
-
79
- return map;
80
- }
81
- }]);
82
-
83
- return YAMLOMap;
84
- }(YAMLSeq);
85
-
86
- _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
87
-
88
- function parseOMap(doc, cst) {
89
- var pairs = parsePairs(doc, cst);
90
- var seenKeys = [];
91
- var _iteratorNormalCompletion2 = true;
92
- var _didIteratorError2 = false;
93
- var _iteratorError2 = undefined;
94
-
95
- try {
96
- for (var _iterator2 = pairs.items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
97
- var key = _step2.value.key;
98
-
99
- if (key instanceof Scalar) {
100
- if (seenKeys.includes(key.value)) {
101
- var msg = 'Ordered maps must not include duplicate keys';
102
- throw new YAMLSemanticError(cst, msg);
103
- } else {
104
- seenKeys.push(key.value);
105
- }
106
- }
107
- }
108
- } catch (err) {
109
- _didIteratorError2 = true;
110
- _iteratorError2 = err;
111
- } finally {
112
- try {
113
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
114
- _iterator2.return();
115
- }
116
- } finally {
117
- if (_didIteratorError2) {
118
- throw _iteratorError2;
119
- }
120
- }
121
- }
122
-
123
- return Object.assign(new YAMLOMap(), pairs);
124
- }
125
-
126
- function createOMap(schema, iterable, ctx) {
127
- var pairs = createPairs(schema, iterable, ctx);
128
- var omap = new YAMLOMap();
129
- omap.items = pairs.items;
130
- return omap;
131
- }
132
-
133
- export default {
134
- identify: function identify(value) {
135
- return value instanceof Map;
136
- },
137
- nodeClass: YAMLOMap,
138
- default: false,
139
- tag: 'tag:yaml.org,2002:omap',
140
- resolve: parseOMap,
141
- createNode: createOMap
142
- };
@@ -1,81 +0,0 @@
1
- import { YAMLSemanticError } from '../../errors';
2
- import YAMLMap from '../../schema/Map';
3
- import Pair from '../../schema/Pair';
4
- import parseSeq from '../../schema/parseSeq';
5
- import YAMLSeq from '../../schema/Seq';
6
- export function parsePairs(doc, cst) {
7
- var seq = parseSeq(doc, cst);
8
-
9
- for (var i = 0; i < seq.items.length; ++i) {
10
- var item = seq.items[i];
11
- if (item instanceof Pair) continue;else if (item instanceof YAMLMap) {
12
- if (item.items.length > 1) {
13
- var msg = 'Each pair must have its own sequence indicator';
14
- throw new YAMLSemanticError(cst, msg);
15
- }
16
-
17
- var pair = item.items[0] || new Pair();
18
- if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore;
19
- if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment;
20
- item = pair;
21
- }
22
- seq.items[i] = item instanceof Pair ? item : new Pair(item);
23
- }
24
-
25
- return seq;
26
- }
27
- export function createPairs(schema, iterable, ctx) {
28
- var pairs = new YAMLSeq(schema);
29
- pairs.tag = 'tag:yaml.org,2002:pairs';
30
- var _iteratorNormalCompletion = true;
31
- var _didIteratorError = false;
32
- var _iteratorError = undefined;
33
-
34
- try {
35
- for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
36
- var it = _step.value;
37
- var key = void 0,
38
- value = void 0;
39
-
40
- if (Array.isArray(it)) {
41
- if (it.length === 2) {
42
- key = it[0];
43
- value = it[1];
44
- } else throw new TypeError("Expected [key, value] tuple: ".concat(it));
45
- } else if (it && it instanceof Object) {
46
- var keys = Object.keys(it);
47
-
48
- if (keys.length === 1) {
49
- key = keys[0];
50
- value = it[key];
51
- } else throw new TypeError("Expected { key: value } tuple: ".concat(it));
52
- } else {
53
- key = it;
54
- }
55
-
56
- var pair = schema.createPair(key, value, ctx);
57
- pairs.items.push(pair);
58
- }
59
- } catch (err) {
60
- _didIteratorError = true;
61
- _iteratorError = err;
62
- } finally {
63
- try {
64
- if (!_iteratorNormalCompletion && _iterator.return != null) {
65
- _iterator.return();
66
- }
67
- } finally {
68
- if (_didIteratorError) {
69
- throw _iteratorError;
70
- }
71
- }
72
- }
73
-
74
- return pairs;
75
- }
76
- export default {
77
- default: false,
78
- tag: 'tag:yaml.org,2002:pairs',
79
- resolve: parsePairs,
80
- createNode: createPairs
81
- };
@@ -1,114 +0,0 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _get from "@babel/runtime/helpers/get";
7
- import _inherits from "@babel/runtime/helpers/inherits";
8
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- import { YAMLSemanticError } from '../../errors';
10
- import YAMLMap, { findPair } from '../../schema/Map';
11
- import Pair from '../../schema/Pair';
12
- import parseMap from '../../schema/parseMap';
13
- import Scalar from '../../schema/Scalar';
14
- export var YAMLSet = /*#__PURE__*/function (_YAMLMap) {
15
- _inherits(YAMLSet, _YAMLMap);
16
-
17
- function YAMLSet() {
18
- var _this;
19
-
20
- _classCallCheck(this, YAMLSet);
21
-
22
- _this = _possibleConstructorReturn(this, _getPrototypeOf(YAMLSet).call(this));
23
- _this.tag = YAMLSet.tag;
24
- return _this;
25
- }
26
-
27
- _createClass(YAMLSet, [{
28
- key: "add",
29
- value: function add(key) {
30
- var pair = key instanceof Pair ? key : new Pair(key);
31
- var prev = findPair(this.items, pair.key);
32
- if (!prev) this.items.push(pair);
33
- }
34
- }, {
35
- key: "get",
36
- value: function get(key, keepPair) {
37
- var pair = findPair(this.items, key);
38
- return !keepPair && pair instanceof Pair ? pair.key instanceof Scalar ? pair.key.value : pair.key : pair;
39
- }
40
- }, {
41
- key: "set",
42
- value: function set(key, value) {
43
- if (typeof value !== 'boolean') throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat(_typeof(value)));
44
- var prev = findPair(this.items, key);
45
-
46
- if (prev && !value) {
47
- this.items.splice(this.items.indexOf(prev), 1);
48
- } else if (!prev && value) {
49
- this.items.push(new Pair(key));
50
- }
51
- }
52
- }, {
53
- key: "toJSON",
54
- value: function toJSON(_, ctx) {
55
- return _get(_getPrototypeOf(YAMLSet.prototype), "toJSON", this).call(this, _, ctx, Set);
56
- }
57
- }, {
58
- key: "toString",
59
- value: function toString(ctx, onComment, onChompKeep) {
60
- if (!ctx) return JSON.stringify(this);
61
- if (this.hasAllNullValues()) return _get(_getPrototypeOf(YAMLSet.prototype), "toString", this).call(this, ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
62
- }
63
- }]);
64
-
65
- return YAMLSet;
66
- }(YAMLMap);
67
-
68
- _defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
69
-
70
- function parseSet(doc, cst) {
71
- var map = parseMap(doc, cst);
72
- if (!map.hasAllNullValues()) throw new YAMLSemanticError(cst, 'Set items must all have null values');
73
- return Object.assign(new YAMLSet(), map);
74
- }
75
-
76
- function createSet(schema, iterable, ctx) {
77
- var set = new YAMLSet();
78
- var _iteratorNormalCompletion = true;
79
- var _didIteratorError = false;
80
- var _iteratorError = undefined;
81
-
82
- try {
83
- for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
84
- var value = _step.value;
85
- set.items.push(schema.createPair(value, null, ctx));
86
- }
87
- } catch (err) {
88
- _didIteratorError = true;
89
- _iteratorError = err;
90
- } finally {
91
- try {
92
- if (!_iteratorNormalCompletion && _iterator.return != null) {
93
- _iterator.return();
94
- }
95
- } finally {
96
- if (_didIteratorError) {
97
- throw _iteratorError;
98
- }
99
- }
100
- }
101
-
102
- return set;
103
- }
104
-
105
- export default {
106
- identify: function identify(value) {
107
- return value instanceof Set;
108
- },
109
- nodeClass: YAMLSet,
110
- default: false,
111
- tag: 'tag:yaml.org,2002:set',
112
- resolve: parseSet,
113
- createNode: createSet
114
- };