trusty-cms 4.1.0 → 4.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +98 -98
  4. data/README.md +1 -1
  5. data/Rakefile +7 -7
  6. data/app/assets/javascripts/admin/assets.js +1 -1
  7. data/app/assets/javascripts/rad_social/rad_ajax_form.js +3 -0
  8. data/app/assets/javascripts/rad_social/rad_email.js +0 -1
  9. data/app/assets/javascripts/rad_social/rad_email_form.js +2 -7
  10. data/app/assets/stylesheets/admin/partials/_forms.scss +1 -1
  11. data/app/assets/stylesheets/admin/partials/_messages.scss +7 -2
  12. data/app/assets/stylesheets/admin/partials/_popup.scss +1 -1
  13. data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
  14. data/app/controllers/admin/assets_controller.rb +21 -31
  15. data/app/controllers/admin/configuration_controller.rb +9 -11
  16. data/app/controllers/admin/extensions_controller.rb +3 -3
  17. data/app/controllers/admin/layouts_controller.rb +3 -4
  18. data/app/controllers/admin/page_attachments_controller.rb +5 -5
  19. data/app/controllers/admin/page_fields_controller.rb +3 -4
  20. data/app/controllers/admin/page_parts_controller.rb +4 -5
  21. data/app/controllers/admin/pages_controller.rb +55 -56
  22. data/app/controllers/admin/references_controller.rb +1 -1
  23. data/app/controllers/admin/resource_controller.rb +132 -130
  24. data/app/controllers/admin/sites_controller.rb +4 -4
  25. data/app/controllers/admin/snippets_controller.rb +3 -4
  26. data/app/controllers/admin/users_controller.rb +16 -16
  27. data/app/controllers/application_controller.rb +47 -48
  28. data/app/controllers/site_controller.rb +51 -48
  29. data/app/controllers/social_mailer_controller.rb +12 -22
  30. data/app/helpers/admin/configuration_helper.rb +19 -20
  31. data/app/helpers/admin/layouts_helper.rb +0 -1
  32. data/app/helpers/admin/node_helper.rb +27 -24
  33. data/app/helpers/admin/pages_helper.rb +2 -2
  34. data/app/helpers/admin/preferences_helper.rb +0 -1
  35. data/app/helpers/admin/references_helper.rb +9 -10
  36. data/app/helpers/admin/regions_helper.rb +3 -3
  37. data/app/helpers/application_helper.rb +32 -33
  38. data/app/helpers/rad_social_helper.rb +8 -11
  39. data/app/helpers/scoped_helper.rb +1 -3
  40. data/app/helpers/sites_helper.rb +4 -4
  41. data/app/mailers/devise_mailer.rb +3 -4
  42. data/app/mailers/rad_social_mailer.rb +8 -8
  43. data/app/models/asset.rb +62 -63
  44. data/app/models/asset_type.rb +38 -39
  45. data/app/models/deprecated_tags.rb +3 -4
  46. data/app/models/file_not_found_page.rb +1 -3
  47. data/app/models/haml_filter.rb +1 -1
  48. data/app/models/layout.rb +4 -5
  49. data/app/models/legacy_user.rb +2 -2
  50. data/app/models/menu_renderer.rb +16 -18
  51. data/app/models/page.rb +96 -93
  52. data/app/models/page_attachment.rb +1 -2
  53. data/app/models/page_context.rb +11 -12
  54. data/app/models/page_part.rb +3 -4
  55. data/app/models/rails_page.rb +10 -12
  56. data/app/models/site.rb +22 -21
  57. data/app/models/snippet.rb +6 -8
  58. data/app/models/snippet_finder.rb +3 -3
  59. data/app/models/snippet_tags.rb +4 -4
  60. data/app/models/standard_tags.rb +258 -252
  61. data/app/models/status.rb +8 -8
  62. data/app/models/trusty_cms/config.rb +25 -25
  63. data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
  64. data/app/models/user.rb +15 -14
  65. data/app/models/user_action_observer.rb +3 -3
  66. data/app/views/admin/assets/edit.html.haml +0 -9
  67. data/app/views/admin/assets/new.html.haml +0 -3
  68. data/app/views/admin/assets/remove.html.haml +1 -1
  69. data/app/views/admin/layouts/remove.html.haml +4 -3
  70. data/app/views/admin/page_parts/_page_part.html.haml +1 -1
  71. data/app/views/admin/pages/remove.html.haml +2 -1
  72. data/app/views/admin/sites/index.haml +3 -1
  73. data/app/views/admin/snippets/remove.html.haml +5 -4
  74. data/app/views/admin/users/remove.html.haml +2 -2
  75. data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
  76. data/app/views/widget/_email_form.html.haml +0 -5
  77. data/bin/rails +4 -4
  78. data/bin/trusty_cms +3 -5
  79. data/config.ru +1 -1
  80. data/config/application.rb +14 -15
  81. data/config/boot.rb +1 -2
  82. data/config/environment.rb +1 -1
  83. data/config/environments/production.rb +0 -1
  84. data/config/environments/test.rb +1 -2
  85. data/config/initializers/devise.rb +1 -1
  86. data/config/initializers/kraken.rb +2 -2
  87. data/config/initializers/tmp.rb +1 -1
  88. data/config/initializers/trusty_cms_config.rb +48 -48
  89. data/config/locales/en.yml +8 -8
  90. data/config/routes.rb +6 -7
  91. data/lib/active_record_extensions/active_record_extensions.rb +1 -2
  92. data/lib/annotatable.rb +3 -5
  93. data/lib/configuration_extensions/configuration_extensions.rb +1 -1
  94. data/lib/inheritable_class_attributes.rb +13 -9
  95. data/lib/login_system.rb +73 -73
  96. data/lib/method_observer.rb +13 -12
  97. data/lib/ostruct.rb +7 -10
  98. data/lib/simpleton.rb +0 -4
  99. data/lib/string_extensions/string_extensions.rb +3 -3
  100. data/lib/symbol_extensions/symbol_extensions.rb +1 -1
  101. data/lib/tasks/database.rake +28 -28
  102. data/lib/tasks/extensions.rake +18 -18
  103. data/lib/tasks/framework.rake +68 -68
  104. data/lib/tasks/radiant_config.rake +4 -4
  105. data/lib/tasks/snippets_extension_tasks.rake +11 -11
  106. data/lib/tasks/translate.rake +14 -14
  107. data/lib/tasks/upgrade_to_devise.rake +1 -1
  108. data/lib/translation_support.rb +22 -22
  109. data/lib/trusty_cms.rb +2 -2
  110. data/lib/trusty_cms/admin_ui.rb +19 -16
  111. data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
  112. data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
  113. data/lib/trusty_cms/available_locales.rb +2 -4
  114. data/lib/trusty_cms/config/definition.rb +11 -8
  115. data/lib/trusty_cms/engine.rb +13 -14
  116. data/lib/trusty_cms/extension.rb +14 -16
  117. data/lib/trusty_cms/extension_loader.rb +6 -6
  118. data/lib/trusty_cms/extension_migrator.rb +42 -41
  119. data/lib/trusty_cms/extension_path.rb +20 -19
  120. data/lib/trusty_cms/initializer.rb +5 -8
  121. data/lib/trusty_cms/pagination/controller.rb +7 -10
  122. data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
  123. data/lib/trusty_cms/resource_responses.rb +3 -3
  124. data/lib/trusty_cms/setup.rb +130 -132
  125. data/lib/trusty_cms/taggable.rb +19 -22
  126. data/lib/trusty_cms/task_support.rb +9 -6
  127. data/package.json +1 -1
  128. data/public/dispatch.fcgi +1 -1
  129. data/public/dispatch.rb +2 -2
  130. data/script/extension +1 -1
  131. data/script/rails +2 -2
  132. data/spec/dummy/package.json +1 -1
  133. data/spec/dummy/yarn.lock +3 -3
  134. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
  135. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
  136. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
  137. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
  138. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
  139. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
  140. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
  141. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
  142. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
  143. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
  144. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
  145. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
  146. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
  147. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
  148. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
  149. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
  150. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
  151. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
  152. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
  153. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
  154. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
  155. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
  156. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
  157. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
  158. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
  159. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
  160. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
  161. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
  162. data/trusty_cms.gemspec +25 -25
  163. data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +1 -1
  164. data/yarn.lock +7 -7
  165. metadata +7609 -105
  166. data/app/assets/javascripts/rad_social/captcha.js +0 -42
  167. data/app/views/admin/assets/refresh.html.haml +0 -14
@@ -0,0 +1,36 @@
1
+ import core, { nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj } from './core';
2
+ import failsafe from './failsafe';
3
+ import json from './json';
4
+ import yaml11 from './yaml-1.1';
5
+ import map from './failsafe/map';
6
+ import seq from './failsafe/seq';
7
+ import binary from './yaml-1.1/binary';
8
+ import omap from './yaml-1.1/omap';
9
+ import pairs from './yaml-1.1/pairs';
10
+ import set from './yaml-1.1/set';
11
+ import { floatTime, intTime, timestamp } from './yaml-1.1/timestamp';
12
+ export var schemas = {
13
+ core: core,
14
+ failsafe: failsafe,
15
+ json: json,
16
+ yaml11: yaml11
17
+ };
18
+ export var tags = {
19
+ binary: binary,
20
+ bool: boolObj,
21
+ float: floatObj,
22
+ floatExp: expObj,
23
+ floatNaN: nanObj,
24
+ floatTime: floatTime,
25
+ int: intObj,
26
+ intHex: hexObj,
27
+ intOct: octObj,
28
+ intTime: intTime,
29
+ map: map,
30
+ null: nullObj,
31
+ omap: omap,
32
+ pairs: pairs,
33
+ seq: seq,
34
+ set: set,
35
+ timestamp: timestamp
36
+ };
@@ -0,0 +1,76 @@
1
+ import map from './failsafe/map';
2
+ import seq from './failsafe/seq';
3
+ import Scalar from '../schema/Scalar';
4
+ import { resolveString } from './failsafe/string';
5
+ var schema = [map, seq, {
6
+ identify: function identify(value) {
7
+ return typeof value === 'string';
8
+ },
9
+ default: true,
10
+ tag: 'tag:yaml.org,2002:str',
11
+ resolve: resolveString,
12
+ stringify: function stringify(value) {
13
+ return JSON.stringify(value);
14
+ }
15
+ }, {
16
+ identify: function identify(value) {
17
+ return value == null;
18
+ },
19
+ createNode: function createNode(schema, value, ctx) {
20
+ return ctx.wrapScalars ? new Scalar(null) : null;
21
+ },
22
+ default: true,
23
+ tag: 'tag:yaml.org,2002:null',
24
+ test: /^null$/,
25
+ resolve: function resolve() {
26
+ return null;
27
+ },
28
+ stringify: function stringify(value) {
29
+ return JSON.stringify(value);
30
+ }
31
+ }, {
32
+ identify: function identify(value) {
33
+ return typeof value === 'boolean';
34
+ },
35
+ default: true,
36
+ tag: 'tag:yaml.org,2002:bool',
37
+ test: /^true|false$/,
38
+ resolve: function resolve(str) {
39
+ return str === 'true';
40
+ },
41
+ stringify: function stringify(value) {
42
+ return JSON.stringify(value);
43
+ }
44
+ }, {
45
+ identify: function identify(value) {
46
+ return typeof value === 'number';
47
+ },
48
+ default: true,
49
+ tag: 'tag:yaml.org,2002:int',
50
+ test: /^-?(?:0|[1-9][0-9]*)$/,
51
+ resolve: function resolve(str) {
52
+ return parseInt(str, 10);
53
+ },
54
+ stringify: function stringify(value) {
55
+ return JSON.stringify(value);
56
+ }
57
+ }, {
58
+ identify: function identify(value) {
59
+ return typeof value === 'number';
60
+ },
61
+ default: true,
62
+ tag: 'tag:yaml.org,2002:float',
63
+ test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
64
+ resolve: function resolve(str) {
65
+ return parseFloat(str);
66
+ },
67
+ stringify: function stringify(value) {
68
+ return JSON.stringify(value);
69
+ }
70
+ }];
71
+
72
+ schema.scalarFallback = function (str) {
73
+ throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(str)));
74
+ };
75
+
76
+ export default schema;
@@ -0,0 +1,23 @@
1
+ import { Type } from '../constants';
2
+ export var binaryOptions = {
3
+ defaultType: Type.BLOCK_LITERAL,
4
+ lineWidth: 76
5
+ };
6
+ export var boolOptions = {
7
+ trueStr: 'true',
8
+ falseStr: 'false'
9
+ };
10
+ export var nullOptions = {
11
+ nullStr: 'null'
12
+ };
13
+ export var strOptions = {
14
+ defaultType: Type.PLAIN,
15
+ doubleQuoted: {
16
+ jsonEncoding: false,
17
+ minMultiLineLength: 40
18
+ },
19
+ fold: {
20
+ lineWidth: 80,
21
+ minContentWidth: 20
22
+ }
23
+ };
@@ -0,0 +1,87 @@
1
+ /* global atob, btoa, Buffer */
2
+ import { Type } from '../../constants';
3
+ import { YAMLReferenceError } from '../../errors';
4
+ import { stringifyString } from '../../stringify';
5
+ import { resolveString } from '../failsafe/string';
6
+ import { binaryOptions as options } from '../options';
7
+ export default {
8
+ identify: function identify(value) {
9
+ return value instanceof Uint8Array;
10
+ },
11
+ // Buffer inherits from Uint8Array
12
+ default: false,
13
+ tag: 'tag:yaml.org,2002:binary',
14
+
15
+ /**
16
+ * Returns a Buffer in node and an Uint8Array in browsers
17
+ *
18
+ * To use the resulting buffer as an image, you'll want to do something like:
19
+ *
20
+ * const blob = new Blob([buffer], { type: 'image/jpeg' })
21
+ * document.querySelector('#photo').src = URL.createObjectURL(blob)
22
+ */
23
+ resolve: function resolve(doc, node) {
24
+ var src = resolveString(doc, node);
25
+
26
+ if (typeof Buffer === 'function') {
27
+ return Buffer.from(src, 'base64');
28
+ } else if (typeof atob === 'function') {
29
+ // On IE 11, atob() can't handle newlines
30
+ var str = atob(src.replace(/[\n\r]/g, ''));
31
+ var buffer = new Uint8Array(str.length);
32
+
33
+ for (var i = 0; i < str.length; ++i) {
34
+ buffer[i] = str.charCodeAt(i);
35
+ }
36
+
37
+ return buffer;
38
+ } else {
39
+ var msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
40
+ doc.errors.push(new YAMLReferenceError(node, msg));
41
+ return null;
42
+ }
43
+ },
44
+ options: options,
45
+ stringify: function stringify(_ref, ctx, onComment, onChompKeep) {
46
+ var comment = _ref.comment,
47
+ type = _ref.type,
48
+ value = _ref.value;
49
+ var src;
50
+
51
+ if (typeof Buffer === 'function') {
52
+ src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
53
+ } else if (typeof btoa === 'function') {
54
+ var s = '';
55
+
56
+ for (var i = 0; i < value.length; ++i) {
57
+ s += String.fromCharCode(value[i]);
58
+ }
59
+
60
+ src = btoa(s);
61
+ } else {
62
+ throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
63
+ }
64
+
65
+ if (!type) type = options.defaultType;
66
+
67
+ if (type === Type.QUOTE_DOUBLE) {
68
+ value = src;
69
+ } else {
70
+ var lineWidth = options.lineWidth;
71
+ var n = Math.ceil(src.length / lineWidth);
72
+ var lines = new Array(n);
73
+
74
+ for (var _i = 0, o = 0; _i < n; ++_i, o += lineWidth) {
75
+ lines[_i] = src.substr(o, lineWidth);
76
+ }
77
+
78
+ value = lines.join(type === Type.BLOCK_LITERAL ? '\n' : ' ');
79
+ }
80
+
81
+ return stringifyString({
82
+ comment: comment,
83
+ type: type,
84
+ value: value
85
+ }, ctx, onComment, onChompKeep);
86
+ }
87
+ };
@@ -0,0 +1,157 @@
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);
@@ -0,0 +1,142 @@
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
+ };