k_doc 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -2
- data/lib/k_doc/container.rb +5 -1
- data/lib/k_doc/mixins/block_processor.rb +2 -1
- data/lib/k_doc/mixins/importable.rb +8 -33
- data/lib/k_doc/model.rb +11 -0
- data/lib/k_doc/settings.rb +4 -0
- data/lib/k_doc/table.rb +4 -0
- data/lib/k_doc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13425498035dd9742336c907655e6555a37f7b4293c99443921bea29b38b0db9
|
4
|
+
data.tar.gz: 63ff3b0ad02f17833cc23318d529c80cc1e0165eae4d18fb096db484f331808b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d623d3964433ecbd4b33d4c4cce608d5e1923836ab6ffb3ab91c05dc9ae517719d2da2a14ca0ab3c83e5cace4593d2afaad80f24eaa4c8e8e48dd7b6229c886a
|
7
|
+
data.tar.gz: 9557e8c8082bcfed3acb10fea6a4516e7aec04a49cfdf3f99fb3800faf32531937df8f52278db7a0e02f6543b8e22e25bbadef7d472e530a5ccaf6c8ae053081
|
data/.rubocop.yml
CHANGED
data/lib/k_doc/container.rb
CHANGED
@@ -25,7 +25,7 @@ module KDoc
|
|
25
25
|
|
26
26
|
initialize_tag(opts)
|
27
27
|
initialize_data(opts)
|
28
|
-
initialize_import(opts)
|
28
|
+
initialize_import(opts)
|
29
29
|
initialize_block(opts, &block)
|
30
30
|
end
|
31
31
|
|
@@ -37,6 +37,10 @@ module KDoc
|
|
37
37
|
@default_data_type ||= Hash
|
38
38
|
end
|
39
39
|
|
40
|
+
def os(**opts)
|
41
|
+
OpenStruct.new(opts)
|
42
|
+
end
|
43
|
+
|
40
44
|
def debug
|
41
45
|
debug_taggable
|
42
46
|
debug_block_processor
|
@@ -6,47 +6,22 @@ module KDoc
|
|
6
6
|
module Importable
|
7
7
|
include KLog::Logging
|
8
8
|
|
9
|
-
|
9
|
+
# Proc/Handler to be called when importing data
|
10
|
+
attr_reader :on_import
|
11
|
+
|
12
|
+
# OpenStruct to be populated with data from import
|
10
13
|
attr_reader :imports
|
11
14
|
|
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
15
|
def initialize_import(opts)
|
17
16
|
# log.error 'initialize_import'
|
18
|
-
@
|
17
|
+
@on_import = opts.delete(:on_import)
|
19
18
|
@imports = OpenStruct.new
|
20
19
|
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
20
|
|
46
|
-
|
21
|
+
def run_on_import
|
22
|
+
return unless on_import
|
47
23
|
|
48
|
-
|
49
|
-
# log.kv 'class type' , self.class.name , debug_pad_size
|
24
|
+
instance_eval(&on_import)
|
50
25
|
end
|
51
26
|
end
|
52
27
|
end
|
data/lib/k_doc/model.rb
CHANGED
@@ -23,6 +23,12 @@ 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
|
+
if block.nil?
|
28
|
+
log.warn 'You cannot call settings without a block. Did you mean to call data[:settings] or odata.settings?'
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
26
32
|
setting_opts ||= {}
|
27
33
|
|
28
34
|
setting_opts = {}.merge(opts) # Container options
|
@@ -34,6 +40,11 @@ module KDoc
|
|
34
40
|
end
|
35
41
|
|
36
42
|
def table(key = :table, **opts, &block)
|
43
|
+
if block.nil?
|
44
|
+
log.warn 'You cannot call table without a block. Did you mean to call data[:table] or odata.table?'
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
37
48
|
# NEED to add support for run_decorators I think
|
38
49
|
opts.merge(parent: self)
|
39
50
|
table_instance(data, key, **opts, &block)
|
data/lib/k_doc/settings.rb
CHANGED
@@ -33,6 +33,10 @@ module KDoc
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def imports
|
37
|
+
parent.imports
|
38
|
+
end
|
39
|
+
|
36
40
|
# Return these settings which are attached to a data container using :key
|
37
41
|
# internal_data is a bad name, but it is unlikely to interfere with any setting names
|
38
42
|
# Maybe I rename this to raw_data
|
data/lib/k_doc/table.rb
CHANGED
data/lib/k_doc/version.rb
CHANGED
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.27
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|