k_doc 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64615008b76feb26a84e9dd808654495cf3f26bf42f6941b00eaca9013081a76
4
- data.tar.gz: e69ccfb764c6dd9df4ee1fe78df56f717726f733184839020d3df968c34fde63
3
+ metadata.gz: f5d1fec58551c4d2c72de3c9629c0b90847352c38b2d491a021dfce0d72afac6
4
+ data.tar.gz: 7f38b815def0fdcabd801daf8e9e569c36213f306f28781d8956f8bfa12b0be7
5
5
  SHA512:
6
- metadata.gz: 94d4cd31dddad2f142fa418c24025c866124722e8f93ee3133d1d7c68893640954c7203e5bd5a502eb75f9650c444d7103945af6fa901ece63450a0537b130d3
7
- data.tar.gz: f1a6e045702b3e9c94146ae413f573fc281472eaf5927e9b27a819445cff112b2a688863c7f0bf2d2d4e996e703dd3f4f7721c7766ecd621feb4971b24cfddba
6
+ metadata.gz: d2ec5f47f7f5dd3cf295bb430615768149724233451b0aaa09aaecca56752292b167948714ea4f146f8050488a7019a2b90ab7d824c6e540dcfc0de0831af5bb
7
+ data.tar.gz: bc816e70fc04faaf6109e4abe57528b48df868b48bee93eecbc152aa782d22c44a98304eef09f8cbd9bbbbd4ec6ab7dc7ab50b16f73f98b915dae24326928c40
data/lib/k_doc.rb CHANGED
@@ -15,7 +15,6 @@ require 'k_doc/model'
15
15
  require 'k_doc/fake_opinion'
16
16
  require 'k_doc/settings'
17
17
  require 'k_doc/table'
18
- require 'k_doc/util'
19
18
 
20
19
  require 'k_doc/decorators/settings_decorator'
21
20
  require 'k_doc/decorators/table_decorator'
@@ -25,6 +24,7 @@ module KDoc
25
24
  class Error < StandardError; end
26
25
 
27
26
  class << self
27
+ # Is this needed
28
28
  # Factory method to create a new model
29
29
  def model(key = nil, **options, &block)
30
30
  model = KDoc::Model.new(key, **options, &block)
@@ -33,12 +33,10 @@ module KDoc
33
33
  end
34
34
 
35
35
  attr_accessor :opinion
36
- attr_accessor :util
37
36
  attr_accessor :log
38
37
  end
39
38
 
40
39
  KDoc.opinion = KDoc::FakeOpinion.new
41
- KDoc.util = KDoc::Util.new
42
40
  end
43
41
 
44
42
  if ENV['KLUE_DEBUG']&.to_s&.downcase == 'true'
@@ -6,15 +6,22 @@ module KDoc
6
6
  class Container
7
7
  # include KLog::Logging
8
8
 
9
- # Seems like there is way too much data here
10
- # Firstly it should probably be in an interface
11
- # Secondly some of this (namespace, project_key, error) belongs in k_manager
12
- # So container would be better off just being key, type, data
9
+ # Name of the document (required)
10
+ #
11
+ # Examples: user, account, country
13
12
  attr_reader :key
14
13
 
15
- # NOTE: This should not be using an opinion in this project
14
+ # Type of data
15
+ #
16
+ # Examples by data type
17
+ # :csv, :yaml, :json, :xml
18
+ #
19
+ # Examples by shape of the data in a DSL
20
+ # :entity, :microapp, blueprint
16
21
  attr_reader :type
17
22
 
23
+ attr_writer :data
24
+
18
25
  # Move this up to k_manager
19
26
  # attr_reader :namespace
20
27
  # attr_reader :project_key
@@ -32,30 +39,15 @@ module KDoc
32
39
  # @option opts [String|Symbol] project_key Project that the container belongs to
33
40
  def initialize(**opts)
34
41
  @key = opts[:key] || SecureRandom.alphanumeric(4)
35
- @type = opts[:type] || '' # KDoc.opinion.default_model_type
36
- # @namespace = opts[:namespace] || ''
37
- # @project_key = opts[:project_key] || ''
38
-
39
- # Old name is default_data, wonder if I still need that idea?
40
- # Most documents live within a hash, some tabular documents such as CSV will use an []
41
- # @data = slice_option(:default_data) || {}
42
+ @type = opts[:type] || ''
42
43
  @data = opts[:data] || {}
43
44
  end
44
45
 
45
- # def unique_key
46
- # @unique_key ||= KDoc.util.build_unique_key(key, type, namespace, project_key)
47
- # end
48
-
49
46
  def debug_header
50
47
  log.kv 'key', key
51
48
  log.kv 'type', type
52
- # log.kv 'namespace', namespace
53
- # log.kv 'project_key', namespace
54
- # log.kv 'error', error
55
49
  end
56
50
 
57
- attr_writer :data
58
-
59
51
  def data
60
52
  @data.clone
61
53
  end
data/lib/k_doc/model.rb CHANGED
@@ -50,7 +50,7 @@ module KDoc
50
50
  # raise
51
51
  rescue StandardError => e
52
52
  log.error('Standard error in document')
53
- puts "key #{unique_key}"
53
+ # puts "key #{unique_key}"
54
54
  # puts "file #{KUtil.data.console_file_hyperlink(resource.file, resource.file)}"
55
55
  log.error(e.message)
56
56
  @error = e
@@ -60,11 +60,6 @@ module KDoc
60
60
  @run_actions = nil
61
61
  end
62
62
 
63
- # Move this up to k_manager
64
- # def unique_key
65
- # @unique_key ||= KDoc.util.build_unique_key(key, type, namespace)
66
- # end
67
-
68
63
  def settings(key = nil, **options, &block)
69
64
  options ||= {}
70
65
 
@@ -164,6 +159,7 @@ module KDoc
164
159
 
165
160
  def initialize_attributes(**options)
166
161
  @options = options || {}
162
+ # Is parent a part of model, or is it part of k_manager::document_taggable
167
163
  @parent = slice_option(:parent)
168
164
 
169
165
  # Most documents live within a hash, some tabular documents such as CSV will use an []
data/lib/k_doc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDoc
4
- VERSION = '0.0.16'
4
+ VERSION = '0.0.17'
5
5
  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.16
4
+ version: 0.0.17
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-04-24 00:00:00.000000000 Z
11
+ date: 2021-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -117,7 +117,6 @@ files:
117
117
  - lib/k_doc/model.rb
118
118
  - lib/k_doc/settings.rb
119
119
  - lib/k_doc/table.rb
120
- - lib/k_doc/util.rb
121
120
  - lib/k_doc/version.rb
122
121
  homepage: http://appydave.com/gems/k-doc
123
122
  licenses:
data/lib/k_doc/util.rb DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module KDoc
4
- # Utility helper methods for KDoc
5
- class Util
6
- # Build a unique key so that resources of the same key do not conflict with
7
- # one another across projects, namespaces or types
8
- #
9
- # @param [String] param_name Param description
10
- def build_unique_key(key, type = nil, namespace = nil, project_key = nil)
11
- raise KDoc::Error, 'key is required when generating unique key' if key.nil? || key.empty?
12
-
13
- type ||= KDoc.opinion.default_model_type
14
-
15
- keys = [project_key, namespace, key, type].reject { |k| k.nil? || k == '' }.map { |k| k.to_s.gsub('_', '-') }
16
-
17
- keys.join('-')
18
- end
19
- end
20
- end