trusty-cms 4.1.1 → 4.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +107 -107
  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/rad_social/rad_screen.scss +0 -4
  12. data/app/controllers/admin/assets_controller.rb +21 -31
  13. data/app/controllers/admin/configuration_controller.rb +9 -11
  14. data/app/controllers/admin/extensions_controller.rb +3 -3
  15. data/app/controllers/admin/layouts_controller.rb +3 -4
  16. data/app/controllers/admin/page_attachments_controller.rb +5 -5
  17. data/app/controllers/admin/page_fields_controller.rb +3 -4
  18. data/app/controllers/admin/page_parts_controller.rb +4 -5
  19. data/app/controllers/admin/pages_controller.rb +55 -56
  20. data/app/controllers/admin/references_controller.rb +1 -1
  21. data/app/controllers/admin/resource_controller.rb +132 -130
  22. data/app/controllers/admin/sites_controller.rb +4 -4
  23. data/app/controllers/admin/snippets_controller.rb +3 -4
  24. data/app/controllers/admin/users_controller.rb +16 -16
  25. data/app/controllers/application_controller.rb +47 -48
  26. data/app/controllers/site_controller.rb +51 -48
  27. data/app/controllers/social_mailer_controller.rb +12 -22
  28. data/app/helpers/admin/configuration_helper.rb +19 -20
  29. data/app/helpers/admin/layouts_helper.rb +0 -1
  30. data/app/helpers/admin/node_helper.rb +27 -24
  31. data/app/helpers/admin/pages_helper.rb +2 -2
  32. data/app/helpers/admin/preferences_helper.rb +0 -1
  33. data/app/helpers/admin/references_helper.rb +9 -10
  34. data/app/helpers/admin/regions_helper.rb +3 -3
  35. data/app/helpers/application_helper.rb +32 -33
  36. data/app/helpers/rad_social_helper.rb +8 -11
  37. data/app/helpers/scoped_helper.rb +1 -3
  38. data/app/helpers/sites_helper.rb +4 -4
  39. data/app/mailers/devise_mailer.rb +3 -4
  40. data/app/mailers/rad_social_mailer.rb +8 -8
  41. data/app/models/asset.rb +62 -63
  42. data/app/models/asset_type.rb +38 -39
  43. data/app/models/deprecated_tags.rb +3 -4
  44. data/app/models/file_not_found_page.rb +1 -3
  45. data/app/models/haml_filter.rb +1 -1
  46. data/app/models/layout.rb +4 -5
  47. data/app/models/legacy_user.rb +2 -2
  48. data/app/models/menu_renderer.rb +16 -18
  49. data/app/models/page.rb +96 -93
  50. data/app/models/page_attachment.rb +1 -2
  51. data/app/models/page_context.rb +11 -12
  52. data/app/models/page_part.rb +3 -4
  53. data/app/models/rails_page.rb +10 -12
  54. data/app/models/site.rb +22 -21
  55. data/app/models/snippet.rb +6 -8
  56. data/app/models/snippet_finder.rb +3 -3
  57. data/app/models/snippet_tags.rb +4 -4
  58. data/app/models/standard_tags.rb +258 -252
  59. data/app/models/status.rb +8 -8
  60. data/app/models/trusty_cms/config.rb +25 -25
  61. data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
  62. data/app/models/user.rb +15 -14
  63. data/app/models/user_action_observer.rb +3 -3
  64. data/app/views/admin/assets/edit.html.haml +3 -9
  65. data/app/views/admin/assets/new.html.haml +0 -3
  66. data/app/views/admin/assets/remove.html.haml +1 -1
  67. data/app/views/admin/layouts/remove.html.haml +3 -2
  68. data/app/views/admin/page_parts/_page_part.html.haml +1 -1
  69. data/app/views/admin/snippets/remove.html.haml +3 -2
  70. data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
  71. data/app/views/widget/_email_form.html.haml +0 -5
  72. data/bin/rails +4 -4
  73. data/bin/trusty_cms +3 -5
  74. data/config.ru +1 -1
  75. data/config/application.rb +14 -15
  76. data/config/boot.rb +1 -2
  77. data/config/environment.rb +1 -1
  78. data/config/environments/production.rb +0 -1
  79. data/config/environments/test.rb +1 -2
  80. data/config/initializers/devise.rb +1 -1
  81. data/config/initializers/kraken.rb +2 -2
  82. data/config/initializers/tmp.rb +1 -1
  83. data/config/initializers/trusty_cms_config.rb +48 -48
  84. data/config/locales/en.yml +5 -4
  85. data/config/routes.rb +6 -7
  86. data/lib/active_record_extensions/active_record_extensions.rb +1 -2
  87. data/lib/annotatable.rb +3 -5
  88. data/lib/configuration_extensions/configuration_extensions.rb +1 -1
  89. data/lib/inheritable_class_attributes.rb +13 -9
  90. data/lib/login_system.rb +73 -73
  91. data/lib/method_observer.rb +13 -12
  92. data/lib/ostruct.rb +7 -10
  93. data/lib/simpleton.rb +0 -4
  94. data/lib/string_extensions/string_extensions.rb +3 -3
  95. data/lib/symbol_extensions/symbol_extensions.rb +1 -1
  96. data/lib/tasks/database.rake +28 -28
  97. data/lib/tasks/extensions.rake +18 -18
  98. data/lib/tasks/framework.rake +68 -68
  99. data/lib/tasks/radiant_config.rake +4 -4
  100. data/lib/tasks/snippets_extension_tasks.rake +11 -11
  101. data/lib/tasks/translate.rake +14 -14
  102. data/lib/tasks/upgrade_to_devise.rake +1 -1
  103. data/lib/translation_support.rb +22 -22
  104. data/lib/trusty_cms.rb +2 -2
  105. data/lib/trusty_cms/admin_ui.rb +19 -16
  106. data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
  107. data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
  108. data/lib/trusty_cms/available_locales.rb +2 -4
  109. data/lib/trusty_cms/config/definition.rb +11 -8
  110. data/lib/trusty_cms/engine.rb +13 -14
  111. data/lib/trusty_cms/extension.rb +14 -16
  112. data/lib/trusty_cms/extension_loader.rb +6 -6
  113. data/lib/trusty_cms/extension_migrator.rb +42 -41
  114. data/lib/trusty_cms/extension_path.rb +20 -19
  115. data/lib/trusty_cms/initializer.rb +5 -8
  116. data/lib/trusty_cms/pagination/controller.rb +7 -10
  117. data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
  118. data/lib/trusty_cms/resource_responses.rb +3 -3
  119. data/lib/trusty_cms/setup.rb +130 -132
  120. data/lib/trusty_cms/taggable.rb +19 -22
  121. data/lib/trusty_cms/task_support.rb +9 -6
  122. data/package.json +1 -1
  123. data/public/dispatch.fcgi +1 -1
  124. data/public/dispatch.rb +2 -2
  125. data/script/extension +1 -1
  126. data/script/rails +2 -2
  127. data/spec/dummy/package.json +1 -1
  128. data/spec/dummy/yarn.lock +3 -3
  129. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
  130. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
  131. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
  132. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
  133. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
  134. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
  135. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
  136. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
  137. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
  138. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
  139. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
  140. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
  141. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
  142. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
  143. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
  144. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
  145. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
  146. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
  147. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
  148. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
  149. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
  150. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
  151. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
  152. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
  153. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
  154. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
  155. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
  156. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
  157. data/trusty_cms.gemspec +25 -25
  158. data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +1 -1
  159. data/yarn.lock +7 -7
  160. metadata +7609 -105
  161. data/app/assets/javascripts/rad_social/captcha.js +0 -42
  162. data/app/views/admin/assets/refresh.html.haml +0 -14
@@ -13,20 +13,21 @@ module TrustyCms::Taggable
13
13
  end
14
14
  class << new_base
15
15
  def default_url_options
16
- {:controller => "site", :action => "show_page", :only_path => true}
16
+ { controller: 'site', action: 'show_page', only_path: true }
17
17
  end
18
18
  end
19
- new_base.tag_descriptions.merge! self.tag_descriptions
19
+ new_base.tag_descriptions.merge! tag_descriptions
20
20
  end
21
21
 
22
22
  protected
23
- def params
24
- @params ||= request.parameters unless request.nil?
25
- end
26
23
 
27
- def request_uri
28
- @request_url ||= request.request_uri unless request.nil?
29
- end
24
+ def params
25
+ @params ||= request.parameters unless request.nil?
26
+ end
27
+
28
+ def request_uri
29
+ @request_url ||= request.request_uri unless request.nil?
30
+ end
30
31
  end
31
32
  end
32
33
 
@@ -44,11 +45,11 @@ module TrustyCms::Taggable
44
45
  Util.tags_in_array(methods)
45
46
  end
46
47
 
47
- def tag_descriptions(hash=nil)
48
+ def tag_descriptions(hash = nil)
48
49
  self.class.tag_descriptions hash
49
50
  end
50
51
 
51
- def warn_of_tag_deprecation(tag_name, options={})
52
+ def warn_of_tag_deprecation(tag_name, options = {})
52
53
  message = "Deprecated radius tag <r:#{tag_name}>"
53
54
  message << " will be removed or significantly changed in trusty #{options[:deadline]}." if options[:deadline]
54
55
  message << " Please use <r:#{options[:substitute]}> instead." if options[:substitute]
@@ -57,12 +58,12 @@ module TrustyCms::Taggable
57
58
 
58
59
  module ClassMethods
59
60
  def inherited(subclass)
60
- subclass.tag_descriptions.reverse_merge! self.tag_descriptions
61
+ subclass.tag_descriptions.reverse_merge! tag_descriptions
61
62
  super
62
63
  end
63
64
 
64
65
  def tag_descriptions(hash = nil)
65
- TrustyCms::Taggable.tag_descriptions[self.name] ||= (hash ||{})
66
+ TrustyCms::Taggable.tag_descriptions[name] ||= (hash || {})
66
67
  end
67
68
 
68
69
  def desc(text)
@@ -71,13 +72,13 @@ module TrustyCms::Taggable
71
72
  end
72
73
 
73
74
  def tag(name, &block)
74
- self.tag_descriptions[name] = TrustyCms::Taggable.last_description if TrustyCms::Taggable.last_description
75
+ tag_descriptions[name] = TrustyCms::Taggable.last_description if TrustyCms::Taggable.last_description
75
76
  TrustyCms::Taggable.last_description = nil
76
77
  define_method("tag:#{name}", &block)
77
78
  end
78
79
 
79
80
  def tags
80
- Util.tags_in_array(self.instance_methods)
81
+ Util.tags_in_array(instance_methods)
81
82
  end
82
83
 
83
84
  # Define a tag while also deprecating it. Normal usage:
@@ -98,7 +99,7 @@ module TrustyCms::Taggable
98
99
  # raise TagError "..."
99
100
  # end
100
101
  #
101
- def deprecated_tag(name, options={}, &dblock)
102
+ def deprecated_tag(name, options = {}, &dblock)
102
103
  TrustyCms::Taggable.tag_deprecations[name] = options.dup
103
104
  if dblock
104
105
  tag(name) do |tag|
@@ -121,18 +122,14 @@ module TrustyCms::Taggable
121
122
 
122
123
  def self.strip_leading_whitespace(text)
123
124
  text = text.dup
124
- text.gsub!("\t", " ")
125
+ text.gsub!("\t", ' ')
125
126
  lines = text.split("\n")
126
127
  leading = lines.map do |line|
127
128
  unless line =~ /^\s*$/
128
- line.match(/^(\s*)/)[0].length
129
- else
130
- nil
129
+ line.match(/^(\s*)/)[0].length
131
130
  end
132
131
  end.compact.min
133
- lines.inject([]) {|ary, line| ary << line.sub(/^[ ]{#{leading}}/, "")}.join("\n")
132
+ lines.inject([]) { |ary, line| ary << line.sub(/^[ ]{#{leading}}/, '') }.join("\n")
134
133
  end
135
-
136
134
  end
137
-
138
135
  end
@@ -8,15 +8,17 @@ module TrustyCms
8
8
  ActiveRecord::Base.establish_connection(env_connection)
9
9
  end
10
10
  end
11
+
11
12
  def config_export(path = "#{Rails.root}/config/trusty_config.yml")
12
- self.establish_connection
13
+ establish_connection
13
14
  FileUtils.mkdir_p(File.dirname(path))
14
- if File.open(File.expand_path(path), 'w') { |f| YAML.dump(TrustyCms::Config.to_hash.to_yaml,f) }
15
+ if File.open(File.expand_path(path), 'w') { |f| YAML.dump(TrustyCms::Config.to_hash.to_yaml, f) }
15
16
  puts "TrustyCms::Config saved to #{path}"
16
17
  end
17
18
  end
19
+
18
20
  def config_import(path = "#{Rails.root}/config/trusty_config.yml", clear = nil)
19
- self.establish_connection
21
+ establish_connection
20
22
  if File.exist?(path)
21
23
  begin
22
24
  TrustyCms::Config.transaction do
@@ -40,12 +42,13 @@ module TrustyCms
40
42
  # Write the combined content of files in dir into cache_file in the same dir.
41
43
  #
42
44
  def cache_files(dir, files, cache_file)
43
- cache_content = files.collect { |f|
44
- File.read(File.join(dir, f)) }.join("\n\n")
45
+ cache_content = files.collect do |f|
46
+ File.read(File.join(dir, f))
47
+ end .join("\n\n")
45
48
 
46
49
  cache_path = File.join(dir, cache_file)
47
50
  File.delete(cache_path) if File.exists?(cache_path)
48
- File.open(cache_path, "w+") { |f| f.write(cache_content) }
51
+ File.open(cache_path, 'w+') { |f| f.write(cache_content) }
49
52
  end
50
53
 
51
54
  # Reads through the layout file and returns an array of JS filenames
@@ -8,7 +8,7 @@
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
10
  "@fortawesome/fontawesome-free": "^5.13.0",
11
- "jquery": "^3.2.1",
11
+ "jquery": "^3.5.0",
12
12
  "jquery-ui-bundle": "^1.12.1",
13
13
  "jquery-ujs": "^1.2.2",
14
14
  "tablesaw": "^3.1.2"
@@ -18,7 +18,7 @@
18
18
  # # Custom log path, normal GC behavior.
19
19
  # RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
20
20
  #
21
- require File.dirname(__FILE__) + "/../config/environment"
21
+ require File.dirname(__FILE__) + '/../config/environment'
22
22
  require 'fcgi_handler'
23
23
 
24
24
  RailsFCGIHandler.process!
@@ -1,10 +1,10 @@
1
1
  #!/home/rails/bin/ruby
2
2
 
3
- require File.dirname(__FILE__) + "/../config/environment" unless defined?(Rails.root)
3
+ require File.dirname(__FILE__) + '/../config/environment' unless defined?(Rails.root)
4
4
 
5
5
  # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
6
  # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
7
- require "dispatcher"
7
+ require 'dispatcher'
8
8
 
9
9
  ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
10
  Dispatcher.dispatch
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require File.expand_path('../../config/boot', __FILE__)
2
+ require File.expand_path('../config/boot', __dir__)
3
3
  require 'trusty_cms/extension/script'
4
4
 
5
5
  TrustyCms::Extension::Script.execute ARGV
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
3
 
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require File.expand_path('../config/boot', __dir__)
6
6
  require 'rails/commands'
@@ -4,7 +4,7 @@
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "jquery": "^3.2.1",
7
+ "jquery": "^3.5.0",
8
8
  "jquery-ui-bundle": "^1.12.1",
9
9
  "jquery-ujs": "^1.2.2"
10
10
  }
@@ -12,6 +12,6 @@ jquery-ujs@^1.2.2:
12
12
  dependencies:
13
13
  jquery ">=1.8.0"
14
14
 
15
- jquery@>=1.8.0, jquery@^3.2.1:
16
- version "3.2.1"
17
- resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787"
15
+ jquery@>=1.8.0, jquery@^3.5.0:
16
+ version "3.5.0"
17
+ resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.0.tgz#9980b97d9e4194611c36530e7dc46a58d7340fc9"
@@ -0,0 +1,126 @@
1
+ import Scalar from '../schema/Scalar';
2
+ import { stringifyNumber } from '../stringify';
3
+ import failsafe from './failsafe';
4
+ import { boolOptions, nullOptions } from './options';
5
+ export var nullObj = {
6
+ identify: function identify(value) {
7
+ return value == null;
8
+ },
9
+ createNode: function createNode(schema, value, ctx) {
10
+ return ctx.wrapScalars ? new Scalar(null) : null;
11
+ },
12
+ default: true,
13
+ tag: 'tag:yaml.org,2002:null',
14
+ test: /^(?:~|[Nn]ull|NULL)?$/,
15
+ resolve: function resolve() {
16
+ return null;
17
+ },
18
+ options: nullOptions,
19
+ stringify: function stringify() {
20
+ return nullOptions.nullStr;
21
+ }
22
+ };
23
+ export var boolObj = {
24
+ identify: function identify(value) {
25
+ return typeof value === 'boolean';
26
+ },
27
+ default: true,
28
+ tag: 'tag:yaml.org,2002:bool',
29
+ test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
30
+ resolve: function resolve(str) {
31
+ return str[0] === 't' || str[0] === 'T';
32
+ },
33
+ options: boolOptions,
34
+ stringify: function stringify(_ref) {
35
+ var value = _ref.value;
36
+ return value ? boolOptions.trueStr : boolOptions.falseStr;
37
+ }
38
+ };
39
+ export var octObj = {
40
+ identify: function identify(value) {
41
+ return typeof value === 'number';
42
+ },
43
+ default: true,
44
+ tag: 'tag:yaml.org,2002:int',
45
+ format: 'OCT',
46
+ test: /^0o([0-7]+)$/,
47
+ resolve: function resolve(str, oct) {
48
+ return parseInt(oct, 8);
49
+ },
50
+ stringify: function stringify(_ref2) {
51
+ var value = _ref2.value;
52
+ return '0o' + value.toString(8);
53
+ }
54
+ };
55
+ export var intObj = {
56
+ identify: function identify(value) {
57
+ return typeof value === 'number';
58
+ },
59
+ default: true,
60
+ tag: 'tag:yaml.org,2002:int',
61
+ test: /^[-+]?[0-9]+$/,
62
+ resolve: function resolve(str) {
63
+ return parseInt(str, 10);
64
+ },
65
+ stringify: stringifyNumber
66
+ };
67
+ export var hexObj = {
68
+ identify: function identify(value) {
69
+ return typeof value === 'number';
70
+ },
71
+ default: true,
72
+ tag: 'tag:yaml.org,2002:int',
73
+ format: 'HEX',
74
+ test: /^0x([0-9a-fA-F]+)$/,
75
+ resolve: function resolve(str, hex) {
76
+ return parseInt(hex, 16);
77
+ },
78
+ stringify: function stringify(_ref3) {
79
+ var value = _ref3.value;
80
+ return '0x' + value.toString(16);
81
+ }
82
+ };
83
+ export var nanObj = {
84
+ identify: function identify(value) {
85
+ return typeof value === 'number';
86
+ },
87
+ default: true,
88
+ tag: 'tag:yaml.org,2002:float',
89
+ test: /^(?:[-+]?\.inf|(\.nan))$/i,
90
+ resolve: function resolve(str, nan) {
91
+ return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
92
+ },
93
+ stringify: stringifyNumber
94
+ };
95
+ export var expObj = {
96
+ identify: function identify(value) {
97
+ return typeof value === 'number';
98
+ },
99
+ default: true,
100
+ tag: 'tag:yaml.org,2002:float',
101
+ format: 'EXP',
102
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
103
+ resolve: function resolve(str) {
104
+ return parseFloat(str);
105
+ },
106
+ stringify: function stringify(_ref4) {
107
+ var value = _ref4.value;
108
+ return Number(value).toExponential();
109
+ }
110
+ };
111
+ export var floatObj = {
112
+ identify: function identify(value) {
113
+ return typeof value === 'number';
114
+ },
115
+ default: true,
116
+ tag: 'tag:yaml.org,2002:float',
117
+ test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
118
+ resolve: function resolve(str, frac1, frac2) {
119
+ var frac = frac1 || frac2;
120
+ var node = new Scalar(parseFloat(str));
121
+ if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
122
+ return node;
123
+ },
124
+ stringify: stringifyNumber
125
+ };
126
+ export default failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);
@@ -0,0 +1,4 @@
1
+ import map from './map';
2
+ import seq from './seq';
3
+ import str from './string';
4
+ export default [map, seq, str];
@@ -0,0 +1,56 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import YAMLMap from '../../schema/Map';
4
+ import parseMap from '../../schema/parseMap';
5
+
6
+ function createMap(schema, obj, ctx) {
7
+ var map = new YAMLMap(schema);
8
+
9
+ if (obj instanceof Map) {
10
+ var _iteratorNormalCompletion = true;
11
+ var _didIteratorError = false;
12
+ var _iteratorError = undefined;
13
+
14
+ try {
15
+ for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
16
+ var _step$value = _slicedToArray(_step.value, 2),
17
+ key = _step$value[0],
18
+ value = _step$value[1];
19
+
20
+ map.items.push(schema.createPair(key, value, ctx));
21
+ }
22
+ } catch (err) {
23
+ _didIteratorError = true;
24
+ _iteratorError = err;
25
+ } finally {
26
+ try {
27
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
28
+ _iterator.return();
29
+ }
30
+ } finally {
31
+ if (_didIteratorError) {
32
+ throw _iteratorError;
33
+ }
34
+ }
35
+ }
36
+ } else if (obj && _typeof(obj) === 'object') {
37
+ for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
38
+ var _key = _Object$keys[_i];
39
+ map.items.push(schema.createPair(_key, obj[_key], ctx));
40
+ }
41
+ }
42
+
43
+ if (typeof schema.sortMapEntries === 'function') {
44
+ map.items.sort(schema.sortMapEntries);
45
+ }
46
+
47
+ return map;
48
+ }
49
+
50
+ export default {
51
+ createNode: createMap,
52
+ default: true,
53
+ nodeClass: YAMLMap,
54
+ tag: 'tag:yaml.org,2002:map',
55
+ resolve: parseMap
56
+ };
@@ -0,0 +1,43 @@
1
+ import parseSeq from '../../schema/parseSeq';
2
+ import YAMLSeq from '../../schema/Seq';
3
+
4
+ function createSeq(schema, obj, ctx) {
5
+ var seq = new YAMLSeq(schema);
6
+
7
+ if (obj && obj[Symbol.iterator]) {
8
+ var _iteratorNormalCompletion = true;
9
+ var _didIteratorError = false;
10
+ var _iteratorError = undefined;
11
+
12
+ try {
13
+ for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
14
+ var it = _step.value;
15
+ var v = schema.createNode(it, ctx.wrapScalars, null, ctx);
16
+ seq.items.push(v);
17
+ }
18
+ } catch (err) {
19
+ _didIteratorError = true;
20
+ _iteratorError = err;
21
+ } finally {
22
+ try {
23
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
24
+ _iterator.return();
25
+ }
26
+ } finally {
27
+ if (_didIteratorError) {
28
+ throw _iteratorError;
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ return seq;
35
+ }
36
+
37
+ export default {
38
+ createNode: createSeq,
39
+ default: true,
40
+ nodeClass: YAMLSeq,
41
+ tag: 'tag:yaml.org,2002:seq',
42
+ resolve: parseSeq
43
+ };
@@ -0,0 +1,28 @@
1
+ import { stringifyString } from '../../stringify';
2
+ import { strOptions } from '../options';
3
+ export var resolveString = function resolveString(doc, node) {
4
+ // on error, will return { str: string, errors: Error[] }
5
+ var res = node.strValue;
6
+ if (!res) return '';
7
+ if (typeof res === 'string') return res;
8
+ res.errors.forEach(function (error) {
9
+ if (!error.source) error.source = node;
10
+ doc.errors.push(error);
11
+ });
12
+ return res.str;
13
+ };
14
+ export default {
15
+ identify: function identify(value) {
16
+ return typeof value === 'string';
17
+ },
18
+ default: true,
19
+ tag: 'tag:yaml.org,2002:str',
20
+ resolve: resolveString,
21
+ stringify: function stringify(item, ctx, onComment, onChompKeep) {
22
+ ctx = Object.assign({
23
+ actualString: true
24
+ }, ctx);
25
+ return stringifyString(item, ctx, onComment, onChompKeep);
26
+ },
27
+ options: strOptions
28
+ };