k_doc 0.0.18 → 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/.builders/directors/_.rb +10 -0
- data/.builders/directors/build_actions.rb +39 -0
- data/.builders/directors/design_pattern_director.rb +39 -0
- data/.builders/directors/director.rb +185 -0
- data/.builders/directors/klue_director.rb +5 -0
- data/.builders/initializers/_.rb +7 -0
- data/.builders/initializers/configure_builder.rb +38 -0
- data/.builders/initializers/handlebars_helpers.rb +27 -0
- data/.builders/setup.rb +18 -0
- data/Guardfile +1 -1
- data/k_doc.gemspec +3 -0
- data/lib/k_doc/action.rb +28 -0
- data/lib/k_doc/container.rb +38 -39
- data/lib/k_doc/csv_doc.rb +64 -0
- data/lib/k_doc/fake_opinion.rb +11 -1
- data/lib/k_doc/json_doc.rb +58 -0
- data/lib/k_doc/mixins/block_processor.rb +45 -0
- data/lib/k_doc/mixins/composable_components.rb +38 -0
- data/lib/k_doc/mixins/datum.rb +45 -0
- data/lib/k_doc/mixins/guarded.rb +50 -0
- data/lib/k_doc/mixins/taggable.rb +118 -0
- data/lib/k_doc/model.rb +35 -80
- data/lib/k_doc/model_backup.rb +191 -0
- data/lib/k_doc/table.rb +1 -4
- data/lib/k_doc/version.rb +1 -1
- data/lib/k_doc/yaml_doc.rb +63 -0
- data/lib/k_doc.rb +47 -2
- metadata +23 -6
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module KDoc
|
6
|
+
# YamlDoc is a DSL for modeling YAML data objects
|
7
|
+
class YamlDoc < KDoc::Container
|
8
|
+
attr_reader :file
|
9
|
+
|
10
|
+
# Create YAML document
|
11
|
+
#
|
12
|
+
# @param [String|Symbol] name Name of the document
|
13
|
+
# @param args[0] Type of the document, defaults to KDoc:: FakeOpinion.new.default_csv_type if not set
|
14
|
+
# @param default: Default value (using named params), as above
|
15
|
+
def initialize(key = nil, **opts, &block)
|
16
|
+
super(**{ key: key }.merge(opts))
|
17
|
+
|
18
|
+
initialize_file
|
19
|
+
|
20
|
+
@block = block if block_given?
|
21
|
+
end
|
22
|
+
|
23
|
+
# Load data from file
|
24
|
+
#
|
25
|
+
# @param [Symbol] load_action The load_action to take if data has already been loaded
|
26
|
+
# @param [:once] load_action :once will load the data from content source on first try only
|
27
|
+
# @param [:reload] load_action :reload will reload from content source each time
|
28
|
+
# @param [Symbol] data_action The data_action to take when setting data, defaults to :replace
|
29
|
+
# @param [:replace] data_action :replace will replace the existing data instance with the incoming data value
|
30
|
+
# @param [:append] data_action :append will keep existing data and then new value data over the top
|
31
|
+
def load(load_action: :once, data_action: :replace)
|
32
|
+
return if load_action == :once && loaded?
|
33
|
+
|
34
|
+
content = File.read(file)
|
35
|
+
hash = YAML.safe_load(content)
|
36
|
+
|
37
|
+
set_data(hash, data_action: data_action)
|
38
|
+
|
39
|
+
@loaded = true
|
40
|
+
|
41
|
+
log_any_messages
|
42
|
+
end
|
43
|
+
|
44
|
+
def loaded?
|
45
|
+
@loaded
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def initialize_file
|
51
|
+
@file ||= opts.delete(:file) || ''
|
52
|
+
@loaded = false
|
53
|
+
end
|
54
|
+
|
55
|
+
def default_data_type
|
56
|
+
Hash
|
57
|
+
end
|
58
|
+
|
59
|
+
def default_container_type
|
60
|
+
:yaml
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/k_doc.rb
CHANGED
@@ -3,14 +3,24 @@
|
|
3
3
|
require 'securerandom'
|
4
4
|
|
5
5
|
require 'table_print'
|
6
|
+
require 'forwardable'
|
6
7
|
require 'k_log'
|
7
8
|
require 'k_type'
|
8
9
|
require 'k_util'
|
9
10
|
require 'k_decor'
|
10
11
|
|
11
12
|
require 'k_doc/version'
|
13
|
+
require 'k_doc/mixins/guarded'
|
14
|
+
require 'k_doc/mixins/taggable'
|
15
|
+
require 'k_doc/mixins/datum'
|
16
|
+
require 'k_doc/mixins/block_processor'
|
17
|
+
require 'k_doc/mixins/composable_components'
|
12
18
|
require 'k_doc/container'
|
13
19
|
# require 'k_doc/data'
|
20
|
+
require 'k_doc/action'
|
21
|
+
require 'k_doc/csv_doc'
|
22
|
+
require 'k_doc/json_doc'
|
23
|
+
require 'k_doc/yaml_doc'
|
14
24
|
require 'k_doc/model'
|
15
25
|
require 'k_doc/fake_opinion'
|
16
26
|
require 'k_doc/settings'
|
@@ -24,14 +34,49 @@ module KDoc
|
|
24
34
|
class Error < StandardError; end
|
25
35
|
|
26
36
|
class << self
|
27
|
-
# Is this needed
|
28
|
-
# Factory method to create a new model
|
29
37
|
def model(key = nil, **options, &block)
|
30
38
|
model = KDoc::Model.new(key, **options, &block)
|
31
39
|
model.execute_block
|
32
40
|
model
|
33
41
|
end
|
34
42
|
|
43
|
+
# These need to be registerable
|
44
|
+
def document(key = nil, **options, &block)
|
45
|
+
model(key, **{ type: :document }.merge(**options), &block)
|
46
|
+
end
|
47
|
+
|
48
|
+
def bootstrap(key = nil, **options, &block)
|
49
|
+
model(key, **{ type: :bootstrap }.merge(**options), &block)
|
50
|
+
end
|
51
|
+
|
52
|
+
def app_settings(key = nil, **options, &block)
|
53
|
+
model(key, **{ type: :app_settings }.merge(**options), &block)
|
54
|
+
end
|
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
|
+
|
62
|
+
def csv(key = nil, **options, &block)
|
63
|
+
doc = KDoc::CsvDoc.new(key, **options, &block)
|
64
|
+
doc.execute_block
|
65
|
+
doc
|
66
|
+
end
|
67
|
+
|
68
|
+
def json(key = nil, **options, &block)
|
69
|
+
doc = KDoc::JsonDoc.new(key, **options, &block)
|
70
|
+
doc.execute_block
|
71
|
+
doc
|
72
|
+
end
|
73
|
+
|
74
|
+
def yaml(key = nil, **options, &block)
|
75
|
+
doc = KDoc::YamlDoc.new(key, **options, &block)
|
76
|
+
doc.execute_block
|
77
|
+
doc
|
78
|
+
end
|
79
|
+
|
35
80
|
attr_accessor :opinion
|
36
81
|
attr_accessor :log
|
37
82
|
end
|
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-
|
11
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -88,6 +88,15 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
+
- ".builders/directors/_.rb"
|
92
|
+
- ".builders/directors/build_actions.rb"
|
93
|
+
- ".builders/directors/design_pattern_director.rb"
|
94
|
+
- ".builders/directors/director.rb"
|
95
|
+
- ".builders/directors/klue_director.rb"
|
96
|
+
- ".builders/initializers/_.rb"
|
97
|
+
- ".builders/initializers/configure_builder.rb"
|
98
|
+
- ".builders/initializers/handlebars_helpers.rb"
|
99
|
+
- ".builders/setup.rb"
|
91
100
|
- ".github/workflows/main.yml"
|
92
101
|
- ".gitignore"
|
93
102
|
- ".rspec"
|
@@ -110,21 +119,29 @@ files:
|
|
110
119
|
- hooks/update-version
|
111
120
|
- k_doc.gemspec
|
112
121
|
- lib/k_doc.rb
|
122
|
+
- lib/k_doc/action.rb
|
113
123
|
- lib/k_doc/container.rb
|
124
|
+
- lib/k_doc/csv_doc.rb
|
114
125
|
- lib/k_doc/decorators/settings_decorator.rb
|
115
126
|
- lib/k_doc/decorators/table_decorator.rb
|
116
127
|
- lib/k_doc/fake_opinion.rb
|
128
|
+
- lib/k_doc/json_doc.rb
|
129
|
+
- lib/k_doc/mixins/block_processor.rb
|
130
|
+
- lib/k_doc/mixins/composable_components.rb
|
131
|
+
- lib/k_doc/mixins/datum.rb
|
132
|
+
- lib/k_doc/mixins/guarded.rb
|
133
|
+
- lib/k_doc/mixins/taggable.rb
|
117
134
|
- lib/k_doc/model.rb
|
135
|
+
- lib/k_doc/model_backup.rb
|
118
136
|
- lib/k_doc/settings.rb
|
119
137
|
- lib/k_doc/table.rb
|
120
138
|
- lib/k_doc/version.rb
|
139
|
+
- lib/k_doc/yaml_doc.rb
|
121
140
|
homepage: http://appydave.com/gems/k-doc
|
122
141
|
licenses:
|
123
142
|
- MIT
|
124
143
|
metadata:
|
125
|
-
|
126
|
-
source_code_uri: https://github.com/klueless-io/k_doc
|
127
|
-
changelog_uri: https://github.com/klueless-io/k_doc/commits/master
|
144
|
+
rubygems_mfa_required: 'true'
|
128
145
|
post_install_message:
|
129
146
|
rdoc_options: []
|
130
147
|
require_paths:
|
@@ -140,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
157
|
- !ruby/object:Gem::Version
|
141
158
|
version: '0'
|
142
159
|
requirements: []
|
143
|
-
rubygems_version: 3.2.
|
160
|
+
rubygems_version: 3.2.33
|
144
161
|
signing_key:
|
145
162
|
specification_version: 4
|
146
163
|
summary: KDoc provides a document in the form a DSL that contains flexible key/value
|