avm-eac_asciidoctor_base0 0.17.0 → 0.18.0

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: 46fa936707853578159b6c9c7b1b877ca534305a71fe1b113ff7cad89e879f93
4
- data.tar.gz: 5963719ff16c228999a5d080d43ef57464672eaa10c765eb5646af9e23593fb4
3
+ metadata.gz: fcb1cedbd51e3b81094be7bbe647eb4867bf0ffcd1dc7bcaff0f7a7eb7e8b151
4
+ data.tar.gz: 97cd9f5b49a969195a447a21c9d40b49b7e29c6d9ce56faf7bd4208df399f143
5
5
  SHA512:
6
- metadata.gz: b86abd89d760294967e9b58ad07fef5c89a76095a0848c80921dc58d188f2f6275b2684dacf2b1118524bffd15e0cd47638843facabf7d3eea47a6edf107d998
7
- data.tar.gz: 3b3678589bf1057056891c368e93a4914b1b654aa409c1ec63f88f827ae7e70f48eb940651565129dd6cb77092f6dd4a9375e22caa3cee40bab9a32614081ea9
6
+ metadata.gz: 69e46e9ad09c37baeae504759740d7d04d05932928ed86b5a32fcb73d821f5458578bc99f3f5e46fdd5b888b75f29c221c05cf37c37790ab843d72a7d812331f
7
+ data.tar.gz: 8d74c66c5f140c627e97c85d3a47f017f383b45bbefe6171de2b44ef3857a352d4cb4df997abc39227d5e14e12f33e564f1c0dc5d5f44644b69fe2240922e523
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacAsciidoctorBase0
7
+ module Instances
8
+ class Build
9
+ class Document
10
+ class BreadcrumbsMacroValue
11
+ enable_method_class
12
+ common_constructor :document
13
+
14
+ NODE_SEPARATOR = ' » '
15
+ ROOT_DOCUMENT_TITLE = 'Home'
16
+
17
+ # @return [Array<String>]
18
+ def result
19
+ trail_nodes.join(NODE_SEPARATOR)
20
+ end
21
+
22
+ def trail_nodes
23
+ r = []
24
+ current = document
25
+ while current.present?
26
+ r.unshift(Node.new(document, current))
27
+ current = current.parent_document
28
+ end
29
+ r
30
+ end
31
+
32
+ class Node
33
+ common_constructor :current, :document
34
+
35
+ # @return [String]
36
+ def address
37
+ current.href_to_other_body(document)
38
+ end
39
+
40
+ # @return [String]
41
+ def title
42
+ if document.parent_document.present?
43
+ document.source_document.title
44
+ else
45
+ ROOT_DOCUMENT_TITLE
46
+ end
47
+ end
48
+
49
+ # @return [String]
50
+ def to_s
51
+ "link:#{address}[#{title}]"
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -23,9 +23,7 @@ module Avm
23
23
 
24
24
  # @return [Pathname]
25
25
  def address
26
- child.body_target_path.relative_path_from(
27
- document.body_target_path.dirname
28
- )
26
+ document.href_to_other_body(child)
29
27
  end
30
28
 
31
29
  # @return [String]
@@ -43,9 +43,15 @@ module Avm
43
43
  "#{author_name} <#{author_email}>"
44
44
  end
45
45
 
46
+ # @return [String]
47
+ def breadcrumbs_lines
48
+ ['[.normal]', document.breadcrumbs_macro_value]
49
+ end
50
+
46
51
  # @return [Array<String>]
47
52
  def result
48
- [stylesheet_line, title_line, author_line] + attributes_lines
53
+ [stylesheet_line, title_line, author_line] + attributes_lines + [''] +
54
+ breadcrumbs_lines
49
55
  end
50
56
 
51
57
  # @return [String]
@@ -16,6 +16,12 @@ module Avm
16
16
  enable_speaker
17
17
  common_constructor :build, :parent_document, :source_document
18
18
 
19
+ # @param other [Avm::EacAsciidoctorBase0::Instances::Build::Document]
20
+ # @return [String]
21
+ def href_to_other_body(other)
22
+ other.body_target_path.relative_path_from(body_target_path.dirname)
23
+ end
24
+
19
25
  # Absolute path to the output of Asciidoctor's source file.
20
26
  #
21
27
  # @return [Pathname]
@@ -32,6 +38,19 @@ module Avm
32
38
  )
33
39
  end
34
40
 
41
+ # @param basename [String]
42
+ # @return [Avm::EacAsciidoctorBase0::Instances::Build::Document, nil]
43
+ def child(basename)
44
+ basename = basename.to_s
45
+ children.find { |c| c.source_document.root_path.basename.to_path == basename }
46
+ end
47
+
48
+ # @param basename [String]
49
+ # @return [Avm::EacAsciidoctorBase0::Instances::Build::Document]
50
+ def child!(basename)
51
+ child(basename) || raise("Child not found with basename \"#{basename}\"")
52
+ end
53
+
35
54
  # @return [Pathname]
36
55
  def convert_base_dir
37
56
  source_document.root_path
@@ -56,7 +75,7 @@ module Avm
56
75
  def pre_processed_body_source_content
57
76
  (
58
77
  header_lines + [''] + source_document.body_path.read.each_line
59
- .flat_map { |line| pre_process_line(line.rstrip) }
78
+ .flat_map { |line| pre_process_line(line.rstrip) }
60
79
  ).map { |line| "#{line.rstrip}\n" }.join
61
80
  end
62
81
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacAsciidoctorBase0
5
- VERSION = '0.17.0'
5
+ VERSION = '0.18.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-eac_asciidoctor_base0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-05 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -135,6 +135,7 @@ files:
135
135
  - lib/avm/eac_asciidoctor_base0/instances/base.rb
136
136
  - lib/avm/eac_asciidoctor_base0/instances/build.rb
137
137
  - lib/avm/eac_asciidoctor_base0/instances/build/document.rb
138
+ - lib/avm/eac_asciidoctor_base0/instances/build/document/breadcrumbs_macro_value.rb
138
139
  - lib/avm/eac_asciidoctor_base0/instances/build/document/child_docs_macro_value.rb
139
140
  - lib/avm/eac_asciidoctor_base0/instances/build/document/header_lines.rb
140
141
  - lib/avm/eac_asciidoctor_base0/instances/build/document/media.rb