k_doc 0.0.28 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f303cce0d48fa08ea50ce2e14a4c5d935fe927c2e634c03db0f2d909cb6a01a6
4
- data.tar.gz: 5bffef8ae688894faf79e73c6fc04725315793d75795d784a3875563c7e6b1be
3
+ metadata.gz: 627b725f7a57a7eed231bac5a00c2409cdaaf1e5bf5c9610b15c63725cae0fbc
4
+ data.tar.gz: 3da6428f327fcf696cf7af358bca4db24f894e52d526e7b096fbf42d1fbdaddd
5
5
  SHA512:
6
- metadata.gz: def580541db16a31f6c80759f7387da8a38f4e1ffbf4545d65ae14da72498fcc86e274b207931347937f55b4d78b9009443f6321b74a8b1a5224cc74127c28c4
7
- data.tar.gz: e4cddb3891b5d4bc785833aa0d9de6efc19fd8d58f1525b99ca20b13407aa0a509ac4808fd70604093d9d7c67d0ffa64b9083af20ec45fba8a052dbd3dd29a5b
6
+ metadata.gz: be14c2081ea3656f0d52cad2aef871bd8f31f474ebc2b7f6a004d02a2f9198e79c52fe4b5c9bcf86ad022fc43e2cb7d1373e72cba6d0317e7ff2b40bd163a8e2
7
+ data.tar.gz: 46ba2d4f053d7548006317c8e5398379ab8a8167cd7e1d02ae9aa8eda988dce8eac42f207e2aa9e7fb7957c7cd91349dda1f5e30df63b320ec0e7b09d43e364a
@@ -29,7 +29,7 @@ module KDoc
29
29
 
30
30
  initialize_tag(opts)
31
31
  initialize_data(opts)
32
- initialize_block(opts, &block)
32
+ initialize_block_processor(opts, &block)
33
33
  end
34
34
 
35
35
  def default_container_type
@@ -28,10 +28,6 @@ module KDoc
28
28
  @default_yaml_type = :yaml
29
29
  @default_settings_key = :settings
30
30
  @default_table_key = :table
31
-
32
- # @document_class = KDoc::Document
33
- @table_class = KDoc::Table
34
- @settings_class = KDoc::Settings
35
31
  end
36
32
  end
37
33
  end
@@ -3,39 +3,100 @@
3
3
  module KDoc
4
4
  # A container acts a base data object for any data that requires tagging
5
5
  # such as unique key, type and namespace.
6
- # Rename: BlockProcessor
6
+ #
7
+ # example usage of the container using model as the basis:
8
+ # KDoc.model do
9
+ # init do
10
+ # context.some_data = :xmen
11
+ # end
12
+ # settings do
13
+ # name context.some_data
14
+ # end
15
+ # action
16
+ # puts context.some_data
17
+ # end
18
+ # end
7
19
  module BlockProcessor
8
- attr_accessor :block
9
- attr_accessor :block_state
20
+ include KLog::Logging
10
21
 
11
- # Proc/Handler to be called before evaluating when importing data
12
- attr_reader :on_init
22
+ attr_reader :block
23
+ attr_reader :block_state
13
24
 
14
- def initialize_block(opts, &block)
25
+ attr_reader :init_block
26
+ attr_reader :action_block
27
+ attr_reader :children
28
+
29
+ def initialize_block_processor(_opts, &block)
15
30
  @block = block if block_given?
16
31
  @block_state = :new
17
- @on_init = opts.delete(:on_init)
32
+
33
+ @init_block = nil
34
+ @action_block = nil
35
+ @children = []
36
+ end
37
+
38
+ def execute_block(run_actions: false)
39
+ # Evaluate the main block of code
40
+ fire_eval # aka primary eval
41
+
42
+ # Call the block of code attached to the init method
43
+ fire_init
44
+
45
+ # Call the each block in the child array of blocks in the order of creation (FIFO)
46
+ fire_children
47
+
48
+ # Call the block of code attached to the action method
49
+ fire_action if run_actions
50
+ end
51
+
52
+ # The underlying container is created and in the case of k_manager, registered
53
+ def new?
54
+ @block_state == :new
18
55
  end
19
56
 
57
+ # The main block has been evaluated, but child blocks are still to be processed
20
58
  def evaluated?
21
- @block_state == :evaluated || @block_state == :actioned
59
+ @block_state == :evaluated || initialized?
22
60
  end
23
61
 
62
+ # Has the init block been called?
63
+ def initialized?
64
+ @block_state == :initialized || children_evaluated?
65
+ end
66
+
67
+ # The block and the data it represents has been evaluated.
68
+ def children_evaluated?
69
+ @block_state == :children_evaluated || actioned?
70
+ end
71
+
72
+ # The on_action method has been called.
24
73
  def actioned?
25
74
  @block_state == :actioned
26
75
  end
27
76
 
28
- def execute_block(run_actions: nil)
29
- run_on_init
77
+ def fire_eval
78
+ return unless new?
30
79
 
31
- # return unless dependencies_met?
80
+ instance_eval(&block) if block
81
+
82
+ @block_state = :evaluated
83
+ rescue StandardError => e
84
+ log.error('Standard error in document')
85
+ # puts "key #{unique_key}"
86
+ # puts "file #{KUtil.data.console_file_hyperlink(resource.file, resource.file)}"
87
+ log.error(e.message)
88
+ @error = e
89
+ raise
90
+ end
32
91
 
33
- eval_block
34
- run_on_action if run_actions
92
+ def init(&block)
93
+ @init_block = block
35
94
  end
36
95
 
37
- def run_on_init
38
- instance_eval(&on_init) if on_init
96
+ def fire_init
97
+ return unless evaluated?
98
+
99
+ instance_eval(&init_block) if init_block
39
100
 
40
101
  @block_state = :initialized
41
102
  rescue StandardError => e
@@ -47,24 +108,50 @@ module KDoc
47
108
  raise
48
109
  end
49
110
 
50
- def eval_block
51
- instance_eval(&block) if block
111
+ def add_child(block)
112
+ @children << block
113
+ end
52
114
 
53
- @block_state = :evaluated
115
+ # Run blocks associated with the children
116
+ #
117
+ # A child can follow one of three patterns:
118
+ # 1. A block that is evaluated immediately against the parent class
119
+ # 2. A class that has its own custom block evaluation
120
+ # 3. A class that has a block which will be evaluated immediately against the child class
121
+ # rubocop:disable Metrics/AbcSize
122
+ def fire_children
123
+ return unless initialized?
124
+
125
+ children.each do |child|
126
+ if child.is_a?(Proc)
127
+ instance_eval(&child)
128
+ elsif child.respond_to?(:fire_eval)
129
+ child.fire_eval
130
+ elsif child.respond_to?(:block)
131
+ child.instance_eval(&child.block)
132
+ end
133
+ end
134
+
135
+ @block_state = :children_evaluated
54
136
  rescue StandardError => e
55
- log.error('Standard error in document')
137
+ log.error('Standard error in document with one of the child blocks')
56
138
  # puts "key #{unique_key}"
57
139
  # puts "file #{KUtil.data.console_file_hyperlink(resource.file, resource.file)}"
58
140
  log.error(e.message)
59
141
  @error = e
60
142
  raise
61
143
  end
144
+ # rubocop:enable Metrics/AbcSize
145
+
146
+ def action(&block)
147
+ @action_block = block
148
+ end
62
149
 
63
- def run_on_action
64
- return unless block
150
+ def fire_action
151
+ return unless children_evaluated?
65
152
 
66
- if respond_to?(:on_action)
67
- on_action
153
+ if action_block
154
+ instance_eval(&action_block)
68
155
  @block_state = :actioned
69
156
  end
70
157
  rescue StandardError => e
@@ -76,10 +163,14 @@ module KDoc
76
163
  raise
77
164
  end
78
165
 
166
+ # rubocop:disable Metrics/AbcSize
79
167
  def debug_block_processor
80
- log.kv 'block_state', block_state , debug_pad_size if respond_to?(:block_state)
81
- log.kv 'evaluated' , evaluated? , debug_pad_size if respond_to?(:evaluated?)
82
- log.kv 'actioned' , actioned? , debug_pad_size if respond_to?(:actioned?)
168
+ log.kv 'block_state' , block_state , debug_pad_size
169
+ log.kv 'new' , new? , debug_pad_size
170
+ log.kv 'evaluated' , evaluated? , debug_pad_size
171
+ log.kv 'children_evaluated' , children_evaluated? , debug_pad_size
172
+ log.kv 'actioned' , actioned? , debug_pad_size
83
173
  end
174
+ # rubocop:enable Metrics/AbcSize
84
175
  end
85
176
  end
data/lib/k_doc/model.rb CHANGED
@@ -23,20 +23,18 @@ module KDoc
23
23
 
24
24
  # Need to look at Director as an alternative to this technique
25
25
  def settings(key = nil, **setting_opts, &block)
26
- # TODO: add test
27
26
  if block.nil?
28
27
  log.warn 'You cannot call settings without a block. Did you mean to call data[:settings] or odata.settings?'
29
28
  return
30
29
  end
31
30
 
32
- setting_opts ||= {}
33
-
34
- setting_opts = {}.merge(opts) # Container options
31
+ setting_opts = {}.merge(opts) # Container options
35
32
  .merge(setting_opts) # Settings setting_opts
36
33
  .merge(parent: self)
37
34
 
38
- settings_instance(data, key, **setting_opts, &block)
39
- # settings.run_decorators(opts)
35
+ child = KDoc::Settings.new(self, data, key, **setting_opts, &block)
36
+
37
+ add_child(child)
40
38
  end
41
39
 
42
40
  def table(key = :table, **opts, &block)
@@ -45,9 +43,9 @@ module KDoc
45
43
  return
46
44
  end
47
45
 
48
- # NEED to add support for run_decorators I think
49
- opts.merge(parent: self)
50
- table_instance(data, key, **opts, &block)
46
+ child = KDoc::Table.new(self, data, key, **opts, &block)
47
+
48
+ add_child(child)
51
49
  end
52
50
  alias rows table
53
51
 
@@ -86,6 +84,11 @@ module KDoc
86
84
 
87
85
  raise KDoc::Error, "Node not found: #{node_name}" if node_data.nil?
88
86
 
87
+ if node_data.is_a?(Array)
88
+ puts 'why is this?'
89
+ return nil
90
+ end
91
+
89
92
  if node_data.keys.length == 2 && (node_data.key?('fields') && node_data.key?('rows'))
90
93
  :table
91
94
  else
@@ -138,15 +141,5 @@ module KDoc
138
141
  log.kv key, opts[key]
139
142
  end
140
143
  end
141
-
142
- private
143
-
144
- def settings_instance(data, key, **opts, &block)
145
- KDoc.opinion.settings_class.new(data, key, **opts, &block)
146
- end
147
-
148
- def table_instance(data, key, **opts, &block)
149
- KDoc.opinion.table_class.new(data, key, **opts, &block)
150
- end
151
144
  end
152
145
  end
@@ -1,40 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
4
-
5
3
  module KDoc
6
4
  # Builds up key/value settings from the block
7
- # and applies them to a key coded node on the hash
8
5
  class Settings
9
6
  include KLog::Logging
10
- # include KDoc::Decorators
11
7
 
12
8
  attr_reader :parent
13
9
  attr_reader :key
14
10
  attr_reader :decorators
11
+ attr_reader :block
15
12
 
16
- alias kp parent
17
-
18
- def initialize(data, key = nil, **options, &block)
19
- initialize_attributes(data, key, **options)
13
+ def initialize(parent, data, key = nil, **opts, &block)
14
+ @parent = parent
15
+ @data = data
16
+ @key = (key || FakeOpinion.new.default_settings_key).to_s
17
+ @data[@key] = {}
18
+ @decorators = build_decorators(opts) # TODO: add tests for decorators
19
+ @block = block
20
+ end
20
21
 
21
- # Need a way to find out the line number for errors and report it correctly
22
- begin
23
- instance_eval(&block) if block_given?
22
+ def fire_eval
23
+ return unless block
24
24
 
25
- run_decorators
25
+ instance_eval(&block)
26
+ run_decorators
26
27
 
27
- # rubocop:disable Style/RescueStandardError
28
- rescue => e
29
- # rubocop:enable Style/RescueStandardError
30
- puts "Invalid code block in settings_dsl: #{@key}"
31
- puts e.message
32
- raise
33
- end
28
+ # rubocop:disable Style/RescueStandardError
29
+ rescue => e
30
+ # rubocop:enable Style/RescueStandardError
31
+ log.error("Standard error while running settings for key: #{@key}")
32
+ log.error(e.message)
33
+ raise
34
34
  end
35
35
 
36
- def imports
37
- parent.imports
36
+ def context
37
+ parent.context
38
38
  end
39
39
 
40
40
  # Return these settings which are attached to a data container using :key
@@ -58,7 +58,7 @@ module KDoc
58
58
  # puts "args.length : #{args.length}"
59
59
 
60
60
  if name != :type && !@parent.nil? && @parent.respond_to?(name)
61
- puts "NAME: #{name}"
61
+ puts "Settings.method_missing - NAME: #{name}"
62
62
  return @parent.public_send(name, *args, &block)
63
63
  end
64
64
  raise KDoc::Error, 'Multiple setting values is not supported' if args.length > 1
@@ -127,21 +127,11 @@ module KDoc
127
127
  decorators.each { |decorator| decorator.decorate(self, :settings) }
128
128
  end
129
129
 
130
- def initialize_attributes(data, key = nil, **options)
131
- @data = data
132
- @key = (key || FakeOpinion.new.default_settings_key).to_s
133
-
134
- @parent = options[:parent] if options.key?(:parent)
130
+ def build_decorators(opts)
131
+ decorator_list = opts[:decorators].nil? ? [] : opts[:decorators]
135
132
 
136
- decorator_list = options[:decorators].nil? ? [] : options[:decorators]
137
-
138
- # This code needs to work differently, it needs to support the 3 different types
139
- # Move the query into helpers
140
- @decorators = decorator_list
141
- .map(&:new)
133
+ decorator_list.map(&:new)
142
134
  .select { |decorator| decorator.compatible?(self) }
143
-
144
- @data[@key] = {}
145
135
  end
146
136
  end
147
137
  end
data/lib/k_doc/table.rb CHANGED
@@ -6,22 +6,38 @@ module KDoc
6
6
  include KLog::Logging
7
7
 
8
8
  attr_reader :parent
9
- attr_reader :name
9
+ attr_reader :key # used to be called name
10
10
  attr_reader :decorators
11
+ attr_reader :block
11
12
 
12
- def initialize(data, name = nil, **options, &block)
13
- initialize_attributes(data, name, **options)
13
+ def initialize(parent, data, key = nil, **opts, &block)
14
+ @parent = parent
15
+ @data = data
16
+ @key = (key || FakeOpinion.new.default_table_key).to_s
17
+ @data[@key] = { 'fields' => [], 'rows' => [] }
18
+ @decorators = build_decorators(opts)
19
+ @block = block
20
+ end
21
+
22
+ def fire_eval
23
+ return unless block
24
+
25
+ instance_eval(&block)
14
26
 
15
27
  @has_executed_field_decorators = false
16
28
  @has_executed_row_decorators = false
17
29
 
18
- instance_eval(&block) if block_given?
19
-
20
30
  run_decorators(:update_rows)
31
+
32
+ # rubocop:disable Style/RescueStandardError
33
+ rescue => e
34
+ # rubocop:enable Style/RescueStandardError
35
+ log.error("Table error for key: #{@key} - #{e.message}")
36
+ raise
21
37
  end
22
38
 
23
- def imports
24
- parent.imports
39
+ def context
40
+ parent.context
25
41
  end
26
42
 
27
43
  # Pass fields in using the following format
@@ -31,7 +47,7 @@ module KDoc
31
47
  def fields(*field_definitions)
32
48
  field_definitions = *field_definitions[0] if field_definitions.length == 1 && field_definitions[0].is_a?(Array)
33
49
 
34
- fields = @data[@name]['fields']
50
+ fields = @data[@key]['fields']
35
51
 
36
52
  field_definitions.each do |fd|
37
53
  fields << if fd.is_a?(String) || fd.is_a?(Symbol)
@@ -46,7 +62,7 @@ module KDoc
46
62
 
47
63
  # rubocop:disable Metrics/AbcSize
48
64
  def row(*args, **named_args)
49
- fields = @data[@name]['fields']
65
+ fields = @data[@key]['fields']
50
66
 
51
67
  raise KType::Error, "To many values for row, argument #{args.length}" if args.length > fields.length
52
68
 
@@ -63,31 +79,31 @@ module KDoc
63
79
  end
64
80
 
65
81
  # Override with named args
66
- named_args.each_key do |key|
67
- row[key.to_s] = named_args[key] # KUtil.data.clean_symbol(named_args[key])
82
+ named_args.each_key do |arg_name|
83
+ row[arg_name.to_s] = named_args[arg_name] # KUtil.data.clean_symbol(named_args[key])
68
84
  end
69
85
 
70
- @data[@name]['rows'] << row
86
+ @data[@key]['rows'] << row
71
87
  row
72
88
  end
73
89
  # rubocop:enable Metrics/AbcSize
74
90
 
75
91
  # rubocop:disable Naming/AccessorMethodName
76
92
  def get_fields
77
- @data[@name]['fields']
93
+ @data[@key]['fields']
78
94
  end
79
95
 
80
96
  def get_rows
81
- @data[@name]['rows']
97
+ @data[@key]['rows']
82
98
  end
83
99
  # rubocop:enable Naming/AccessorMethodName
84
100
 
85
101
  def internal_data
86
- @data[@name]
102
+ @data[@key]
87
103
  end
88
104
 
89
105
  def find_row(key, value)
90
- @data[@name]['rows'].find { |r| r[key] == value }
106
+ @data[@key]['rows'].find { |r| r[key] == value }
91
107
  end
92
108
 
93
109
  # Field definition
@@ -138,24 +154,12 @@ module KDoc
138
154
  end
139
155
  # rubocop:enable Metrics/CyclomaticComplexity
140
156
 
141
- # rubocop:disable Metrics/AbcSize
142
- def initialize_attributes(data, name = nil, **options)
143
- @data = data
144
- @name = (name || FakeOpinion.new.default_table_key.to_s).to_s
145
-
146
- @parent = options[:parent] if !options.nil? && options.key?(:parent)
157
+ def build_decorators(opts)
158
+ decorator_list = opts[:decorators].nil? ? [] : opts[:decorators]
147
159
 
148
- # This code needs to work differently, it needs to support the 3 different types
149
- # Move the query into helpers
150
- decorator_list = options[:decorators].nil? ? [] : options[:decorators]
151
-
152
- @decorators = decorator_list
153
- .map(&:new)
160
+ decorator_list.map(&:new)
154
161
  .select { |decorator| decorator.compatible?(self) }
155
-
156
- @data[@name] = { 'fields' => [], 'rows' => [] }
157
162
  end
158
- # rubocop:enable Metrics/AbcSize
159
163
 
160
164
  def respond_to_missing?(name, *_args, &_block)
161
165
  (!@parent.nil? && @parent.respond_to?(name, true)) || super
data/lib/k_doc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDoc
4
- VERSION = '0.0.28'
4
+ VERSION = '0.0.32'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2022-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -132,7 +132,6 @@ files:
132
132
  - lib/k_doc/mixins/guarded.rb
133
133
  - lib/k_doc/mixins/taggable.rb
134
134
  - lib/k_doc/model.rb
135
- - lib/k_doc/model_backup.rb
136
135
  - lib/k_doc/settings.rb
137
136
  - lib/k_doc/table.rb
138
137
  - lib/k_doc/version.rb
@@ -1,191 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # module KDoc
4
- # # Model is a DSL for modeling general purpose data objects
5
- # #
6
- # # A model can have
7
- # # - 0 or more named setting groups each with their key/value pairs
8
- # # - 0 or more named table groups each with their own columns and rows
9
- # #
10
- # # A settings group without a name will default to name: :settings
11
- # # A table group without a name will default to name: :table
12
- # class Model < KDoc::Container
13
- # include KLog::Logging
14
-
15
- # # include KType::Error
16
- # # include KType::ManagedState
17
- # # include KType::NamedFolder
18
- # # include KType::LayeredFolder
19
-
20
- # attr_reader :options
21
-
22
- # # Create document
23
- # #
24
- # # @param [String|Symbol] name Name of the document
25
- # # @param args[0] Type of the document, defaults to KDoc:: FakeOpinion.new.default_model_type if not set
26
- # # @param default: Default value (using named params), as above
27
- # def initialize(key = nil, **options, &block)
28
- # super(key: key, type: options[:type] || KDoc.opinion.default_model_type) # , namespace: options[:namespace], project_key: options[:project_key])
29
- # initialize_attributes(**options)
30
-
31
- # @block = block if block_given?
32
- # end
33
-
34
- # # NOTE: Can this be moved out of the is object?
35
- # def execute_block(run_actions: nil)
36
- # return if @block.nil?
37
-
38
- # # The DSL actions method will only run on run_actions: true
39
- # @run_actions = run_actions
40
-
41
- # instance_eval(&@block)
42
-
43
- # on_action if run_actions && respond_to?(:on_action)
44
- # # rescue KDoc::Error => e
45
- # # puts('KDoc::Error in document')
46
- # # puts "key #{unique_key}"
47
- # # # puts "file #{KUtil.data.console_file_hyperlink(resource.file, resource.file)}"
48
- # # puts(e.message)
49
- # # @error = e
50
- # # raise
51
- # rescue StandardError => e
52
- # log.error('Standard error in document')
53
- # # puts "key #{unique_key}"
54
- # # puts "file #{KUtil.data.console_file_hyperlink(resource.file, resource.file)}"
55
- # log.error(e.message)
56
- # @error = e
57
- # # log.exception exception2
58
- # raise
59
- # ensure
60
- # @run_actions = nil
61
- # end
62
-
63
- # def settings(key = nil, **options, &block)
64
- # options ||= {}
65
-
66
- # opts = {}.merge(@options) # Data Options
67
- # .merge(options) # Settings Options
68
- # .merge(parent: self)
69
-
70
- # settings_instance(@data, key, **opts, &block)
71
- # # settings.run_decorators(opts)
72
- # end
73
-
74
- # def table(key = :table, **options, &block)
75
- # # NEED to add support for run_decorators I think
76
- # options.merge(parent: self)
77
- # table_instance(@data, key, **options, &block)
78
- # end
79
- # alias rows table
80
-
81
- # # Sweet add-on would be builders
82
- # # def builder(key, &block)
83
- # # # example
84
- # # KDoc::Builder::Shotstack.new(@data, key, &block)
85
- # # end
86
-
87
- # # Need to move this down to container
88
- # # Need to use some sort of cache invalidation to know if the internal data has been altered
89
- # def odata
90
- # @odata ||= data_struct
91
- # end
92
-
93
- # def oraw
94
- # @oraw ||= raw_data_struct
95
- # end
96
-
97
- # def data_struct
98
- # KUtil.data.to_open_struct(data)
99
- # end
100
- # # alias d data_struct
101
-
102
- # def raw_data_struct
103
- # KUtil.data.to_open_struct(raw_data)
104
- # end
105
-
106
- # def get_node_type(node_name)
107
- # node_name = KUtil.data.clean_symbol(node_name)
108
- # node_data = @data[node_name]
109
-
110
- # raise KDoc::Error, "Node not found: #{node_name}" if node_data.nil?
111
-
112
- # if node_data.keys.length == 2 && (node_data.key?('fields') && node_data.key?('rows'))
113
- # :table
114
- # else
115
- # :settings
116
- # end
117
- # end
118
-
119
- # # Removes any meta data eg. "fields" from a table and just returns the raw data
120
- # # REFACTOR: IT MAY BE BEST TO MOVE raw_data into each of the node_types
121
- # def raw_data
122
- # # REFACT, what if this is CSV, meaning it is just an array?
123
- # # add specs
124
- # result = data
125
-
126
- # result.each_key do |key|
127
- # # ANTI: get_node_type uses @data while we are using @data.clone here
128
- # result[key] = if get_node_type(key) == :table
129
- # # Old format was to keep the rows and delete the fields
130
- # # Now the format is to pull the row_value up to the key and remove rows and fields
131
- # # result[key].delete('fields')
132
- # result[key]['rows']
133
- # else
134
- # result[key]
135
- # end
136
- # end
137
-
138
- # result
139
- # end
140
-
141
- # # Move this out to the logger function when it has been refactor
142
- # def debug(include_header: false)
143
- # debug_header if include_header
144
-
145
- # # tp dsls.values, :k_key, :k_type, :state, :save_at, :last_at, :data, :last_data, :source, { :file => { :width => 150 } }
146
- # # puts JSON.pretty_generate(data)
147
- # log.o(raw_data_struct)
148
- # end
149
-
150
- # def debug_header
151
- # log.heading self.class.name
152
- # debug_container
153
- # debug_header_keys
154
-
155
- # log.line
156
- # end
157
-
158
- # def debug_header_keys
159
- # options&.keys&.reject { |k| k == :namespace }&.each do |key|
160
- # log.kv key, options[key]
161
- # end
162
- # end
163
-
164
- # private
165
-
166
- # def initialize_attributes(**options)
167
- # @options = options || {}
168
- # # Is parent a part of model, or is it part of k_manager::document_taggable (NOT SURE IF IT IS USED YET)
169
- # @parent = slice_option(:parent)
170
-
171
- # # Most documents live within a hash, some tabular documents such as CSV will use an []
172
- # @data = slice_option(:default_data) || {}
173
- # end
174
-
175
- # def settings_instance(data, key, **options, &block)
176
- # KDoc.opinion.settings_class.new(data, key, **options, &block)
177
- # end
178
-
179
- # def table_instance(data, key, **options, &block)
180
- # KDoc.opinion.table_class.new(data, key, **options, &block)
181
- # end
182
-
183
- # def slice_option(key)
184
- # return nil unless @options.key?(key)
185
-
186
- # result = @options[key]
187
- # @options.delete(key)
188
- # result
189
- # end
190
- # end
191
- # end