k_doc 0.0.25 → 0.0.26
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/.rubocop.yml +9 -13
- data/lib/k_doc/container.rb +4 -1
- data/lib/k_doc/mixins/block_processor.rb +21 -1
- data/lib/k_doc/mixins/importable.rb +52 -0
- data/lib/k_doc/mixins/taggable.rb +1 -19
- data/lib/k_doc/model.rb +2 -1
- data/lib/k_doc/version.rb +1 -1
- data/lib/k_doc.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e43e7408a95cf8bf701922e28ef33115d12dd66dd77af00ca1f8b0e492c0952d
|
4
|
+
data.tar.gz: 74506c87934ece30b1e5e37b111fc6ff347ae277b8085aff50a0dce698946b7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92427570dd666fa9d679472fe48dd79771a877209ddd80df4143db1b03cf75ed587af99b1bca3f39e4f039e6ffa4e074c2173f19f8047811a17ca6c7d25cf248
|
7
|
+
data.tar.gz: 553d2c7d0bbf1304b7814e3196b3bf4d90a413c920c2209865918dd3351edabcd6fdad345cb4deb53fb5cb2678b637992caf00a7349218030a37518605071206
|
data/.rubocop.yml
CHANGED
@@ -44,15 +44,20 @@ Layout/LineLength:
|
|
44
44
|
Lint/UnusedMethodArgument:
|
45
45
|
AllowUnusedKeywordArguments: true
|
46
46
|
|
47
|
-
Style/
|
47
|
+
Style/AccessorGrouping:
|
48
48
|
Enabled: false
|
49
|
-
|
50
49
|
Style/BlockComments:
|
51
50
|
Enabled: false
|
52
51
|
Include:
|
53
52
|
- "**/spec/*"
|
54
|
-
|
55
|
-
|
53
|
+
Style/Documentation:
|
54
|
+
Enabled: false
|
55
|
+
Style/EmptyMethod:
|
56
|
+
Exclude:
|
57
|
+
- "**/spec/**/*"
|
58
|
+
Style/OpenStructUse:
|
59
|
+
Exclude:
|
60
|
+
- "**/spec/**/*"
|
56
61
|
Metrics/ClassLength:
|
57
62
|
Enabled: false
|
58
63
|
Metrics/ModuleLength:
|
@@ -63,23 +68,14 @@ Naming/MemoizedInstanceVariableName:
|
|
63
68
|
Naming/VariableNumber:
|
64
69
|
Exclude:
|
65
70
|
- "**/spec/**/*"
|
66
|
-
Style/EmptyMethod:
|
67
|
-
Exclude:
|
68
|
-
- "**/spec/**/*"
|
69
71
|
Metrics/ParameterLists:
|
70
72
|
Exclude:
|
71
73
|
- "**/spec/**/*"
|
72
74
|
Layout/EmptyLineBetweenDefs:
|
73
75
|
Exclude:
|
74
76
|
- "**/spec/**/*"
|
75
|
-
|
76
77
|
Lint/AmbiguousBlockAssociation:
|
77
78
|
Exclude:
|
78
79
|
- "**/spec/**/*"
|
79
|
-
|
80
|
-
Style/AccessorGrouping:
|
81
|
-
Enabled: false
|
82
|
-
|
83
80
|
Layout/SpaceBeforeComma:
|
84
81
|
Enabled: false
|
85
|
-
# My Preferences - End
|
data/lib/k_doc/container.rb
CHANGED
@@ -9,6 +9,7 @@ module KDoc
|
|
9
9
|
include KDoc::Taggable
|
10
10
|
include KDoc::Datum
|
11
11
|
include KDoc::BlockProcessor
|
12
|
+
include KDoc::Importable
|
12
13
|
|
13
14
|
attr_reader :opts
|
14
15
|
|
@@ -24,6 +25,7 @@ module KDoc
|
|
24
25
|
|
25
26
|
initialize_tag(opts)
|
26
27
|
initialize_data(opts)
|
28
|
+
initialize_import(opts) if respond_to?(:initialize_import)
|
27
29
|
initialize_block(opts, &block)
|
28
30
|
end
|
29
31
|
|
@@ -36,7 +38,8 @@ module KDoc
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def debug
|
39
|
-
|
41
|
+
debug_taggable
|
42
|
+
debug_block_processor
|
40
43
|
debug_errors
|
41
44
|
end
|
42
45
|
|
@@ -6,9 +6,19 @@ module KDoc
|
|
6
6
|
# Rename: BlockProcessor
|
7
7
|
module BlockProcessor
|
8
8
|
attr_accessor :block
|
9
|
+
attr_accessor :block_state
|
9
10
|
|
10
11
|
def initialize_block(_opts, &block)
|
11
12
|
@block = block if block_given?
|
13
|
+
@block_state = :initial
|
14
|
+
end
|
15
|
+
|
16
|
+
def evaluated?
|
17
|
+
@block_state == :evaluated || @block_state == :actioned
|
18
|
+
end
|
19
|
+
|
20
|
+
def actioned?
|
21
|
+
@block_state == :actioned
|
12
22
|
end
|
13
23
|
|
14
24
|
def execute_block(run_actions: nil)
|
@@ -20,6 +30,7 @@ module KDoc
|
|
20
30
|
return if @block.nil?
|
21
31
|
|
22
32
|
instance_eval(&@block)
|
33
|
+
@block_state = :evaluated
|
23
34
|
rescue StandardError => e
|
24
35
|
log.error('Standard error in document')
|
25
36
|
# puts "key #{unique_key}"
|
@@ -32,7 +43,10 @@ module KDoc
|
|
32
43
|
def run_on_action
|
33
44
|
return if @block.nil?
|
34
45
|
|
35
|
-
|
46
|
+
if respond_to?(:on_action)
|
47
|
+
on_action
|
48
|
+
@block_state = :actioned
|
49
|
+
end
|
36
50
|
rescue StandardError => e
|
37
51
|
log.error('Standard error while running actions')
|
38
52
|
# puts "key #{unique_key}"
|
@@ -41,5 +55,11 @@ module KDoc
|
|
41
55
|
@error = e
|
42
56
|
raise
|
43
57
|
end
|
58
|
+
|
59
|
+
def debug_block_processor
|
60
|
+
log.kv 'block_state', block_state , debug_pad_size if respond_to?(:block_state)
|
61
|
+
log.kv 'evaluated' , evaluated? , debug_pad_size if respond_to?(:evaluated?)
|
62
|
+
log.kv 'actioned' , actioned? , debug_pad_size if respond_to?(:actioned?)
|
63
|
+
end
|
44
64
|
end
|
45
65
|
end
|
@@ -0,0 +1,52 @@
|
|
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
|
+
attr_reader :importer
|
10
|
+
attr_reader :imports
|
11
|
+
|
12
|
+
# Imports are provided via an options hash, these imports are remove from the hash as they are read
|
13
|
+
#
|
14
|
+
# Any container can import data from an existing container via the import options
|
15
|
+
# rubocop:disable Style/OpenStructUse
|
16
|
+
def initialize_import(opts)
|
17
|
+
# log.error 'initialize_import'
|
18
|
+
@importer = opts.delete(:importer)
|
19
|
+
@imports = OpenStruct.new
|
20
|
+
end
|
21
|
+
# rubocop:enable Style/OpenStructUse
|
22
|
+
|
23
|
+
def call_importer
|
24
|
+
return unless importer
|
25
|
+
|
26
|
+
importer.call(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
# def import(tag)
|
30
|
+
# KManager.find_document(tag)
|
31
|
+
# end
|
32
|
+
|
33
|
+
# def import_data(tag, as: :document)
|
34
|
+
# doc = KManager.find_document(tag)
|
35
|
+
|
36
|
+
# return nil unless doc&.data
|
37
|
+
|
38
|
+
# # log.error 'about to import'
|
39
|
+
# doc.debug(include_header: true)
|
40
|
+
|
41
|
+
# return KUtil.data.to_open_struct(doc.data) if %i[open_struct ostruct].include?(as)
|
42
|
+
|
43
|
+
# doc.data
|
44
|
+
# end
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
def debug_importable
|
49
|
+
# log.kv 'class type' , self.class.name , debug_pad_size
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -67,28 +67,10 @@ module KDoc
|
|
67
67
|
@namespace = ns.is_a?(Array) ? ns : [ns]
|
68
68
|
end
|
69
69
|
|
70
|
-
# # Internal data object
|
71
|
-
# def data
|
72
|
-
# @data ||= @tag_options.delete(:data) || @tag_options.delete(:default_data) || default_data_value
|
73
|
-
# # Settings and Table on Model needed access to @data for modification, I don't think this should be a clone
|
74
|
-
# # never return the original data object, but at the same time
|
75
|
-
# # do not re-clone it every time this accessor is called.
|
76
|
-
# # @clone_data ||= @data.clone
|
77
|
-
# end
|
78
|
-
|
79
|
-
# Implement in container
|
80
|
-
# def default_container_type
|
81
|
-
# :container
|
82
|
-
# end
|
83
|
-
|
84
|
-
# def default_data_value
|
85
|
-
# {}
|
86
|
-
# end
|
87
|
-
|
88
70
|
protected
|
89
71
|
|
90
72
|
# rubocop:disable Metrics/AbcSize
|
91
|
-
def
|
73
|
+
def debug_taggable
|
92
74
|
log.kv 'tag' , tag , debug_pad_size
|
93
75
|
log.kv 'project' , project , debug_pad_size unless project.nil? || project.empty?
|
94
76
|
log.kv 'namespace' , namespace , debug_pad_size unless namespace.nil? || namespace.empty?
|
data/lib/k_doc/model.rb
CHANGED
data/lib/k_doc/version.rb
CHANGED
data/lib/k_doc.rb
CHANGED
@@ -15,6 +15,7 @@ require 'k_doc/mixins/taggable'
|
|
15
15
|
require 'k_doc/mixins/datum'
|
16
16
|
require 'k_doc/mixins/block_processor'
|
17
17
|
require 'k_doc/mixins/composable_components'
|
18
|
+
require 'k_doc/mixins/importable'
|
18
19
|
require 'k_doc/container'
|
19
20
|
# require 'k_doc/data'
|
20
21
|
require 'k_doc/action'
|
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.
|
4
|
+
version: 0.0.26
|
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-
|
11
|
+
date: 2022-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/k_doc/mixins/composable_components.rb
|
131
131
|
- lib/k_doc/mixins/datum.rb
|
132
132
|
- lib/k_doc/mixins/guarded.rb
|
133
|
+
- lib/k_doc/mixins/importable.rb
|
133
134
|
- lib/k_doc/mixins/taggable.rb
|
134
135
|
- lib/k_doc/model.rb
|
135
136
|
- lib/k_doc/model_backup.rb
|