avm-eac_asciidoctor_base0 0.8.0 → 0.9.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: 03c7645d927c7e1137be888719c791310f26e115d82994bbc2c38ee0b529ea8b
4
- data.tar.gz: 2e8fdf1bca41bf33e712c2376965293b7d2647be5a959e0153405b2f7d0d4f91
3
+ metadata.gz: 96b69b3f900af61453fcb4945f09b28b62df452d094c2b69ca19cc48ed3cff17
4
+ data.tar.gz: 92934bd6d39e951f350f9bf26b9b9da26b19be9ca46ed9e0c5aabda550f2e475
5
5
  SHA512:
6
- metadata.gz: da87dfa63c9d973ee3c12dad407cb35b11356d0a8c6b77241d39da986f45966bc2dafe22c19fb0755892593816e41bc1d589e7e2eda377778a2ca3d1820eaa9e
7
- data.tar.gz: ae9283719f44d74b6c1aac9095a4ac7478c7879940ef60ea6fe96d6f6659655c18c7e2168603872cda89e48b0175413c653c4cfb9d8ae93b3162ab3a2fb8c013
6
+ metadata.gz: b038e101b9dce5872edb410b8955c80d6b910f1f6d19c10cd4f1e99f5068d4a00031b3231fb2b929d8faf155efdb637f608fd952f6eb95b70e1dccdcf304b555
7
+ data.tar.gz: 449b9fdee9cd6853f82325ec82bbf7bbcc46e11d5d2b38b5010aef1e4d1b513b955940ddf9c69b63fa82b72da36e717a7331dcb37c66d632211b71bf7b0a3d50
@@ -12,7 +12,7 @@ module Avm
12
12
  ::Avm::EacAsciidoctorBase0::Sources::Build.new(
13
13
  project,
14
14
  ::Avm::EacAsciidoctorBase0::Sources::Build::OPTION_TARGET_DIRECTORY => build_dir
15
- ).run
15
+ ).perform
16
16
  end
17
17
 
18
18
  private
@@ -8,9 +8,6 @@ module Avm
8
8
  module EacAsciidoctorBase0
9
9
  module SourceGenerators
10
10
  class Base < ::Avm::SourceGenerators::Base
11
- IDENT = ' '
12
- JOBS = %w[main_document].freeze
13
- TEMPLATE_VARIABLES = %w[lib_path name root_module].freeze
14
11
  OPTIONS = {}.freeze
15
12
 
16
13
  enable_speaker
@@ -8,7 +8,13 @@ module Avm
8
8
  module EacAsciidoctorBase0
9
9
  module Sources
10
10
  class Base < ::Avm::EacWebappBase0::Sources::Base
11
- MAIN_FILE_SUBPATH = ::Pathname.new('index.adoc')
11
+ CONTENT_DIRECTORY_SUBPATH = ::Pathname.new('content')
12
+ CONTENT_DOCUMENT_BASENAME = ::Pathname.new('body.adoc')
13
+ MAIN_FILE_SUBPATH = CONTENT_DIRECTORY_SUBPATH.join(CONTENT_DOCUMENT_BASENAME)
14
+
15
+ def content_directory
16
+ path.join(CONTENT_DIRECTORY_SUBPATH)
17
+ end
12
18
 
13
19
  def valid?
14
20
  path.join(MAIN_FILE_SUBPATH).file?
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+
5
+ module Avm
6
+ module EacAsciidoctorBase0
7
+ module Sources
8
+ class Build
9
+ class Document
10
+ ROOT_BODY_TARGET_BASENAME = 'index'
11
+
12
+ enable_simple_cache
13
+ enable_speaker
14
+ common_constructor :build, :parent_document, :basename
15
+
16
+ # Absolute path to the Asciidoctor file.
17
+ #
18
+ # @return [Pathname]
19
+ def body_source_path
20
+ root_source_path.join(
21
+ ::Avm::EacAsciidoctorBase0::Sources::Base::CONTENT_DOCUMENT_BASENAME
22
+ )
23
+ end
24
+
25
+ # Absolute path to the output of Asciidoctor's source file.
26
+ #
27
+ # @return [Pathname]
28
+ def body_target_path
29
+ build.target_directory.join(
30
+ parent_document.present? ? subpath : ROOT_BODY_TARGET_BASENAME
31
+ ).basename_sub('.*') { |b| "#{b}.html" }
32
+ end
33
+
34
+ def mydebug
35
+ root_source_path.print_debug(title: 'Document')
36
+ children.count.print_debug(label: 'children.count')
37
+ body_source_path.print_debug(label: 'body_source')
38
+ body_source_path.file?.print_debug(label: 'body_source.file?')
39
+ body_target_path.print_debug(label: 'body_target')
40
+ end
41
+
42
+ def perform
43
+ perform_self
44
+ perform_children
45
+ end
46
+
47
+ def perform_self
48
+ infov 'Building', root_source_path
49
+ ::Asciidoctor.convert_file(
50
+ body_source_path.to_path,
51
+ to_file: body_target_path.to_path, safe: :unsafe, mkdirs: true
52
+ )
53
+ end
54
+
55
+ def perform_children
56
+ children.each(&:perform)
57
+ end
58
+
59
+ def tree_documents_count
60
+ children.inject(1) { |a, e| a + e.tree_documents_count }
61
+ end
62
+
63
+ # Absolute path to the document's source root.
64
+ #
65
+ # @return [Pathname]
66
+ def root_source_path
67
+ build.source.content_directory.join(subpath)
68
+ end
69
+
70
+ def subpath
71
+ parent_document.if_present('.'.to_pathname) { |pd| pd.subpath.join(basename) }
72
+ end
73
+
74
+ private
75
+
76
+ def children_uncached
77
+ root_source_path.children.select(&:directory?)
78
+ .map { |path| self.class.new(build, self, path.basename) }
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -12,20 +12,24 @@ module Avm
12
12
  enable_simple_cache
13
13
  enable_listable
14
14
  lists.add_symbol :option, :target_directory
15
- common_constructor :project, :options, default: [{}] do
15
+ common_constructor :source, :options, default: [{}] do
16
16
  self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
17
17
  end
18
18
 
19
19
  SOURCE_EXTNAMES = %w[.adoc .asc].freeze
20
20
 
21
- def run
22
- infov 'Files to build', source_files.count
21
+ def perform
22
+ infov 'Files to build', root_document.tree_documents_count
23
23
  target_directory.clear
24
- source_files.each(&:run)
24
+ root_document.perform
25
25
  end
26
26
 
27
27
  def default_target_directory
28
- project.path.join('build')
28
+ source.path.join('build')
29
+ end
30
+
31
+ def root_document
32
+ ::Avm::EacAsciidoctorBase0::Sources::Build::Document.new(self, nil, nil)
29
33
  end
30
34
 
31
35
  def target_directory
@@ -33,16 +37,6 @@ module Avm
33
37
  options[OPTION_TARGET_DIRECTORY] || default_target_directory
34
38
  )
35
39
  end
36
-
37
- def source_files_uncached
38
- r = []
39
- project.path.children.each do |child|
40
- next unless SOURCE_EXTNAMES.include?(child.extname)
41
-
42
- r << ::Avm::EacAsciidoctorBase0::Sources::Build::File.new(self, child.basename)
43
- end
44
- r
45
- end
46
40
  end
47
41
  end
48
42
  end
@@ -17,7 +17,7 @@ module Avm
17
17
 
18
18
  def run
19
19
  start_banner
20
- build.run
20
+ build.perform
21
21
  open
22
22
  end
23
23
 
@@ -40,7 +40,7 @@ module Avm
40
40
  end
41
41
 
42
42
  def open_path
43
- build.source_files.first.target_path
43
+ build.root_document.body_target_path
44
44
  end
45
45
 
46
46
  def start_banner
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacAsciidoctorBase0
5
- VERSION = '0.8.0'
5
+ VERSION = '0.9.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.8.0
4
+ version: 0.9.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: 2022-10-29 00:00:00.000000000 Z
11
+ date: 2022-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '0.12'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.12.1
42
+ version: 0.12.2
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '0.12'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.12.1
52
+ version: 0.12.2
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: eac_ruby_utils
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +104,20 @@ dependencies:
104
104
  - - "~>"
105
105
  - !ruby/object:Gem::Version
106
106
  version: '3.30'
107
+ - !ruby/object:Gem::Dependency
108
+ name: eac_fs
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '0.14'
114
+ type: :development
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '0.14'
107
121
  - !ruby/object:Gem::Dependency
108
122
  name: eac_ruby_gem_support
109
123
  requirement: !ruby/object:Gem::Requirement
@@ -137,11 +151,11 @@ files:
137
151
  - lib/avm/eac_asciidoctor_base0/sources.rb
138
152
  - lib/avm/eac_asciidoctor_base0/sources/base.rb
139
153
  - lib/avm/eac_asciidoctor_base0/sources/build.rb
140
- - lib/avm/eac_asciidoctor_base0/sources/build/file.rb
154
+ - lib/avm/eac_asciidoctor_base0/sources/build/document.rb
141
155
  - lib/avm/eac_asciidoctor_base0/sources/runners.rb
142
156
  - lib/avm/eac_asciidoctor_base0/sources/runners/build.rb
143
157
  - lib/avm/eac_asciidoctor_base0/version.rb
144
- - template/avm/eac_asciidoctor_base0/source_generators/base/index.adoc
158
+ - template/avm/eac_asciidoctor_base0/source_generators/base/content/body.adoc
145
159
  homepage:
146
160
  licenses: []
147
161
  metadata: {}
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'asciidoctor'
4
-
5
- module Avm
6
- module EacAsciidoctorBase0
7
- module Sources
8
- class Build
9
- class File
10
- enable_speaker
11
- common_constructor :build, :subpath
12
-
13
- def run
14
- infov 'Building', subpath
15
- ::Asciidoctor.convert_file source_path.to_path,
16
- to_file: target_path.to_path, safe: :unsafe, mkdirs: true
17
- end
18
-
19
- def source_path
20
- build.project.path.join(subpath)
21
- end
22
-
23
- def target_path
24
- build.target_directory.join(subpath).basename_sub('.*') { |b| "#{b}.html" }
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end