eac_tools 0.59.0 → 0.60.0

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: 2cb19ed074ebe2b0a6b8d0695d83159c38744eccc80c3e361d3d6b2a60c99874
4
- data.tar.gz: fe65562b50eea39849b5a7001ce3804ac19e0df8c6fcaec8678732719130fc8d
3
+ metadata.gz: 327ae2eff08c0ad4c133241be2a63b4c7a0867317996c75f96254289510efc92
4
+ data.tar.gz: 7f683ac460509520c772af752277317ffbd6adfbc099757ad0f88cd104a85517
5
5
  SHA512:
6
- metadata.gz: 7ae8c3ac14a3bff264e300b79e19742c7254274dffbb8aa17cb4119b22b460cff527e5e971d499e6bd0adfad853fdc89c7ff418ba8af7360ca5ac1997166c401
7
- data.tar.gz: 5d593fc1603967b5d2ad2231dad540cdd81db1c1f4f861fd12259afc0e60cfdd93f67f5248b7eef76013dc2fd57fa50dcf5628478641ff162d10da5d45f0960f
6
+ metadata.gz: '08edc8c921395b4593f0ae47b0c36d1f67c1847d752d8e17fb258f82fa637854652e85b77ee69fd0a0664ca9f633d0ba2f3812bd188b750c1b55ddaeac60f732'
7
+ data.tar.gz: d6753df13da2becc01dccf9a71896f2aba4506e236f05b2c8026e8c0dc30a59f472da6dd4453a4b3506cdd778b76f1437e1cc3ac48f873622514b4613a6e0347
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.59.0)
4
+ eac_tools (0.60.0)
5
5
  avm (~> 0.66, >= 0.66.1)
6
- avm-eac_asciidoctor_base0 (~> 0.17)
6
+ avm-eac_asciidoctor_base0 (~> 0.18)
7
7
  avm-eac_generic_base0 (~> 0.12)
8
8
  avm-eac_latex_base0 (~> 0.3)
9
9
  avm-eac_php_base0 (~> 0.4, >= 0.4.1)
@@ -37,7 +37,7 @@ PATH
37
37
  PATH
38
38
  remote: sub/avm-eac_asciidoctor_base0
39
39
  specs:
40
- avm-eac_asciidoctor_base0 (0.17.0)
40
+ avm-eac_asciidoctor_base0 (0.18.0)
41
41
  asciidoctor (~> 2.0, >= 2.0.18)
42
42
  avm-eac_webapp_base0 (~> 0.14)
43
43
  eac_ruby_utils (~> 0.112)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.59.0'
4
+ VERSION = '0.60.0'
5
5
  end
@@ -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
@@ -1,32 +1,72 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/eac_asciidoctor_base0/sources/base'
4
3
  require 'avm/eac_asciidoctor_base0/instances/build'
5
4
 
6
- ::RSpec.describe ::Avm::EacAsciidoctorBase0::Instances::Build::Document do
7
- let(:application) { ::Avm::Applications::Base.new('myapp') }
8
- let(:application_instance) do
9
- ::Avm::EacAsciidoctorBase0::Instances::Base
10
- .new(application, 'stub')
11
- end
12
- let(:build) { ::Avm::EacAsciidoctorBase0::Instances::Build.new(application_instance) }
5
+ ::RSpec.describe ::Avm::EacAsciidoctorBase0::Instances::Build::Document do # rubocop:disable Metrics/BlockLength
6
+ let(:app_director) { eac_asciidoctor_base0_stubs }
7
+ let(:build) { ::Avm::EacAsciidoctorBase0::Instances::Build.new(app_director.instance) }
13
8
  let(:fixtures_dir) { __dir__.to_pathname.join('document_spec_files') }
14
- let(:instance) { build.root_document }
15
- let(:source) { avm_source('EacAsciidoctorBase0', target_basename: application.id) }
9
+ let(:instance) { build_doc_child(build.root_document, :c1, :c1_1, :c1_1_1) }
16
10
  let(:target_file) { fixtures_dir.join('pre_processed_root_body.adoc') }
11
+ let(:source) { app_director.source }
12
+ let(:doc_template) do
13
+ r = temp_dir
14
+ ::FileUtils.copy_entry(source.root_document.root_path, r)
15
+ r
16
+ end
17
17
 
18
18
  before do
19
- application.entry('stereotype').write('EacAsciidoctorBase0')
20
- ::EacConfig::Node.context.current.entry("#{application.id}_dev.install.path")
21
- .value = source.path.to_path
22
- application_instance.entry('install.path').write(source.path.to_path)
23
- application_instance.entry('install.name').write('The Author')
24
- application_instance.entry('install.name_initials').write('T.A.')
25
- application_instance.entry('install.email').write('theauthor@example.net')
26
- application_instance.entry('web.url').write('https://www.example.net')
19
+ copy_template_hash(
20
+ source.root_document,
21
+ c1: {
22
+ c1_1: {
23
+ c1_1_1: {
24
+ c1_1_1_1: {},
25
+ c1_1_1_2: {}
26
+ },
27
+ c1_1_2: {
28
+ c1_1_2_1: {},
29
+ c1_1_2_2: {}
30
+ }
31
+ }
32
+ },
33
+ c2: {
34
+ c2_1: {}
35
+ }
36
+ )
27
37
  end
28
38
 
29
39
  it do
30
40
  expect(instance.pre_processed_body_source_content).to eq(target_file.read)
31
41
  end
42
+
43
+ # @return [Avm::EacAsciidoctorBase0::Sources::Base::Document]
44
+ def copy_template_doc(parent, basename)
45
+ parent.assert_argument(::Avm::EacAsciidoctorBase0::Sources::Base::Document, 'parent')
46
+
47
+ root_target = parent.root_path.join(basename.to_s)
48
+ ::FileUtils.copy_entry(doc_template, root_target)
49
+ root_target.join('title').write(root_target.basename.to_path)
50
+ ::Avm::EacAsciidoctorBase0::Sources::Base::Document.new(parent.source, parent,
51
+ root_target.basename)
52
+ end
53
+
54
+ # @return [Array<Avm::EacAsciidoctorBase0::Sources::Base::Document>]
55
+ def copy_template_hash(parent, hash)
56
+ parent.assert_argument(::Avm::EacAsciidoctorBase0::Sources::Base::Document, 'parent')
57
+ hash.assert_argument(::Hash, 'hash')
58
+
59
+ hash.map do |k, v|
60
+ r = copy_template_doc(parent, k)
61
+ copy_template_hash(r, v)
62
+ r
63
+ end
64
+ end
65
+
66
+ # @return [Avm::EacAsciidoctorBase0::Instances::Build::Document]
67
+ def build_doc_child(build_doc, *path)
68
+ basename = path.shift.to_s
69
+ r = build_doc.child!(basename)
70
+ path.any? ? build_doc_child(r, *path) : r
71
+ end
32
72
  end
@@ -1,5 +1,5 @@
1
- :stylesheet: ../theme/main.css
2
- = EacAsciidoctorBase0 Generated Source
1
+ :stylesheet: ../../../../theme/main.css
2
+ = c1_1_1
3
3
  The Author <theauthor@example.net>
4
4
  :Author Initials: T.A.
5
5
  :toc: left
@@ -7,8 +7,13 @@ The Author <theauthor@example.net>
7
7
  :numbered:
8
8
  :website: https://www.example.net
9
9
 
10
+ [.normal]
11
+ link:../../../index.html[Home] » link:../../index.html[c1] » link:../index.html[c1_1] » link:index.html[c1_1_1]
12
+
10
13
  == Child Documents
11
14
 
15
+ * link:c1_1_1_1/index.html[c1_1_1_1]
16
+ * link:c1_1_1_2/index.html[c1_1_1_2]
12
17
 
13
18
  == First Section
14
19
 
@@ -1,32 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/eac_asciidoctor_base0/sources/base'
4
3
  require 'avm/eac_asciidoctor_base0/instances/build'
5
4
  require 'eac_fs/comparator'
6
5
 
7
- ::RSpec.describe ::Avm::EacAsciidoctorBase0::Instances::Build do # rubocop:disable Metrics/BlockLength
8
- let(:application) { ::Avm::Applications::Base.new('myapp') }
9
- let(:application_instance) do
10
- ::Avm::EacAsciidoctorBase0::Instances::Base
11
- .new(application, 'stub')
12
- end
6
+ ::RSpec.describe ::Avm::EacAsciidoctorBase0::Instances::Build do
7
+ let(:app_director) { eac_asciidoctor_base0_stubs }
13
8
  let(:fs_comparator) { ::EacFs::Comparator.new.truncate_file('*.html') }
14
- let(:instance) { described_class.new(application_instance) }
15
- let(:source) { avm_source('EacAsciidoctorBase0', target_basename: application.id) }
16
-
17
- before do
18
- application.entry('stereotype').write('EacAsciidoctorBase0')
19
- ::EacConfig::Node.context.current.entry("#{application.id}_dev.install.path")
20
- .value = source.path.to_path
21
- application_instance.entry('install.name').write('The Author')
22
- application_instance.entry('install.name_initials').write('T.A.')
23
- application_instance.entry('install.email').write('theauthor@example.net')
24
- application_instance.entry('web.url').write('https://www.example.net')
25
- end
9
+ let(:instance) { described_class.new(app_director.instance) }
26
10
 
27
11
  include_examples 'source_target_fixtures', __FILE__ do
28
12
  def source_data(source_file)
29
- ::FileUtils.copy_entry(source_file, source.path)
13
+ ::FileUtils.copy_entry(source_file, app_director.source.path)
30
14
  instance.perform
31
15
  fs_comparator.build(instance.target_directory)
32
16
  end
@@ -7,12 +7,7 @@ require 'avm/eac_asciidoctor_base0/sources/base'
7
7
  include_examples 'in_avm_registry', 'sources'
8
8
 
9
9
  describe '#instance' do
10
- let(:application) { ::Avm::Applications::Base.new('myapp') }
11
- let(:source) { avm_source('EacAsciidoctorBase0', target_basename: application.id) }
12
-
13
- before do
14
- application.local_source_path_entry.value = source.path
15
- end
10
+ let(:source) { eac_asciidoctor_base0_stubs.source }
16
11
 
17
12
  it do
18
13
  expect(source.instance).to be_a(::Avm::EacAsciidoctorBase0::Instances::Base)
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/node'
4
+ require 'avm/applications/base'
5
+ require 'avm/instances/base'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module EacAsciidoctorBase0Stubs
9
+ class Director
10
+ DEFAULT_APPLICATION_ID = 'myapp'
11
+ INSTANCE_ENTRY_KEYS = {
12
+ 'install.name' => 'The Author',
13
+ 'install.name_initials' => 'T.A.',
14
+ 'install.email' => 'theauthor@example.net',
15
+ 'web.url' => 'https://www.example.net'
16
+ }.freeze
17
+
18
+ enable_simple_cache
19
+ common_constructor :rspec_example, :application_id, default: [DEFAULT_APPLICATION_ID] do
20
+ source
21
+ application
22
+ instance
23
+ end
24
+
25
+ private
26
+
27
+ # @return [Avm::Applications::Base]
28
+ def application_uncached
29
+ r = ::Avm::Applications::Base.new(application_id)
30
+ r.entry('stereotype').write('EacAsciidoctorBase0')
31
+ r.local_source_path_entry.value = source.path.to_path
32
+ r
33
+ end
34
+
35
+ # @return [Avm::EacAsciidoctorBase0::Instances::Base]
36
+ def instance_uncached
37
+ r = ::Avm::EacAsciidoctorBase0::Instances::Base.new(application, 'stub')
38
+ INSTANCE_ENTRY_KEYS.each { |k, v| r.entry(k).write(v) }
39
+ r
40
+ end
41
+
42
+ # @return [Avm::EacAsciidoctorBase0::Sources::Base]
43
+ def source_uncached
44
+ rspec_example.avm_source('EacAsciidoctorBase0', target_basename: application_id)
45
+ end
46
+ end
47
+
48
+ def eac_asciidoctor_base0_stubs(id = nil)
49
+ args = [self]
50
+ args << id if id.present?
51
+ ::EacAsciidoctorBase0Stubs::Director.new(*args)
52
+ end
53
+ end
54
+
55
+ ::EacRubyUtils::Rspec.default_setup.rspec_config.include(::EacAsciidoctorBase0Stubs)
@@ -3,3 +3,6 @@
3
3
  require 'eac_ruby_utils/rspec/default_setup'
4
4
  ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
5
5
  .stub_avm_contexts
6
+
7
+ require 'eac_ruby_utils/require_sub'
8
+ ::EacRubyUtils.require_sub __FILE__
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.59.0
4
+ version: 0.60.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: avm
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.17'
39
+ version: '0.18'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.17'
46
+ version: '0.18'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: avm-eac_generic_base0
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -375,6 +375,7 @@ files:
375
375
  - sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/base.rb
376
376
  - sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build.rb
377
377
  - sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document.rb
378
+ - sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/breadcrumbs_macro_value.rb
378
379
  - sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/child_docs_macro_value.rb
379
380
  - sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_lines.rb
380
381
  - sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/media.rb
@@ -419,6 +420,7 @@ files:
419
420
  - sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/sources/base_spec.rb
420
421
  - sub/avm-eac_asciidoctor_base0/spec/rubocop_spec.rb
421
422
  - sub/avm-eac_asciidoctor_base0/spec/spec_helper.rb
423
+ - sub/avm-eac_asciidoctor_base0/spec/spec_helper/eac_asciidoctor_base0_stubs.rb
422
424
  - sub/avm-eac_asciidoctor_base0/template/avm/eac_asciidoctor_base0/source_generators/base/content/body.adoc
423
425
  - sub/avm-eac_asciidoctor_base0/template/avm/eac_asciidoctor_base0/source_generators/base/content/title
424
426
  - sub/avm-eac_asciidoctor_base0/template/avm/eac_asciidoctor_base0/source_generators/base/theme/main.css