avm-eac_asciidoctor_base0 0.20.0 → 0.21.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: f9351964d576043145fbecd87f7ec3e8284af521b5b1c8c59e0789cb4a26565a
4
- data.tar.gz: 01bb632ed8c02e474d8fecf05e420a29cf2850c6a3c449a2c23d675bdb3a71b1
3
+ metadata.gz: eb16b5036a3115476326afa24a89bc40da17326fa76ea99f1d7df0bb021b53db
4
+ data.tar.gz: 4fc856b7b229420888cc496f798f0dac76681a339a9feaa319eab6759bf38be4
5
5
  SHA512:
6
- metadata.gz: 7f71b5da7a78cb72738d08748f7a15eac3bda6998d9b2ed8bb6248a28cbaeda8b862bb4924f05e2a419cfa54affd0a7d76f3da773e2e18b4fd1562abd1f39f8d
7
- data.tar.gz: e1ac34e3cc668e5e1c0379f1129e7e01e8a6df58dd1f54d7ab2194f40ae43f5bef14985236c41d0dd02573b8aa050177e8b2b257d9a24ab5521d16b88205b272
6
+ metadata.gz: 90988a7ba168f8a781121a46721eb798b5bb6429b04a0e58da80c97d48ebf4e6b8b0fbdc83d67cf993899da5bb0ac1eb20904f4098751ea019f112096997cc8e
7
+ data.tar.gz: 578fc517e677e5460815d7cb03eca55ab438158060aa17508d1751d180378dabf009de46aaf3db1637d796732995ba565acdc80404e09708fbf68016957f0b70
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/recursive_builder'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module DocumentsOwner
9
+ common_concern
10
+
11
+ # @param subpath [Pathname]
12
+ # @return [Avm::EacAsciidoctorBase0::Sources::Document]
13
+ # @raise [KeyError]
14
+ def document(subpath)
15
+ documents.find { |d| d.subpath.to_pathname == subpath.to_pathname } ||
16
+ raise(::KeyError, "Document not found with subáth = \"#{subpath}\"")
17
+ end
18
+
19
+ # @return [Enumerable<Avm::EacAsciidoctorBase0::Sources::Document>]
20
+ def documents
21
+ ::EacRubyUtils::RecursiveBuilder.new(root_document, &:children).result
22
+ end
23
+
24
+ # @return [Object]
25
+ def root_document
26
+ raise "Abstract method hit: #{__method__}"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require 'avm/eac_asciidoctor_base0/instances/macros'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module EacAsciidoctorBase0
9
+ module Instances
10
+ class Build
11
+ class Document
12
+ module BodyTarget
13
+ common_concern
14
+
15
+ BODY_TARGET_BASENAME = 'index.html'
16
+
17
+ # Absolute path to the output of Asciidoctor's source file.
18
+ #
19
+ # @return [Pathname]
20
+ def body_target_path
21
+ build.target_directory.join(source_document.subpath).join(BODY_TARGET_BASENAME)
22
+ end
23
+
24
+ # @return [Asciidoctor::Document]
25
+ def body_target_write
26
+ ::Asciidoctor.convert(
27
+ pre_processed_body_source_content,
28
+ base_dir: convert_base_dir,
29
+ to_file: body_target_path.to_path, safe: :unsafe, mkdirs: true
30
+ )
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -17,7 +17,7 @@ module Avm
17
17
  def media_target_path
18
18
  build.target_directory.join(
19
19
  parent_document.present? ? source_document.subpath : '',
20
- ::Avm::EacAsciidoctorBase0::Sources::Base::Document::Media::MEDIA_DIRECTORY_BASENAME
20
+ ::Avm::EacAsciidoctorBase0::Sources::Document::Media::MEDIA_DIRECTORY_BASENAME
21
21
  )
22
22
  end
23
23
  end
@@ -11,11 +11,10 @@ module Avm
11
11
  class Document
12
12
  require_sub __FILE__, include_modules: true
13
13
 
14
- BODY_TARGET_BASENAME = 'index.html'
15
-
16
14
  enable_simple_cache
17
15
  enable_speaker
18
16
  common_constructor :build, :parent_document, :source_document
17
+ delegate :subpath, to: :source_document
19
18
 
20
19
  # @param other [Avm::EacAsciidoctorBase0::Instances::Build::Document]
21
20
  # @return [String]
@@ -32,22 +31,6 @@ module Avm
32
31
  end
33
32
  end
34
33
 
35
- # Absolute path to the output of Asciidoctor's source file.
36
- #
37
- # @return [Pathname]
38
- def body_target_path
39
- build.target_directory.join(source_document.subpath).join(BODY_TARGET_BASENAME)
40
- end
41
-
42
- # @return [Asciidoctor::Document]
43
- def build_body
44
- ::Asciidoctor.convert(
45
- pre_processed_body_source_content,
46
- base_dir: convert_base_dir,
47
- to_file: body_target_path.to_path, safe: :unsafe, mkdirs: true
48
- )
49
- end
50
-
51
34
  # @param basename [String]
52
35
  # @return [Avm::EacAsciidoctorBase0::Instances::Build::Document, nil]
53
36
  def child(basename)
@@ -85,7 +68,7 @@ module Avm
85
68
 
86
69
  def perform_self
87
70
  infov 'Building', source_document.subpath
88
- build_body
71
+ body_target_write
89
72
  copy_media_directory
90
73
  end
91
74
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/eac_asciidoctor_base0/documents_owner'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'eac_ruby_utils/fs/clearable_directory'
5
6
 
@@ -8,6 +9,7 @@ module Avm
8
9
  module Instances
9
10
  class Build
10
11
  require_sub __FILE__
12
+ include ::Avm::EacAsciidoctorBase0::DocumentsOwner
11
13
  enable_speaker
12
14
  enable_simple_cache
13
15
  enable_listable
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_webapp_base0/sources/base'
4
+ require 'avm/eac_asciidoctor_base0/documents_owner'
5
+ require 'avm/eac_asciidoctor_base0/instances/build'
6
+ require 'avm/eac_asciidoctor_base0/sources/document'
4
7
  require 'avm/eac_asciidoctor_base0/sources/runners'
5
8
  require 'eac_ruby_utils/core_ext'
6
9
 
@@ -9,13 +12,20 @@ module Avm
9
12
  module Sources
10
13
  class Base < ::Avm::EacWebappBase0::Sources::Base
11
14
  require_sub __FILE__, include_modules: true
15
+ include ::Avm::EacAsciidoctorBase0::DocumentsOwner
12
16
 
13
17
  CONTENT_DIRECTORY_SUBPATH = ::Pathname.new('content')
14
18
  CONTENT_DOCUMENT_BASENAME = ::Pathname.new('body.adoc')
15
19
  MAIN_FILE_SUBPATH = CONTENT_DIRECTORY_SUBPATH.join(
16
- ::Avm::EacAsciidoctorBase0::Sources::Base::Document::TITLE_BASENAME
20
+ ::Avm::EacAsciidoctorBase0::Sources::Document::TITLE_BASENAME
17
21
  )
18
22
 
23
+ # @param options [Hash]
24
+ # @return [Avm::EacAsciidoctorBase0::Instances::Build]
25
+ def build(options = {})
26
+ ::Avm::EacAsciidoctorBase0::Instances::Build.new(instance_to_build, options)
27
+ end
28
+
19
29
  def content_directory
20
30
  path.join(CONTENT_DIRECTORY_SUBPATH)
21
31
  end
@@ -25,9 +35,9 @@ module Avm
25
35
  ::Avm::EacAsciidoctorBase0::Sources::Base::InstanceToBuild.new(self)
26
36
  end
27
37
 
28
- # @return [Avm::EacAsciidoctorBase0::Sources::Base::Document
38
+ # @return [Avm::EacAsciidoctorBase0::Sources::Document
29
39
  def root_document
30
- ::Avm::EacAsciidoctorBase0::Sources::Base::Document.new(self, nil, nil)
40
+ ::Avm::EacAsciidoctorBase0::Sources::Document.new(self, nil, nil)
31
41
  end
32
42
 
33
43
  def valid?
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module Sources
9
+ class Document
10
+ module Media
11
+ MEDIA_DIRECTORY_BASENAME = '_media'
12
+
13
+ def copy_media_directory_to(target_directory_path)
14
+ return unless media_directory.directory?
15
+
16
+ target_directory_path.parent.mkpath
17
+ ::FileUtils.copy_entry(media_directory, target_directory_path)
18
+ end
19
+
20
+ # @return [Pathname]
21
+ def media_directory
22
+ root_path.join(MEDIA_DIRECTORY_BASENAME)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module Sources
9
+ class Document
10
+ module Title
11
+ TITLE_BASENAME = 'title'
12
+
13
+ # @return [String]
14
+ def title
15
+ title_path.read.strip
16
+ end
17
+
18
+ # @return [Pathname]
19
+ def title_path
20
+ root_path.join(TITLE_BASENAME)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module Sources
9
+ class Document
10
+ enable_simple_cache
11
+ enable_speaker
12
+ require_sub __FILE__, include_modules: true
13
+ common_constructor :source, :parent_document, :basename
14
+
15
+ # Absolute path to the Asciidoctor file.
16
+ #
17
+ # @return [Pathname]
18
+ def body_path
19
+ root_path.join(
20
+ ::Avm::EacAsciidoctorBase0::Sources::Base::CONTENT_DOCUMENT_BASENAME
21
+ )
22
+ end
23
+
24
+ # @return [Avm::EacAsciidoctorBase0::Instances::Build::Document]
25
+ def build_document
26
+ source.build.document(subpath)
27
+ end
28
+
29
+ # Absolute path to the document's source root.
30
+ #
31
+ # @return [Pathname]
32
+ def root_path
33
+ source.content_directory.join(subpath)
34
+ end
35
+
36
+ # @return [Pathname]
37
+ def subpath
38
+ parent_document.if_present('.'.to_pathname) { |pd| pd.subpath.join(basename) }
39
+ end
40
+
41
+ # @return [String]
42
+ def to_s
43
+ subpath.to_path
44
+ end
45
+
46
+ private
47
+
48
+ def children_uncached
49
+ root_path.children.select(&:directory?)
50
+ .reject { |path| path.basename.to_path == MEDIA_DIRECTORY_BASENAME }
51
+ .map { |path| self.class.new(source, self, path.basename) }
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -23,11 +23,9 @@ module Avm
23
23
 
24
24
  private
25
25
 
26
+ # @return [Avm::EacAsciidoctorBase0::Instances::Build]
26
27
  def build_uncached
27
- ::Avm::EacAsciidoctorBase0::Instances::Build.new(
28
- runner_context.call(:source).instance_to_build,
29
- target_directory: parsed.target_dir
30
- )
28
+ source.build(target_directory: parsed.target_dir)
31
29
  end
32
30
 
33
31
  def default_target_directory
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'os'
4
+ require 'eac_cli/core_ext'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module Sources
9
+ module Runners
10
+ class Document
11
+ class Build
12
+ runner_with :help do
13
+ bool_opt '-O', '--open'
14
+ end
15
+
16
+ def run
17
+ %w[build open ending].each { |p| send("run_#{p}") }
18
+ end
19
+
20
+ private
21
+
22
+ def build_document_uncached
23
+ document.build_document
24
+ end
25
+
26
+ def run_build
27
+ build_document.perform_self
28
+ end
29
+
30
+ def run_ending
31
+ success 'Done'
32
+ end
33
+
34
+ def run_open
35
+ return unless parsed.open?
36
+
37
+ infov 'Opening', build_document.body_target_path
38
+ ::EacRubyUtils::Envs.local.command(OS.open_file_command,
39
+ build_document.body_target_path).system!
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+
5
+ module Avm
6
+ module EacAsciidoctorBase0
7
+ module Sources
8
+ module Runners
9
+ class Document
10
+ runner_with :help, :subcommands do
11
+ pos_arg :subpath
12
+ subcommands
13
+ end
14
+ delegate :subpath, to: :parsed
15
+ for_context :document, :subpath
16
+
17
+ private
18
+
19
+ # @return [Avm::EacAsciidoctorBase0::Sources::Document]
20
+ # @raise [KeyError]
21
+ def document_uncached
22
+ source.document(subpath)
23
+ end
24
+
25
+ require_sub __FILE__
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+
5
+ module Avm
6
+ module EacAsciidoctorBase0
7
+ module Sources
8
+ module Runners
9
+ class Documents
10
+ runner_with :help
11
+
12
+ def run
13
+ infov 'Documents', documents.count
14
+ documents.each do |document|
15
+ infov ' * ', document
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def documents_uncached
22
+ source.documents
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacAsciidoctorBase0
5
- VERSION = '0.20.0'
5
+ VERSION = '0.21.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.20.0
4
+ version: 0.21.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-11-19 00:00:00.000000000 Z
11
+ date: 2023-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -56,20 +56,14 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0.119'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.119.2
59
+ version: '0.120'
63
60
  type: :runtime
64
61
  prerelease: false
65
62
  version_requirements: !ruby/object:Gem::Requirement
66
63
  requirements:
67
64
  - - "~>"
68
65
  - !ruby/object:Gem::Version
69
- version: '0.119'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 0.119.2
66
+ version: '0.120'
73
67
  - !ruby/object:Gem::Dependency
74
68
  name: os
75
69
  requirement: !ruby/object:Gem::Requirement
@@ -139,6 +133,7 @@ extensions: []
139
133
  extra_rdoc_files: []
140
134
  files:
141
135
  - lib/avm/eac_asciidoctor_base0.rb
136
+ - lib/avm/eac_asciidoctor_base0/documents_owner.rb
142
137
  - lib/avm/eac_asciidoctor_base0/file_formats/base.rb
143
138
  - lib/avm/eac_asciidoctor_base0/file_formats/base/file_resource_name.rb
144
139
  - lib/avm/eac_asciidoctor_base0/instances.rb
@@ -147,6 +142,7 @@ files:
147
142
  - lib/avm/eac_asciidoctor_base0/instances/base.rb
148
143
  - lib/avm/eac_asciidoctor_base0/instances/build.rb
149
144
  - lib/avm/eac_asciidoctor_base0/instances/build/document.rb
145
+ - lib/avm/eac_asciidoctor_base0/instances/build/document/body_target.rb
150
146
  - lib/avm/eac_asciidoctor_base0/instances/build/document/header_lines.rb
151
147
  - lib/avm/eac_asciidoctor_base0/instances/build/document/media.rb
152
148
  - lib/avm/eac_asciidoctor_base0/instances/build/document/pre_process_line.rb
@@ -161,13 +157,16 @@ files:
161
157
  - lib/avm/eac_asciidoctor_base0/source_generators/base.rb
162
158
  - lib/avm/eac_asciidoctor_base0/sources.rb
163
159
  - lib/avm/eac_asciidoctor_base0/sources/base.rb
164
- - lib/avm/eac_asciidoctor_base0/sources/base/document.rb
165
- - lib/avm/eac_asciidoctor_base0/sources/base/document/media.rb
166
- - lib/avm/eac_asciidoctor_base0/sources/base/document/title.rb
167
160
  - lib/avm/eac_asciidoctor_base0/sources/base/instance_to_build.rb
168
161
  - lib/avm/eac_asciidoctor_base0/sources/base/theme.rb
162
+ - lib/avm/eac_asciidoctor_base0/sources/document.rb
163
+ - lib/avm/eac_asciidoctor_base0/sources/document/media.rb
164
+ - lib/avm/eac_asciidoctor_base0/sources/document/title.rb
169
165
  - lib/avm/eac_asciidoctor_base0/sources/runners.rb
170
166
  - lib/avm/eac_asciidoctor_base0/sources/runners/build.rb
167
+ - lib/avm/eac_asciidoctor_base0/sources/runners/document.rb
168
+ - lib/avm/eac_asciidoctor_base0/sources/runners/document/build.rb
169
+ - lib/avm/eac_asciidoctor_base0/sources/runners/documents.rb
171
170
  - lib/avm/eac_asciidoctor_base0/version.rb
172
171
  - template/avm/eac_asciidoctor_base0/source_generators/base/content/body.adoc
173
172
  - template/avm/eac_asciidoctor_base0/source_generators/base/content/title
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'asciidoctor'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module Avm
7
- module EacAsciidoctorBase0
8
- module Sources
9
- class Base
10
- class Document
11
- module Media
12
- MEDIA_DIRECTORY_BASENAME = '_media'
13
-
14
- def copy_media_directory_to(target_directory_path)
15
- return unless media_directory.directory?
16
-
17
- target_directory_path.parent.mkpath
18
- ::FileUtils.copy_entry(media_directory, target_directory_path)
19
- end
20
-
21
- # @return [Pathname]
22
- def media_directory
23
- root_path.join(MEDIA_DIRECTORY_BASENAME)
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'asciidoctor'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module Avm
7
- module EacAsciidoctorBase0
8
- module Sources
9
- class Base
10
- class Document
11
- module Title
12
- TITLE_BASENAME = 'title'
13
-
14
- # @return [String]
15
- def title
16
- title_path.read.strip
17
- end
18
-
19
- # @return [Pathname]
20
- def title_path
21
- root_path.join(TITLE_BASENAME)
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'asciidoctor'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module Avm
7
- module EacAsciidoctorBase0
8
- module Sources
9
- class Base
10
- class Document
11
- enable_simple_cache
12
- enable_speaker
13
- require_sub __FILE__, include_modules: true
14
- common_constructor :source, :parent_document, :basename
15
-
16
- # Absolute path to the Asciidoctor file.
17
- #
18
- # @return [Pathname]
19
- def body_path
20
- root_path.join(
21
- ::Avm::EacAsciidoctorBase0::Sources::Base::CONTENT_DOCUMENT_BASENAME
22
- )
23
- end
24
-
25
- # Absolute path to the document's source root.
26
- #
27
- # @return [Pathname]
28
- def root_path
29
- source.content_directory.join(subpath)
30
- end
31
-
32
- # @return [Pathname]
33
- def subpath
34
- parent_document.if_present('.'.to_pathname) { |pd| pd.subpath.join(basename) }
35
- end
36
-
37
- private
38
-
39
- def children_uncached
40
- root_path.children.select(&:directory?)
41
- .reject { |path| path.basename.to_path == MEDIA_DIRECTORY_BASENAME }
42
- .map { |path| self.class.new(source, self, path.basename) }
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end