k_doc 0.0.24 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/directors/director.rb +1 -1
- data/.builders/initializers/configure_builder.rb +3 -3
- data/.rubocop.yml +8 -13
- data/README.md +0 -11
- data/lib/k_doc/container.rb +11 -1
- data/lib/k_doc/mixins/block_processor.rb +45 -5
- data/lib/k_doc/mixins/taggable.rb +1 -19
- data/lib/k_doc/model.rb +13 -1
- 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: f303cce0d48fa08ea50ce2e14a4c5d935fe927c2e634c03db0f2d909cb6a01a6
|
4
|
+
data.tar.gz: 5bffef8ae688894faf79e73c6fc04725315793d75795d784a3875563c7e6b1be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: def580541db16a31f6c80759f7387da8a38f4e1ffbf4545d65ae14da72498fcc86e274b207931347937f55b4d78b9009443f6321b74a8b1a5224cc74127c28c4
|
7
|
+
data.tar.gz: e4cddb3891b5d4bc785833aa0d9de6efc19fd8d58f1525b99ca20b13407aa0a509ac4808fd70604093d9d7c67d0ffa64b9083af20ec45fba8a052dbd3dd29a5b
|
@@ -1,5 +1,5 @@
|
|
1
1
|
KBuilder.reset(:gem)
|
2
|
-
|
2
|
+
KConfig.configure(:gem) do |config|
|
3
3
|
# config.template_folders.add(:global , '~/dev/kgems/k_templates/definitions/genesis')
|
4
4
|
config.target_folders.add(:root , File.expand_path('..', Dir.getwd))
|
5
5
|
config.target_folders.add(:lib , :root, 'lib', 'k_doc')
|
@@ -7,14 +7,14 @@ KBuilder.configure(:gem) do |config|
|
|
7
7
|
end
|
8
8
|
|
9
9
|
KBuilder.reset(:design_patterns)
|
10
|
-
|
10
|
+
KConfig.configure(:design_patterns) do |config|
|
11
11
|
config.template_folders.add(:global , '~/dev/kgems/k_templates/templates/ruby_design_patterns')
|
12
12
|
config.target_folders.add(:root , File.expand_path('..', Dir.getwd))
|
13
13
|
config.target_folders.add(:lib , :root, 'lib', 'k_doc')
|
14
14
|
config.target_folders.add(:spec , :root, 'spec', 'k_doc')
|
15
15
|
end
|
16
16
|
|
17
|
-
#
|
17
|
+
# KConfig.configuration(:gem).debug
|
18
18
|
|
19
19
|
# def builder
|
20
20
|
# @builder ||= KBuilder::BaseBuilder.init
|
data/.rubocop.yml
CHANGED
@@ -44,15 +44,19 @@ 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
|
+
Enabled: false
|
56
60
|
Metrics/ClassLength:
|
57
61
|
Enabled: false
|
58
62
|
Metrics/ModuleLength:
|
@@ -63,23 +67,14 @@ Naming/MemoizedInstanceVariableName:
|
|
63
67
|
Naming/VariableNumber:
|
64
68
|
Exclude:
|
65
69
|
- "**/spec/**/*"
|
66
|
-
Style/EmptyMethod:
|
67
|
-
Exclude:
|
68
|
-
- "**/spec/**/*"
|
69
70
|
Metrics/ParameterLists:
|
70
71
|
Exclude:
|
71
72
|
- "**/spec/**/*"
|
72
73
|
Layout/EmptyLineBetweenDefs:
|
73
74
|
Exclude:
|
74
75
|
- "**/spec/**/*"
|
75
|
-
|
76
76
|
Lint/AmbiguousBlockAssociation:
|
77
77
|
Exclude:
|
78
78
|
- "**/spec/**/*"
|
79
|
-
|
80
|
-
Style/AccessorGrouping:
|
81
|
-
Enabled: false
|
82
|
-
|
83
79
|
Layout/SpaceBeforeComma:
|
84
80
|
Enabled: false
|
85
|
-
# My Preferences - End
|
data/README.md
CHANGED
@@ -52,17 +52,6 @@ Checkout the repo
|
|
52
52
|
git clone klueless-io/k_doc
|
53
53
|
```
|
54
54
|
|
55
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
56
|
-
|
57
|
-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
58
|
-
|
59
|
-
```bash
|
60
|
-
bin/console
|
61
|
-
|
62
|
-
Aaa::Bbb::Program.execute()
|
63
|
-
# => ""
|
64
|
-
```
|
65
|
-
|
66
55
|
`k_doc` is setup with Guard, run `guard`, this will watch development file changes and run tests automatically, if successful, it will then run rubocop for style quality.
|
67
56
|
|
68
57
|
To release a new version, update the version number in `version.rb`, build the gem and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
data/lib/k_doc/container.rb
CHANGED
@@ -10,6 +10,10 @@ module KDoc
|
|
10
10
|
include KDoc::Datum
|
11
11
|
include KDoc::BlockProcessor
|
12
12
|
|
13
|
+
# OpenStruct to be populated with context data, this can be used inside the on_init
|
14
|
+
attr_reader :context
|
15
|
+
|
16
|
+
# Opts that are passed to the container. Some options will be removed when evaluated by different plugins (Taggable, BlockProcessor)
|
13
17
|
attr_reader :opts
|
14
18
|
|
15
19
|
# TODO: Owner/Owned need to be in a module and tested
|
@@ -20,6 +24,7 @@ module KDoc
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def initialize(**opts, &block)
|
27
|
+
@context = OpenStruct.new
|
23
28
|
@opts = opts
|
24
29
|
|
25
30
|
initialize_tag(opts)
|
@@ -35,8 +40,13 @@ module KDoc
|
|
35
40
|
@default_data_type ||= Hash
|
36
41
|
end
|
37
42
|
|
43
|
+
def os(**opts)
|
44
|
+
OpenStruct.new(opts)
|
45
|
+
end
|
46
|
+
|
38
47
|
def debug
|
39
|
-
|
48
|
+
debug_taggable
|
49
|
+
debug_block_processor
|
40
50
|
debug_errors
|
41
51
|
end
|
42
52
|
|
@@ -6,20 +6,51 @@ module KDoc
|
|
6
6
|
# Rename: BlockProcessor
|
7
7
|
module BlockProcessor
|
8
8
|
attr_accessor :block
|
9
|
+
attr_accessor :block_state
|
9
10
|
|
10
|
-
|
11
|
+
# Proc/Handler to be called before evaluating when importing data
|
12
|
+
attr_reader :on_init
|
13
|
+
|
14
|
+
def initialize_block(opts, &block)
|
11
15
|
@block = block if block_given?
|
16
|
+
@block_state = :new
|
17
|
+
@on_init = opts.delete(:on_init)
|
18
|
+
end
|
19
|
+
|
20
|
+
def evaluated?
|
21
|
+
@block_state == :evaluated || @block_state == :actioned
|
22
|
+
end
|
23
|
+
|
24
|
+
def actioned?
|
25
|
+
@block_state == :actioned
|
12
26
|
end
|
13
27
|
|
14
28
|
def execute_block(run_actions: nil)
|
29
|
+
run_on_init
|
30
|
+
|
31
|
+
# return unless dependencies_met?
|
32
|
+
|
15
33
|
eval_block
|
16
34
|
run_on_action if run_actions
|
17
35
|
end
|
18
36
|
|
37
|
+
def run_on_init
|
38
|
+
instance_eval(&on_init) if on_init
|
39
|
+
|
40
|
+
@block_state = :initialized
|
41
|
+
rescue StandardError => e
|
42
|
+
log.error('Standard error in document on_init')
|
43
|
+
# puts "key #{unique_key}"
|
44
|
+
# puts "file #{KUtil.data.console_file_hyperlink(resource.file, resource.file)}"
|
45
|
+
log.error(e.message)
|
46
|
+
@error = e
|
47
|
+
raise
|
48
|
+
end
|
49
|
+
|
19
50
|
def eval_block
|
20
|
-
|
51
|
+
instance_eval(&block) if block
|
21
52
|
|
22
|
-
|
53
|
+
@block_state = :evaluated
|
23
54
|
rescue StandardError => e
|
24
55
|
log.error('Standard error in document')
|
25
56
|
# puts "key #{unique_key}"
|
@@ -30,9 +61,12 @@ module KDoc
|
|
30
61
|
end
|
31
62
|
|
32
63
|
def run_on_action
|
33
|
-
return
|
64
|
+
return unless block
|
34
65
|
|
35
|
-
|
66
|
+
if respond_to?(:on_action)
|
67
|
+
on_action
|
68
|
+
@block_state = :actioned
|
69
|
+
end
|
36
70
|
rescue StandardError => e
|
37
71
|
log.error('Standard error while running actions')
|
38
72
|
# puts "key #{unique_key}"
|
@@ -41,5 +75,11 @@ module KDoc
|
|
41
75
|
@error = e
|
42
76
|
raise
|
43
77
|
end
|
78
|
+
|
79
|
+
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?)
|
83
|
+
end
|
44
84
|
end
|
45
85
|
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
@@ -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)
|
@@ -115,7 +126,8 @@ module KDoc
|
|
115
126
|
|
116
127
|
def debug_header
|
117
128
|
log.heading self.class.name
|
118
|
-
|
129
|
+
debug_taggable
|
130
|
+
debug_block_processor
|
119
131
|
debug_header_keys
|
120
132
|
|
121
133
|
log.line
|
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.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|