eac_tools 0.41.0 → 0.43.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +23 -23
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +4 -4
  5. data/sub/avm/lib/avm/applications/base.rb +24 -3
  6. data/sub/avm/lib/avm/entries/entry.rb +5 -0
  7. data/sub/avm/lib/avm/instances/base.rb +5 -12
  8. data/sub/avm/lib/avm/instances/ids.rb +30 -0
  9. data/sub/avm/lib/avm/rspec/setup.rb +8 -0
  10. data/sub/avm/lib/avm/sources/base/instance.rb +2 -14
  11. data/sub/avm/lib/avm/version.rb +1 -1
  12. data/sub/avm/spec/spec_helper.rb +1 -1
  13. data/sub/avm-eac_asciidoctor_base0/avm-eac_asciidoctor_base0.gemspec +1 -1
  14. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/base.rb +18 -0
  15. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb +78 -0
  16. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/pre_process_line.rb +50 -0
  17. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document.rb +71 -0
  18. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/{sources → instances}/build.rb +10 -3
  19. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/deploy.rb +4 -4
  20. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base/document/title.rb +28 -0
  21. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base/document.rb +47 -0
  22. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base/theme.rb +40 -0
  23. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base.rb +7 -0
  24. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runners/build.rb +5 -3
  25. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
  26. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec.rb +32 -0
  27. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec_files/pre_processed_root_body.adoc +16 -0
  28. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build_spec.rb +48 -0
  29. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/{sources → instances}/build_spec_files/doc1.html +0 -0
  30. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/{sources → instances}/build_spec_files/doc2/doc2_1.html +0 -0
  31. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/{sources → instances}/build_spec_files/doc2.html +0 -0
  32. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/{sources → instances}/build_spec_files/index.html +0 -0
  33. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/source_generators/base_spec_files/no_options/content/body.adoc +1 -1
  34. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/source_generators/base_spec_files/no_options/content/title +1 -0
  35. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/source_generators/base_spec_files/no_options/theme/main.css +0 -0
  36. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/sources/base_spec.rb +14 -0
  37. data/sub/avm-eac_asciidoctor_base0/spec/spec_helper.rb +1 -4
  38. data/sub/avm-eac_asciidoctor_base0/template/avm/eac_asciidoctor_base0/source_generators/base/content/body.adoc +1 -1
  39. data/sub/avm-eac_asciidoctor_base0/template/avm/eac_asciidoctor_base0/source_generators/base/content/title +1 -0
  40. data/sub/avm-eac_asciidoctor_base0/template/avm/eac_asciidoctor_base0/source_generators/base/theme/main.css +0 -0
  41. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
  42. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb +27 -0
  43. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/gemfile_lock.rb +27 -0
  44. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/options.rb +30 -0
  45. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb +52 -0
  46. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base.rb +1 -66
  47. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  48. data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/source_generators/base_spec.rb +2 -1
  49. data/sub/eac_cli/eac_cli.gemspec +2 -2
  50. data/sub/eac_cli/lib/eac_cli/config/entry.rb +4 -0
  51. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  52. data/sub/eac_config/eac_config.gemspec +2 -2
  53. data/sub/eac_config/lib/eac_config/entry/not_found_error.rb +13 -0
  54. data/sub/eac_config/lib/eac_config/entry.rb +7 -0
  55. data/sub/eac_config/lib/eac_config/version.rb +1 -1
  56. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +9 -0
  57. data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +15 -6
  58. data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +5 -1
  59. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  60. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +9 -2
  61. metadata +34 -29
  62. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build/document.rb +0 -84
  63. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/sources/build_spec.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4a759c572f8acfb951cb1952ae3b1b1800bac5dada73d1907e8e8e2df9fa9e5
4
- data.tar.gz: 4c5804436ac869605af3be470557cee27131fbe0be2d6f2191f778210d7c60cd
3
+ metadata.gz: 65b0eefb0e0ef10a3abfd27894a02ee0d4c7de07af8aa4f26a20d4ac4fd6dcbd
4
+ data.tar.gz: 6b07c4255b3d7ce70942927f6293d185ee7103bfd83fd6cc39fb0f69383293ac
5
5
  SHA512:
6
- metadata.gz: dbe1a9779ef9fa3a6d11c4d47bd47d9a5812d7af616669ff01a503233c563f15d64ca857b3536ea89e3b767d28c8ea13f56b0615c4183cf965729433bffd0310
7
- data.tar.gz: a2f36c26ff611a47052fcf57a31a9644c408160ae27dc637d0ebdbd8c3477fe564dcc56bc7ce38076d3be7ef6e6a6619cd1aab7e70db4fe19b3da55e20dbff04
6
+ metadata.gz: d67d744fc384ea9a92c1b39aa98bfda3f53c72125a48cd76d00963c94b51fdf1bdceffb2f489da4b03475a26afcdc660c9cc6ee0cfc911d6312f66ef37a1a3e5
7
+ data.tar.gz: ea8f9e685277a7e941ebe4e76593df2065505098e961d014ebe87f4d297e394e5b2f94d97574978d60e0cadf932e7a7b81add2e7b3cc89d92aff8d6967b6f67a
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.41.0)
5
- avm (~> 0.54)
6
- avm-eac_asciidoctor_base0 (~> 0.9)
4
+ eac_tools (0.43.0)
5
+ avm (~> 0.55)
6
+ avm-eac_asciidoctor_base0 (~> 0.11)
7
7
  avm-eac_generic_base0 (~> 0.8)
8
8
  avm-eac_latex_base0 (~> 0.3)
9
9
  avm-eac_php_base0 (~> 0.3)
@@ -11,11 +11,11 @@ PATH
11
11
  avm-eac_rails_base1 (~> 0.7)
12
12
  avm-eac_redmine_base0 (~> 0.16)
13
13
  avm-eac_redmine_plugin_base0 (~> 0.3)
14
- avm-eac_ruby_base1 (~> 0.26, >= 0.26.2)
14
+ avm-eac_ruby_base1 (~> 0.27)
15
15
  avm-eac_webapp_base0 (~> 0.12, >= 0.12.2)
16
16
  avm-eac_wordpress_base0 (~> 0.2, >= 0.2.1)
17
17
  avm-tools (~> 0.142, >= 0.142.4)
18
- eac_ruby_utils (~> 0.106, >= 0.106.1)
18
+ eac_ruby_utils (~> 0.107)
19
19
 
20
20
  PATH
21
21
  remote: sub/aranha-parsers
@@ -33,10 +33,10 @@ PATH
33
33
  PATH
34
34
  remote: sub/avm-eac_asciidoctor_base0
35
35
  specs:
36
- avm-eac_asciidoctor_base0 (0.9.0)
36
+ avm-eac_asciidoctor_base0 (0.11.0)
37
37
  asciidoctor (~> 2.0, >= 2.0.18)
38
38
  avm-eac_webapp_base0 (~> 0.12, >= 0.12.2)
39
- eac_ruby_utils (~> 0.106, >= 0.106.1)
39
+ eac_ruby_utils (~> 0.107)
40
40
  os (~> 1.1, >= 1.1.4)
41
41
  rouge (~> 3.30)
42
42
 
@@ -108,10 +108,10 @@ PATH
108
108
  PATH
109
109
  remote: sub/avm-eac_ruby_base1
110
110
  specs:
111
- avm-eac_ruby_base1 (0.26.2)
112
- avm (~> 0.54)
111
+ avm-eac_ruby_base1 (0.27.0)
112
+ avm (~> 0.55)
113
113
  avm-eac_generic_base0 (~> 0.8)
114
- eac_ruby_utils (~> 0.106, >= 0.106.1)
114
+ eac_ruby_utils (~> 0.107)
115
115
 
116
116
  PATH
117
117
  remote: sub/avm-eac_webapp_base0
@@ -173,14 +173,14 @@ PATH
173
173
  PATH
174
174
  remote: sub/avm
175
175
  specs:
176
- avm (0.54.0)
176
+ avm (0.55.0)
177
177
  aranha-parsers (~> 0.14, >= 0.14.4)
178
- eac_cli (~> 0.28)
179
- eac_config (~> 0.11, >= 0.11.1)
178
+ eac_cli (~> 0.29)
179
+ eac_config (~> 0.12)
180
180
  eac_docker (~> 0.5)
181
- eac_fs (~> 0.13)
181
+ eac_fs (~> 0.14)
182
182
  eac_git (~> 0.13)
183
- eac_ruby_utils (~> 0.106, >= 0.106.1)
183
+ eac_ruby_utils (~> 0.107)
184
184
  eac_templates (~> 0.3, >= 0.3.2)
185
185
  filesize (~> 0.2)
186
186
  htmlbeautifier (~> 1.4, >= 1.4.2)
@@ -189,17 +189,17 @@ PATH
189
189
  PATH
190
190
  remote: sub/eac_cli
191
191
  specs:
192
- eac_cli (0.28.0)
192
+ eac_cli (0.29.0)
193
193
  colorize (~> 0.8, >= 0.8.1)
194
- eac_config (~> 0.11, >= 0.11.1)
195
- eac_ruby_utils (~> 0.103)
194
+ eac_config (~> 0.12)
195
+ eac_ruby_utils (~> 0.107)
196
196
 
197
197
  PATH
198
198
  remote: sub/eac_config
199
199
  specs:
200
- eac_config (0.11.1)
201
- addressable (~> 2.8)
202
- eac_ruby_utils (~> 0.102)
200
+ eac_config (0.12.0)
201
+ addressable (~> 2.8, >= 2.8.1)
202
+ eac_ruby_utils (~> 0.107)
203
203
 
204
204
  PATH
205
205
  remote: sub/eac_docker
@@ -235,7 +235,7 @@ PATH
235
235
  PATH
236
236
  remote: sub/eac_ruby_utils
237
237
  specs:
238
- eac_ruby_utils (0.106.1)
238
+ eac_ruby_utils (0.107.0)
239
239
  activesupport (>= 4, < 7)
240
240
  addressable (~> 2.8, >= 2.8.1)
241
241
  bundler
@@ -370,7 +370,7 @@ GEM
370
370
  tzinfo (2.0.5)
371
371
  concurrent-ruby (~> 1.0)
372
372
  unicode-display_width (1.6.1)
373
- zeitwerk (2.6.1)
373
+ zeitwerk (2.6.4)
374
374
  zlib (2.1.1)
375
375
 
376
376
  PLATFORMS
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.41.0'
4
+ VERSION = '0.43.0'
5
5
  end
data/sub/avm/avm.gemspec CHANGED
@@ -13,12 +13,12 @@ Gem::Specification.new do |s|
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
15
  s.add_dependency 'aranha-parsers', '~> 0.14', '>= 0.14.4'
16
- s.add_dependency 'eac_cli', '~> 0.28'
17
- s.add_dependency 'eac_config', '~> 0.11', '>= 0.11.1'
16
+ s.add_dependency 'eac_cli', '~> 0.29'
17
+ s.add_dependency 'eac_config', '~> 0.12'
18
18
  s.add_dependency 'eac_docker', '~> 0.5'
19
- s.add_dependency 'eac_fs', '~> 0.13'
19
+ s.add_dependency 'eac_fs', '~> 0.14'
20
20
  s.add_dependency 'eac_git', '~> 0.13'
21
- s.add_dependency 'eac_ruby_utils', '~> 0.106', '>= 0.106.1'
21
+ s.add_dependency 'eac_ruby_utils', '~> 0.107'
22
22
  s.add_dependency 'eac_templates', '~> 0.3', '>= 0.3.2'
23
23
  s.add_dependency 'filesize', '~> 0.2'
24
24
  s.add_dependency 'htmlbeautifier', '~> 1.4', '>= 1.4.2'
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/entries/base'
4
+ require 'avm/instances/ids'
4
5
  require 'avm/registry'
5
6
  require 'eac_ruby_utils/core_ext'
6
7
 
@@ -22,23 +23,43 @@ module Avm
22
23
  end
23
24
 
24
25
  def instance(suffix)
25
- ::Avm::Instances::Base.new(self, suffix)
26
+ stereotype.instance_class.new(self, suffix)
26
27
  end
27
28
 
28
29
  def name
29
30
  entry(::Avm::Instances::EntryKeys::NAME).read
30
31
  end
31
32
 
33
+ # @return [String]
34
+ def local_instance_id
35
+ ::Avm::Instances::Ids.build(id, local_instance_suffix)
36
+ end
37
+
38
+ # @return [Pathname]
39
+ def local_source_path
40
+ local_source_path_entry.value!.to_pathname
41
+ end
42
+
43
+ # @return [EacConfig::Entry]
44
+ def local_source_path_entry
45
+ ::EacConfig::Node.context.current.entry([local_instance_id, 'install', 'path'])
46
+ end
47
+
48
+ # @return [String]
49
+ def local_instance_suffix
50
+ LOCAL_INSTANCE_SUFFIX
51
+ end
52
+
32
53
  private
33
54
 
34
55
  # @return [Avm::Instances::Base]
35
56
  def local_instance_uncached
36
- instance(LOCAL_INSTANCE_SUFFIX)
57
+ instance(local_instance_suffix)
37
58
  end
38
59
 
39
60
  # @return [Avm::Sources::Base]
40
61
  def local_source_uncached
41
- ::Avm::Registry.sources.detect(local_instance.install_path)
62
+ ::Avm::Registry.sources.detect(local_source_path)
42
63
  end
43
64
  end
44
65
  end
@@ -46,6 +46,11 @@ module Avm
46
46
  optional_value || read
47
47
  end
48
48
 
49
+ def value!
50
+ optional_value.if_present { |v| return v }
51
+ context_entry.value!
52
+ end
53
+
49
54
  def write(value)
50
55
  context_entry.value = value
51
56
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/ids'
3
4
  require 'avm/with/application_stereotype'
4
5
  require 'avm/with/extra_subcommands'
5
6
  require 'eac_ruby_utils/require_sub'
@@ -23,18 +24,9 @@ module Avm
23
24
 
24
25
  class << self
25
26
  def by_id(id)
26
- application_id, suffix = parse_id(id)
27
+ parsed_id = ::Avm::Instances::Ids.parse!(id)
27
28
  require 'avm/applications/base'
28
- new(::Avm::Applications::Base.new(application_id), suffix)
29
- end
30
-
31
- private
32
-
33
- def parse_id(id)
34
- m = ID_PATTERN.match(id)
35
- return [m[1], m[2]] if m
36
-
37
- raise "ID Pattern no matched: \"#{id}\""
29
+ new(::Avm::Applications::Base.new(parsed_id.application_id), parsed_id.instance_suffix)
38
30
  end
39
31
  end
40
32
 
@@ -42,8 +34,9 @@ module Avm
42
34
  self.suffix = suffix.to_s
43
35
  end
44
36
 
37
+ # @return [String]
45
38
  def id
46
- "#{application.id}_#{suffix}"
39
+ ::Avm::Instances::Ids.build(application.id, suffix)
47
40
  end
48
41
 
49
42
  def to_s
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Instances
7
+ module Ids
8
+ ID_PARTS_SEPARATOR = '_'
9
+ ID_PATTERN = /\A([a-z0-9]+(?:\-[a-z0-9]+)*)_(.+)\z/.freeze
10
+ ID_PARSER = ID_PATTERN.to_parser do |m|
11
+ ::Struct.new(:application_id, :instance_suffix).new(m[1], m[2])
12
+ end
13
+
14
+ class << self
15
+ # @param application_id [String]
16
+ # @param instance_suffix [String]
17
+ # @return [String]
18
+ def build(application_id, instance_suffix)
19
+ [application_id, instance_suffix].join(ID_PARTS_SEPARATOR)
20
+ end
21
+
22
+ # @param id [String]
23
+ # @return [String]
24
+ def parse!(id)
25
+ ID_PARSER.parse!(id)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -21,6 +21,14 @@ module Avm
21
21
  require "avm/rspec/shared_examples/#{example}"
22
22
  end
23
23
  end
24
+
25
+ # @return [self]
26
+ def stub_avm_contexts
27
+ stub_eac_config_node
28
+ stub_eac_speaker
29
+
30
+ self
31
+ end
24
32
  end
25
33
  end
26
34
  end
@@ -7,20 +7,8 @@ module Avm
7
7
  module Sources
8
8
  class Base
9
9
  module Instance
10
- DEFAULT_INSTANCE_SUFFIX = 'dev'
11
-
12
- def instance_suffix
13
- DEFAULT_INSTANCE_SUFFIX
14
- end
15
-
16
- private
17
-
18
- def application_uncached
19
- ::Avm::Applications::Base.new(path.basename)
20
- end
21
-
22
- def instance_uncached
23
- ::Avm::Instances::Base.new(application, DEFAULT_INSTANCE_SUFFIX)
10
+ def instance
11
+ application.local_instance
24
12
  end
25
13
  end
26
14
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.54.0'
4
+ VERSION = '0.55.0'
5
5
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/rspec/default_setup'
4
- ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
4
+ ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__)).stub_avm_contexts
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency 'asciidoctor', '~> 2.0', '>= 2.0.18'
16
16
  s.add_dependency 'avm-eac_webapp_base0', '~> 0.12', '>= 0.12.2'
17
- s.add_dependency 'eac_ruby_utils', '~> 0.106', '>= 0.106.1'
17
+ s.add_dependency 'eac_ruby_utils', '~> 0.107'
18
18
  s.add_dependency 'os', '~> 1.1', '>= 1.1.4'
19
19
  s.add_dependency 'rouge', '~> 3.30'
20
20
 
@@ -10,6 +10,24 @@ module Avm
10
10
  module Instances
11
11
  class Base < ::Avm::EacWebappBase0::Instances::Base
12
12
  FILES_UNITS = {}.freeze
13
+ AUTHOR_EMAIL_ENTRY_PATH = 'install.email'
14
+ AUTHOR_NAME_ENTRY_PATH = 'install.name'
15
+ AUTHOR_NAME_INITIALS_ENTRY_PATH = 'install.name_initials'
16
+
17
+ # @return [String]
18
+ def author_email
19
+ entry(AUTHOR_EMAIL_ENTRY_PATH).value!
20
+ end
21
+
22
+ # @return [String]
23
+ def author_name
24
+ entry(AUTHOR_NAME_ENTRY_PATH).value!
25
+ end
26
+
27
+ # @return [String]
28
+ def author_name_initials
29
+ entry(AUTHOR_NAME_INITIALS_ENTRY_PATH).value!
30
+ end
13
31
  end
14
32
  end
15
33
  end
@@ -0,0 +1,78 @@
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 HeaderMacroValue
11
+ enable_method_class
12
+ enable_settings_provider
13
+ enable_simple_cache
14
+ common_constructor :document
15
+
16
+ delegate :build, :source_document, to: :document
17
+ delegate :instance, to: :build
18
+ delegate :author_email, :author_name, to: :instance
19
+
20
+ ATTRIBUTES = ['Author Initials', 'toc', 'icons', 'numbered', 'website'].freeze
21
+ TOC = 'left'
22
+ ICONS = ''
23
+ NUMBERED = ''
24
+
25
+ # @return [String]
26
+ def attribute_line(name, value)
27
+ [":#{name}:", value].reject(&:blank?).join(' ')
28
+ end
29
+
30
+ def attributes_lines
31
+ ATTRIBUTES.map { |attr| attribute_line(attr, attribute_value(attr)) }
32
+ end
33
+
34
+ def attribute_value(attr)
35
+ setting_value(attr.variableize)
36
+ end
37
+
38
+ def author_initials
39
+ instance.author_name_initials
40
+ end
41
+
42
+ def author_line
43
+ "#{author_name} <#{author_email}>"
44
+ end
45
+
46
+ def result
47
+ result_lines.join("\n")
48
+ end
49
+
50
+ def result_lines
51
+ [stylesheet_line, title_line, author_line] + attributes_lines
52
+ end
53
+
54
+ # @return [String]
55
+ def stylesheet_line
56
+ attribute_line('stylesheet', stylesheet_path)
57
+ end
58
+
59
+ # @return [Pathname]
60
+ def stylesheet_path
61
+ source_document.source.theme_stylesheet_path
62
+ .relative_path_from(document.convert_base_dir)
63
+ end
64
+
65
+ # @return [String]
66
+ def title_line
67
+ "= #{source_document.title}"
68
+ end
69
+
70
+ def website
71
+ instance.web_url
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,50 @@
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 PreProcessLine
11
+ enable_method_class
12
+ enable_simple_cache
13
+
14
+ MACRO_PARSER = %r{\A\s*//\#(\S+.*)}.to_parser do |m|
15
+ m[1]
16
+ end
17
+
18
+ common_constructor :document, :line
19
+
20
+ def result
21
+ if macro?
22
+ macro_value
23
+ else
24
+ line
25
+ end
26
+ end
27
+
28
+ def macro?
29
+ macro_name.present?
30
+ end
31
+
32
+ def macro_parser
33
+ MACRO_PARSER
34
+ end
35
+
36
+ def macro_value
37
+ document.send("#{macro_name}_macro_value")
38
+ end
39
+
40
+ private
41
+
42
+ def macro_name_uncached
43
+ macro_parser.parse(line)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,71 @@
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 Instances
9
+ class Build
10
+ class Document
11
+ require_sub __FILE__
12
+
13
+ ROOT_BODY_TARGET_BASENAME = 'index'
14
+
15
+ enable_simple_cache
16
+ enable_speaker
17
+ common_constructor :build, :parent_document, :source_document
18
+
19
+ # Absolute path to the output of Asciidoctor's source file.
20
+ #
21
+ # @return [Pathname]
22
+ def body_target_path
23
+ build.target_directory.join(
24
+ parent_document.present? ? source_document.subpath : ROOT_BODY_TARGET_BASENAME
25
+ ).basename_sub('.*') { |b| "#{b}.html" }
26
+ end
27
+
28
+ # @return [Pathname]
29
+ def convert_base_dir
30
+ source_document.root_path
31
+ end
32
+
33
+ def perform
34
+ perform_self
35
+ perform_children
36
+ end
37
+
38
+ def perform_self
39
+ infov 'Building', source_document.root_path
40
+ ::Asciidoctor.convert(
41
+ pre_processed_body_source_content,
42
+ base_dir: convert_base_dir,
43
+ to_file: body_target_path.to_path, safe: :unsafe, mkdirs: true
44
+ )
45
+ end
46
+
47
+ def perform_children
48
+ children.each(&:perform)
49
+ end
50
+
51
+ # @return [String]
52
+ def pre_processed_body_source_content
53
+ source_document.body_path.read.each_line
54
+ .map { |line| pre_process_line(line.rstrip) + "\n" }.join
55
+ end
56
+
57
+ def tree_documents_count
58
+ children.inject(1) { |a, e| a + e.tree_documents_count }
59
+ end
60
+
61
+ private
62
+
63
+ def children_uncached
64
+ source_document.children
65
+ .map { |source_child| self.class.new(build, self, source_child) }
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -5,14 +5,15 @@ require 'eac_ruby_utils/fs/clearable_directory'
5
5
 
6
6
  module Avm
7
7
  module EacAsciidoctorBase0
8
- module Sources
8
+ module Instances
9
9
  class Build
10
10
  require_sub __FILE__
11
11
  enable_speaker
12
12
  enable_simple_cache
13
13
  enable_listable
14
14
  lists.add_symbol :option, :target_directory
15
- common_constructor :source, :options, default: [{}] do
15
+ common_constructor :instance, :options, default: [{}] do
16
+ instance.assert_argument(::Avm::EacAsciidoctorBase0::Instances::Base, 'instance')
16
17
  self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
17
18
  end
18
19
 
@@ -29,7 +30,13 @@ module Avm
29
30
  end
30
31
 
31
32
  def root_document
32
- ::Avm::EacAsciidoctorBase0::Sources::Build::Document.new(self, nil, nil)
33
+ ::Avm::EacAsciidoctorBase0::Instances::Build::Document
34
+ .new(self, nil, source.root_document)
35
+ end
36
+
37
+ # @return [Avm::EacAsciidoctorBase0::Sources::Base]
38
+ def source
39
+ instance.application.local_source
33
40
  end
34
41
 
35
42
  def target_directory
@@ -2,16 +2,16 @@
2
2
 
3
3
  require 'avm/eac_webapp_base0/instances/deploy'
4
4
  require 'avm/eac_asciidoctor_base0/sources/base'
5
- require 'avm/eac_asciidoctor_base0/sources/build'
5
+ require 'avm/eac_asciidoctor_base0/instances/build'
6
6
 
7
7
  module Avm
8
8
  module EacAsciidoctorBase0
9
9
  module Instances
10
10
  class Deploy < ::Avm::EacWebappBase0::Instances::Deploy
11
11
  def build_content
12
- ::Avm::EacAsciidoctorBase0::Sources::Build.new(
13
- project,
14
- ::Avm::EacAsciidoctorBase0::Sources::Build::OPTION_TARGET_DIRECTORY => build_dir
12
+ ::Avm::EacAsciidoctorBase0::Instances::Build.new(
13
+ instance,
14
+ ::Avm::EacAsciidoctorBase0::Instances::Build::OPTION_TARGET_DIRECTORY => build_dir
15
15
  ).perform
16
16
  end
17
17
 
@@ -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 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