k_doc 0.0.27 → 0.0.28

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13425498035dd9742336c907655e6555a37f7b4293c99443921bea29b38b0db9
4
- data.tar.gz: 63ff3b0ad02f17833cc23318d529c80cc1e0165eae4d18fb096db484f331808b
3
+ metadata.gz: f303cce0d48fa08ea50ce2e14a4c5d935fe927c2e634c03db0f2d909cb6a01a6
4
+ data.tar.gz: 5bffef8ae688894faf79e73c6fc04725315793d75795d784a3875563c7e6b1be
5
5
  SHA512:
6
- metadata.gz: d623d3964433ecbd4b33d4c4cce608d5e1923836ab6ffb3ab91c05dc9ae517719d2da2a14ca0ab3c83e5cace4593d2afaad80f24eaa4c8e8e48dd7b6229c886a
7
- data.tar.gz: 9557e8c8082bcfed3acb10fea6a4516e7aec04a49cfdf3f99fb3800faf32531937df8f52278db7a0e02f6543b8e22e25bbadef7d472e530a5ccaf6c8ae053081
6
+ metadata.gz: def580541db16a31f6c80759f7387da8a38f4e1ffbf4545d65ae14da72498fcc86e274b207931347937f55b4d78b9009443f6321b74a8b1a5224cc74127c28c4
7
+ data.tar.gz: e4cddb3891b5d4bc785833aa0d9de6efc19fd8d58f1525b99ca20b13407aa0a509ac4808fd70604093d9d7c67d0ffa64b9083af20ec45fba8a052dbd3dd29a5b
@@ -9,8 +9,11 @@ module KDoc
9
9
  include KDoc::Taggable
10
10
  include KDoc::Datum
11
11
  include KDoc::BlockProcessor
12
- include KDoc::Importable
13
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)
14
17
  attr_reader :opts
15
18
 
16
19
  # TODO: Owner/Owned need to be in a module and tested
@@ -21,11 +24,11 @@ module KDoc
21
24
  end
22
25
 
23
26
  def initialize(**opts, &block)
27
+ @context = OpenStruct.new
24
28
  @opts = opts
25
29
 
26
30
  initialize_tag(opts)
27
31
  initialize_data(opts)
28
- initialize_import(opts)
29
32
  initialize_block(opts, &block)
30
33
  end
31
34
 
@@ -8,9 +8,13 @@ module KDoc
8
8
  attr_accessor :block
9
9
  attr_accessor :block_state
10
10
 
11
- def initialize_block(_opts, &block)
11
+ # Proc/Handler to be called before evaluating when importing data
12
+ attr_reader :on_init
13
+
14
+ def initialize_block(opts, &block)
12
15
  @block = block if block_given?
13
- @block_state = :initial
16
+ @block_state = :new
17
+ @on_init = opts.delete(:on_init)
14
18
  end
15
19
 
16
20
  def evaluated?
@@ -21,16 +25,31 @@ module KDoc
21
25
  @block_state == :actioned
22
26
  end
23
27
 
24
- def execute_block(run_importer: nil, run_actions: nil)
25
- run_on_import if run_importer
28
+ def execute_block(run_actions: nil)
29
+ run_on_init
30
+
31
+ # return unless dependencies_met?
32
+
26
33
  eval_block
27
34
  run_on_action if run_actions
28
35
  end
29
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
+
30
50
  def eval_block
31
- return if @block.nil?
51
+ instance_eval(&block) if block
32
52
 
33
- instance_eval(&@block)
34
53
  @block_state = :evaluated
35
54
  rescue StandardError => e
36
55
  log.error('Standard error in document')
@@ -42,7 +61,7 @@ module KDoc
42
61
  end
43
62
 
44
63
  def run_on_action
45
- return if @block.nil?
64
+ return unless block
46
65
 
47
66
  if respond_to?(:on_action)
48
67
  on_action
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.27'
4
+ VERSION = '0.0.28'
5
5
  end
data/lib/k_doc.rb CHANGED
@@ -15,7 +15,6 @@ require 'k_doc/mixins/taggable'
15
15
  require 'k_doc/mixins/datum'
16
16
  require 'k_doc/mixins/block_processor'
17
17
  require 'k_doc/mixins/composable_components'
18
- require 'k_doc/mixins/importable'
19
18
  require 'k_doc/container'
20
19
  # require 'k_doc/data'
21
20
  require 'k_doc/action'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -130,7 +130,6 @@ files:
130
130
  - lib/k_doc/mixins/composable_components.rb
131
131
  - lib/k_doc/mixins/datum.rb
132
132
  - lib/k_doc/mixins/guarded.rb
133
- - lib/k_doc/mixins/importable.rb
134
133
  - lib/k_doc/mixins/taggable.rb
135
134
  - lib/k_doc/model.rb
136
135
  - lib/k_doc/model_backup.rb
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module KDoc
4
- # Alow documents to import data from other sources (usually other documents)
5
-
6
- module Importable
7
- include KLog::Logging
8
-
9
- # Proc/Handler to be called when importing data
10
- attr_reader :on_import
11
-
12
- # OpenStruct to be populated with data from import
13
- attr_reader :imports
14
-
15
- def initialize_import(opts)
16
- # log.error 'initialize_import'
17
- @on_import = opts.delete(:on_import)
18
- @imports = OpenStruct.new
19
- end
20
-
21
- def run_on_import
22
- return unless on_import
23
-
24
- instance_eval(&on_import)
25
- end
26
- end
27
- end