k_doc 0.0.27 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.builders/_.rb +1 -0
- data/.builders/boot.rb +90 -0
- data/.builders/generators/domain_diagram.rb +198 -0
- data/.builders/generators/project_plan.rb +42 -0
- data/.builders/setup.rb +14 -14
- data/.rubocop.yml +4 -0
- data/README.md +2 -1
- data/docs/class-diagram-dsl.png +0 -0
- data/docs/class-diagram.png +0 -0
- data/docs/domain-custom.drawio +97 -0
- data/docs/domain-custom.svg +1 -0
- data/docs/domain-modal.md +7 -0
- data/docs/domain.drawio +82 -0
- data/docs/domain_model.svg +3 -0
- data/docs/project-plan.drawio +29 -0
- data/docs/project-plan.md +24 -0
- data/docs/project_in_progress.svg +3 -0
- data/lib/k_doc/container.rb +6 -3
- data/lib/k_doc/fake_opinion.rb +0 -4
- data/lib/k_doc/mixins/block_processor.rb +180 -21
- data/lib/k_doc/mixins/guarded.rb +1 -1
- data/lib/k_doc/mixins/taggable.rb +2 -0
- data/lib/k_doc/model.rb +12 -19
- data/lib/k_doc/settings.rb +26 -35
- data/lib/k_doc/table.rb +35 -31
- data/lib/k_doc/version.rb +1 -1
- data/lib/k_doc.rb +0 -1
- metadata +16 -7
- data/.builders/initializers/_.rb +0 -7
- data/.builders/initializers/configure_builder.rb +0 -38
- data/.builders/initializers/handlebars_helpers.rb +0 -27
- data/lib/k_doc/mixins/importable.rb +0 -27
- data/lib/k_doc/model_backup.rb +0 -191
@@ -1,27 +0,0 @@
|
|
1
|
-
Handlebars::Helpers.configure do |config|
|
2
|
-
config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_helpers.json')
|
3
|
-
config.helper_config_file = config_file
|
4
|
-
|
5
|
-
string_config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_string_formatters.json')
|
6
|
-
config.string_formatter_config_file = string_config_file
|
7
|
-
end
|
8
|
-
|
9
|
-
def camel
|
10
|
-
require 'handlebars/helpers/string_formatting/camel'
|
11
|
-
Handlebars::Helpers::StringFormatting::Camel.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def titleize
|
15
|
-
require 'handlebars/helpers/string_formatting/titleize'
|
16
|
-
Handlebars::Helpers::StringFormatting::Titleize.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def pluralize
|
20
|
-
require 'handlebars/helpers/inflection/pluralize'
|
21
|
-
Handlebars::Helpers::Inflection::Pluralize.new
|
22
|
-
end
|
23
|
-
|
24
|
-
def singularize
|
25
|
-
require 'handlebars/helpers/inflection/singularize'
|
26
|
-
Handlebars::Helpers::Inflection::Singularize.new
|
27
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KDoc
|
4
|
-
# Alow documents to import data from other sources (usually other documents)
|
5
|
-
|
6
|
-
module Importable
|
7
|
-
include KLog::Logging
|
8
|
-
|
9
|
-
# Proc/Handler to be called when importing data
|
10
|
-
attr_reader :on_import
|
11
|
-
|
12
|
-
# OpenStruct to be populated with data from import
|
13
|
-
attr_reader :imports
|
14
|
-
|
15
|
-
def initialize_import(opts)
|
16
|
-
# log.error 'initialize_import'
|
17
|
-
@on_import = opts.delete(:on_import)
|
18
|
-
@imports = OpenStruct.new
|
19
|
-
end
|
20
|
-
|
21
|
-
def run_on_import
|
22
|
-
return unless on_import
|
23
|
-
|
24
|
-
instance_eval(&on_import)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/k_doc/model_backup.rb
DELETED
@@ -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
|