k_doc 0.0.21 → 0.0.25
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/directors/director.rb +1 -1
- data/.builders/initializers/configure_builder.rb +3 -3
- data/README.md +0 -11
- data/k_doc.gemspec +3 -0
- data/lib/k_doc/action.rb +28 -0
- data/lib/k_doc/container.rb +3 -3
- data/lib/k_doc/csv_doc.rb +2 -2
- data/lib/k_doc/fake_opinion.rb +4 -1
- data/lib/k_doc/json_doc.rb +2 -2
- data/lib/k_doc/mixins/datum.rb +6 -9
- data/lib/k_doc/mixins/guarded.rb +26 -5
- data/lib/k_doc/mixins/taggable.rb +9 -7
- data/lib/k_doc/version.rb +1 -1
- data/lib/k_doc/yaml_doc.rb +4 -2
- data/lib/k_doc.rb +7 -0
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a629e6b0524e5610debb6b933e7473cf122518a9e7b0d86a8627e4d1e23380e
|
4
|
+
data.tar.gz: bac4ddc4e068b3c975ed51fcb2c93c6bbbdd7b2c9da6d82dc7706432b803b4f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bf61c53b8f3c75e315bf9ca05473c0c0c7b08c371ca62135297a66e5f96f8991f34df27cb3e7a75244b6037dde8023ad33cff7c98435415024c49392f18c666
|
7
|
+
data.tar.gz: 5f3c9aa53fdcf7022285818d5a857374050aad58523a74b1cb06c42a2bb603589d23745d0b36a018f2b8477b6aec666ed92be219cde9fd9e9a167766decb90da
|
@@ -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/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/k_doc.gemspec
CHANGED
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
@@ -14,7 +14,7 @@ module KDoc
|
|
14
14
|
|
15
15
|
# TODO: Owner/Owned need to be in a module and tested
|
16
16
|
attr_accessor :owner
|
17
|
-
|
17
|
+
|
18
18
|
def owned?
|
19
19
|
@owner != nil
|
20
20
|
end
|
@@ -31,8 +31,8 @@ module KDoc
|
|
31
31
|
:container
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
34
|
+
def default_data_type
|
35
|
+
@default_data_type ||= Hash
|
36
36
|
end
|
37
37
|
|
38
38
|
def debug
|
data/lib/k_doc/csv_doc.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/json_doc.rb
CHANGED
data/lib/k_doc/mixins/datum.rb
CHANGED
@@ -8,17 +8,14 @@ module KDoc
|
|
8
8
|
attr_reader :data
|
9
9
|
|
10
10
|
def initialize_data(opts)
|
11
|
-
@
|
12
|
-
@data = opts.delete(:data) || opts.delete(:default_data) ||
|
11
|
+
@default_data_type = opts.delete(:default_data_type) if opts.key?(:default_data_type)
|
12
|
+
@data = opts.delete(:data) || opts.delete(:default_data) || default_data_type.new
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
warn("Incompatible data type - #{default_data_value.class} is incompatible with #{data.class}")
|
17
|
-
@data = default_data_value
|
14
|
+
warn("Incompatible data type - #{default_data_type} is incompatible with #{data.class} in constructor") unless data.is_a?(default_data_type)
|
18
15
|
end
|
19
16
|
|
20
|
-
def
|
21
|
-
raise 'Implement
|
17
|
+
def default_data_type
|
18
|
+
raise 'Implement default_data_type in container' unless @default_data_type
|
22
19
|
end
|
23
20
|
|
24
21
|
# Write data object
|
@@ -28,7 +25,7 @@ module KDoc
|
|
28
25
|
# @param [:replace] data_action :replace will replace the existing data instance with the incoming data value
|
29
26
|
# @param [:append] data_action :append will keep existing data and then new value data over the top
|
30
27
|
def set_data(value, data_action: :replace)
|
31
|
-
|
28
|
+
warn("Incompatible data type - #{default_data_type} is incompatible with #{value.class} in set data") unless value.is_a?(default_data_type)
|
32
29
|
|
33
30
|
case data_action
|
34
31
|
when :replace
|
data/lib/k_doc/mixins/guarded.rb
CHANGED
@@ -5,12 +5,14 @@ module KDoc
|
|
5
5
|
#
|
6
6
|
# TODO: this could be moved into KType or KGuard
|
7
7
|
module Guarded
|
8
|
-
|
9
|
-
|
8
|
+
Guard = Struct.new(:type, :message)
|
9
|
+
|
10
|
+
def guard(message, log: false)
|
11
|
+
errors << Guard.new(:guard, message)
|
10
12
|
end
|
11
13
|
|
12
14
|
def warn(message)
|
13
|
-
errors <<
|
15
|
+
errors << Guard.new(:warning, message)
|
14
16
|
end
|
15
17
|
alias warning warn
|
16
18
|
|
@@ -19,11 +21,30 @@ module KDoc
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def error_messages
|
22
|
-
|
24
|
+
errors.map(&:message)
|
25
|
+
end
|
26
|
+
|
27
|
+
def error_hash
|
28
|
+
errors.map(&:to_h)
|
23
29
|
end
|
24
30
|
|
31
|
+
# TODO: Add these predicates
|
32
|
+
# def errors?
|
33
|
+
# def warnings?
|
34
|
+
|
25
35
|
def valid?
|
26
|
-
|
36
|
+
errors.length.zero?
|
37
|
+
end
|
38
|
+
|
39
|
+
def log_any_messages
|
40
|
+
errors.each do |error|
|
41
|
+
log.warn error.message if error.type == :warning
|
42
|
+
log.error error.message if error.type == :guard
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def clear_errors
|
47
|
+
errors.clear
|
27
48
|
end
|
28
49
|
end
|
29
50
|
end
|
@@ -44,6 +44,7 @@ module KDoc
|
|
44
44
|
@type ||= @tag_options.delete(:type) || default_container_type
|
45
45
|
end
|
46
46
|
|
47
|
+
# TODO: rename to area (or area root namespace)
|
47
48
|
# Project name
|
48
49
|
#
|
49
50
|
# Examples
|
@@ -88,17 +89,18 @@ module KDoc
|
|
88
89
|
|
89
90
|
# rubocop:disable Metrics/AbcSize
|
90
91
|
def debug_container
|
91
|
-
log.kv 'tag'
|
92
|
-
log.kv 'project'
|
93
|
-
log.kv 'namespace', namespace
|
94
|
-
log.kv 'key'
|
95
|
-
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
|
96
98
|
# log.kv 'error' , error , debug_kv_pad_size
|
97
99
|
end
|
98
100
|
# rubocop:enable Metrics/AbcSize
|
99
101
|
|
100
102
|
def debug_pad_size
|
101
|
-
@debug_pad_size ||= @tag_options.delete(:debug_pad_size) ||
|
103
|
+
@debug_pad_size ||= @tag_options.delete(:debug_pad_size) || 20
|
102
104
|
end
|
103
105
|
|
104
106
|
private
|
@@ -107,8 +109,8 @@ module KDoc
|
|
107
109
|
values = []
|
108
110
|
values << project if project
|
109
111
|
values += namespace
|
110
|
-
values << type if type
|
111
112
|
values << key
|
113
|
+
values << type if type
|
112
114
|
values -= [nil, '']
|
113
115
|
@tag = values.join('_').to_sym
|
114
116
|
end
|
data/lib/k_doc/version.rb
CHANGED
data/lib/k_doc/yaml_doc.rb
CHANGED
@@ -37,6 +37,8 @@ module KDoc
|
|
37
37
|
set_data(hash, data_action: data_action)
|
38
38
|
|
39
39
|
@loaded = true
|
40
|
+
|
41
|
+
log_any_messages
|
40
42
|
end
|
41
43
|
|
42
44
|
def loaded?
|
@@ -50,8 +52,8 @@ module KDoc
|
|
50
52
|
@loaded = false
|
51
53
|
end
|
52
54
|
|
53
|
-
def
|
54
|
-
|
55
|
+
def default_data_type
|
56
|
+
Hash
|
55
57
|
end
|
56
58
|
|
57
59
|
def default_container_type
|
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.25
|
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-12 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
|
@@ -140,9 +141,7 @@ homepage: http://appydave.com/gems/k-doc
|
|
140
141
|
licenses:
|
141
142
|
- MIT
|
142
143
|
metadata:
|
143
|
-
|
144
|
-
source_code_uri: https://github.com/klueless-io/k_doc
|
145
|
-
changelog_uri: https://github.com/klueless-io/k_doc/commits/master
|
144
|
+
rubygems_mfa_required: 'true'
|
146
145
|
post_install_message:
|
147
146
|
rdoc_options: []
|
148
147
|
require_paths:
|
@@ -158,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
157
|
- !ruby/object:Gem::Version
|
159
158
|
version: '0'
|
160
159
|
requirements: []
|
161
|
-
rubygems_version: 3.2.
|
160
|
+
rubygems_version: 3.2.33
|
162
161
|
signing_key:
|
163
162
|
specification_version: 4
|
164
163
|
summary: KDoc provides a document in the form a DSL that contains flexible key/value
|