avm-eac_asciidoctor_base0 0.7.1 → 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: 4d8759187450e42df520d84444f57864d4b8e9e19ec496ce16c4e2d2de3b5667
4
- data.tar.gz: 93844e57282d8ced4e3f69ec22e58859bc752ce2d9b7504978f202fe2c31b0bc
3
+ metadata.gz: 96b69b3f900af61453fcb4945f09b28b62df452d094c2b69ca19cc48ed3cff17
4
+ data.tar.gz: 92934bd6d39e951f350f9bf26b9b9da26b19be9ca46ed9e0c5aabda550f2e475
5
5
  SHA512:
6
- metadata.gz: ece6c0315a4ef292d70b82066822f6f904c9b009e8271ae7938c80a78f1c65789d06e5b68fae834901050b50b14e1bece6d707d1156eabe7ce36a02b230a3e9e
7
- data.tar.gz: c4381369a29ff19f1a6e4e39a3992964d2ff39130391edde749d49efaf3ee34ccb64e69771aac66c3906fa2604e579d904b317bbdd3fac4ced3fecf9020a3521
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
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/source_generators/base'
4
+ require 'eac_templates/core_ext'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module EacAsciidoctorBase0
9
+ module SourceGenerators
10
+ class Base < ::Avm::SourceGenerators::Base
11
+ OPTIONS = {}.freeze
12
+
13
+ enable_speaker
14
+ enable_simple_cache
15
+
16
+ class << self
17
+ def option_list
18
+ OPTIONS.inject(super) { |a, e| a.option(*e) }
19
+ end
20
+ end
21
+
22
+ def perform
23
+ template.apply(self, target_path)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacAsciidoctorBase0
7
+ module SourceGenerators
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -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.7.1'
5
+ VERSION = '0.9.0'
6
6
  end
7
7
  end
@@ -0,0 +1,9 @@
1
+ = EacAsciidoctorBase0 Generated Source =
2
+
3
+ == First Section
4
+
5
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sapien.
6
+
7
+ == Second Section
8
+
9
+ Nam faucibus quis dui at laoreet. Pellentesque ut sapien est.
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.7.1
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-09-25 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
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '2.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 2.0.17
22
+ version: 2.0.18
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,35 +29,47 @@ dependencies:
29
29
  version: '2.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.17
32
+ version: 2.0.18
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: avm-eac_webapp_base0
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.9'
39
+ version: '0.12'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.12.2
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
- version: '0.9'
49
+ version: '0.12'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.12.2
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: eac_ruby_utils
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
57
  - - "~>"
52
58
  - !ruby/object:Gem::Version
53
- version: '0.104'
59
+ version: '0.106'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.106.1
54
63
  type: :runtime
55
64
  prerelease: false
56
65
  version_requirements: !ruby/object:Gem::Requirement
57
66
  requirements:
58
67
  - - "~>"
59
68
  - !ruby/object:Gem::Version
60
- version: '0.104'
69
+ version: '0.106'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 0.106.1
61
73
  - !ruby/object:Gem::Dependency
62
74
  name: os
63
75
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +104,20 @@ dependencies:
92
104
  - - "~>"
93
105
  - !ruby/object:Gem::Version
94
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'
95
121
  - !ruby/object:Gem::Dependency
96
122
  name: eac_ruby_gem_support
97
123
  requirement: !ruby/object:Gem::Requirement
@@ -120,13 +146,16 @@ files:
120
146
  - lib/avm/eac_asciidoctor_base0/instances/deploy.rb
121
147
  - lib/avm/eac_asciidoctor_base0/runners.rb
122
148
  - lib/avm/eac_asciidoctor_base0/runners/base.rb
149
+ - lib/avm/eac_asciidoctor_base0/source_generators.rb
150
+ - lib/avm/eac_asciidoctor_base0/source_generators/base.rb
123
151
  - lib/avm/eac_asciidoctor_base0/sources.rb
124
152
  - lib/avm/eac_asciidoctor_base0/sources/base.rb
125
153
  - lib/avm/eac_asciidoctor_base0/sources/build.rb
126
- - lib/avm/eac_asciidoctor_base0/sources/build/file.rb
154
+ - lib/avm/eac_asciidoctor_base0/sources/build/document.rb
127
155
  - lib/avm/eac_asciidoctor_base0/sources/runners.rb
128
156
  - lib/avm/eac_asciidoctor_base0/sources/runners/build.rb
129
157
  - lib/avm/eac_asciidoctor_base0/version.rb
158
+ - template/avm/eac_asciidoctor_base0/source_generators/base/content/body.adoc
130
159
  homepage:
131
160
  licenses: []
132
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