k_doc 0.0.23 → 0.0.24
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/lib/k_doc/action.rb +28 -0
- data/lib/k_doc/container.rb +1 -1
- data/lib/k_doc/fake_opinion.rb +4 -1
- data/lib/k_doc/mixins/guarded.rb +5 -1
- data/lib/k_doc/mixins/taggable.rb +7 -6
- data/lib/k_doc/version.rb +1 -1
- data/lib/k_doc.rb +7 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62acce8bfac2c242082dd6cf050db2d7e6c535bc6af229f50b4185aec7573261
|
|
4
|
+
data.tar.gz: 23b23c0dffa5da8de05f88c0f470aa63dbdfe3f734582872debf0a74edd1c8fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3762d2ab76f5d4128a2330ea7ad84db2234bea4a56bec313ade497691a46df0f0e20aec4445268647b49d2d68279c3c5730d0ebdecd0b2dba0e48d15b7d77ded
|
|
7
|
+
data.tar.gz: 8e9054976e5e0fbe40e9a27cb3e5244cbd451b5d67c30246d874348b75fd17877774ac0dd819da017db8a3c02439e7fe70aa1fee9887c292d4d0c8997187fad6
|
data/lib/k_doc/action.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module KDoc
|
|
4
|
+
# Action is a DSL for modeling JSON data objects
|
|
5
|
+
class Action < KDoc::Container
|
|
6
|
+
attr_reader :file
|
|
7
|
+
|
|
8
|
+
# Simple Ruby Action
|
|
9
|
+
#
|
|
10
|
+
# @param [String|Symbol] name Name of the document
|
|
11
|
+
# @param args[0] Type of the document, defaults to KDoc:: FakeOpinion.new.default_action_type if not set
|
|
12
|
+
# @param default: Default value (using named params), as above
|
|
13
|
+
# @param [Proc] block The block is stored and accessed different types in the document loading workflow.
|
|
14
|
+
def initialize(key = nil, **opts, &_block)
|
|
15
|
+
super(**{ key: key }.merge(opts))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def default_data_type
|
|
21
|
+
String
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def default_container_type
|
|
25
|
+
:action
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
data/lib/k_doc/container.rb
CHANGED
data/lib/k_doc/fake_opinion.rb
CHANGED
|
@@ -7,6 +7,7 @@ module KDoc
|
|
|
7
7
|
# how I want to implement this
|
|
8
8
|
# Need to look at the configuration patterns, this is really a configuration
|
|
9
9
|
class FakeOpinion
|
|
10
|
+
attr_accessor :default_action_type
|
|
10
11
|
attr_accessor :default_model_type
|
|
11
12
|
attr_accessor :default_csv_type
|
|
12
13
|
attr_accessor :default_json_type
|
|
@@ -19,7 +20,9 @@ module KDoc
|
|
|
19
20
|
attr_accessor :table_class
|
|
20
21
|
|
|
21
22
|
def initialize
|
|
22
|
-
@default_model_type = :entity
|
|
23
|
+
# @default_model_type = :entity
|
|
24
|
+
@default_action_type = :action
|
|
25
|
+
@default_model_type = :kdoc
|
|
23
26
|
@default_csv_type = :csv
|
|
24
27
|
@default_json_type = :json
|
|
25
28
|
@default_yaml_type = :yaml
|
data/lib/k_doc/mixins/guarded.rb
CHANGED
|
@@ -7,7 +7,7 @@ module KDoc
|
|
|
7
7
|
module Guarded
|
|
8
8
|
Guard = Struct.new(:type, :message)
|
|
9
9
|
|
|
10
|
-
def guard(message)
|
|
10
|
+
def guard(message, log: false)
|
|
11
11
|
errors << Guard.new(:guard, message)
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -42,5 +42,9 @@ module KDoc
|
|
|
42
42
|
log.error error.message if error.type == :guard
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
|
+
|
|
46
|
+
def clear_errors
|
|
47
|
+
errors.clear
|
|
48
|
+
end
|
|
45
49
|
end
|
|
46
50
|
end
|
|
@@ -89,17 +89,18 @@ module KDoc
|
|
|
89
89
|
|
|
90
90
|
# rubocop:disable Metrics/AbcSize
|
|
91
91
|
def debug_container
|
|
92
|
-
log.kv 'tag'
|
|
93
|
-
log.kv 'project'
|
|
94
|
-
log.kv 'namespace', namespace
|
|
95
|
-
log.kv 'key'
|
|
96
|
-
log.kv 'type'
|
|
92
|
+
log.kv 'tag' , tag , debug_pad_size
|
|
93
|
+
log.kv 'project' , project , debug_pad_size unless project.nil? || project.empty?
|
|
94
|
+
log.kv 'namespace' , namespace , debug_pad_size unless namespace.nil? || namespace.empty?
|
|
95
|
+
log.kv 'key' , key , debug_pad_size
|
|
96
|
+
log.kv 'type' , type , debug_pad_size
|
|
97
|
+
log.kv 'class type' , self.class.name , debug_pad_size
|
|
97
98
|
# log.kv 'error' , error , debug_kv_pad_size
|
|
98
99
|
end
|
|
99
100
|
# rubocop:enable Metrics/AbcSize
|
|
100
101
|
|
|
101
102
|
def debug_pad_size
|
|
102
|
-
@debug_pad_size ||= @tag_options.delete(:debug_pad_size) ||
|
|
103
|
+
@debug_pad_size ||= @tag_options.delete(:debug_pad_size) || 20
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
private
|
data/lib/k_doc/version.rb
CHANGED
data/lib/k_doc.rb
CHANGED
|
@@ -17,6 +17,7 @@ require 'k_doc/mixins/block_processor'
|
|
|
17
17
|
require 'k_doc/mixins/composable_components'
|
|
18
18
|
require 'k_doc/container'
|
|
19
19
|
# require 'k_doc/data'
|
|
20
|
+
require 'k_doc/action'
|
|
20
21
|
require 'k_doc/csv_doc'
|
|
21
22
|
require 'k_doc/json_doc'
|
|
22
23
|
require 'k_doc/yaml_doc'
|
|
@@ -52,6 +53,12 @@ module KDoc
|
|
|
52
53
|
model(key, **{ type: :app_settings }.merge(**options), &block)
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
def action(key = nil, **options, &block)
|
|
57
|
+
doc = KDoc::Action.new(key, **options, &block)
|
|
58
|
+
doc.execute_block
|
|
59
|
+
doc
|
|
60
|
+
end
|
|
61
|
+
|
|
55
62
|
def csv(key = nil, **options, &block)
|
|
56
63
|
doc = KDoc::CsvDoc.new(key, **options, &block)
|
|
57
64
|
doc.execute_block
|
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.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Cruwys
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-12-
|
|
11
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -119,6 +119,7 @@ files:
|
|
|
119
119
|
- hooks/update-version
|
|
120
120
|
- k_doc.gemspec
|
|
121
121
|
- lib/k_doc.rb
|
|
122
|
+
- lib/k_doc/action.rb
|
|
122
123
|
- lib/k_doc/container.rb
|
|
123
124
|
- lib/k_doc/csv_doc.rb
|
|
124
125
|
- lib/k_doc/decorators/settings_decorator.rb
|
|
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
156
157
|
- !ruby/object:Gem::Version
|
|
157
158
|
version: '0'
|
|
158
159
|
requirements: []
|
|
159
|
-
rubygems_version: 3.2.
|
|
160
|
+
rubygems_version: 3.2.33
|
|
160
161
|
signing_key:
|
|
161
162
|
specification_version: 4
|
|
162
163
|
summary: KDoc provides a document in the form a DSL that contains flexible key/value
|