eac_tools 0.60.3 → 0.61.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +13 -13
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_lines.rb +1 -1
  5. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/pre_process_line.rb +16 -4
  6. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document.rb +23 -1
  7. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/base.rb +21 -0
  8. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/breadcrumbs.rb +55 -0
  9. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/child_docs/document_builder.rb +63 -0
  10. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/child_docs.rb +35 -0
  11. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/default_body.rb +21 -0
  12. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros.rb +13 -0
  13. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base.rb +5 -1
  14. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
  15. data/sub/avm-files/avm-files.gemspec +1 -1
  16. data/sub/avm-files/lib/avm/files/version.rb +1 -1
  17. data/sub/avm-git/avm-git.gemspec +2 -2
  18. data/sub/avm-git/lib/avm/git/version.rb +1 -1
  19. data/sub/eac_templates/lib/eac_templates/abstract/directory.rb +42 -0
  20. data/sub/eac_templates/lib/eac_templates/abstract/file.rb +25 -0
  21. data/sub/eac_templates/lib/eac_templates/abstract/fs_object.rb +94 -0
  22. data/sub/eac_templates/lib/eac_templates/abstract/fs_object_by_pathname.rb +13 -0
  23. data/sub/eac_templates/lib/eac_templates/abstract/not_found_error.rb +8 -0
  24. data/sub/eac_templates/lib/eac_templates/interface_methods.rb +3 -3
  25. data/sub/eac_templates/lib/eac_templates/modules/ancestor/directory.rb +4 -2
  26. data/sub/eac_templates/lib/eac_templates/modules/ancestor/file.rb +3 -2
  27. data/sub/eac_templates/lib/eac_templates/modules/ancestor/fs_object.rb +6 -13
  28. data/sub/eac_templates/lib/eac_templates/modules/ancestor.rb +6 -3
  29. data/sub/eac_templates/lib/eac_templates/sources/directory.rb +23 -10
  30. data/sub/eac_templates/lib/eac_templates/sources/file.rb +3 -14
  31. data/sub/eac_templates/lib/eac_templates/sources/fs_object.rb +17 -17
  32. data/sub/eac_templates/lib/eac_templates/sources/set.rb +5 -4
  33. data/sub/eac_templates/lib/eac_templates/variables/content.rb +52 -0
  34. data/sub/eac_templates/lib/eac_templates/variables/directory.rb +7 -5
  35. data/sub/eac_templates/lib/eac_templates/variables/file.rb +9 -33
  36. data/sub/eac_templates/lib/eac_templates/version.rb +1 -1
  37. data/sub/eac_templates/spec/lib/eac_templates/{patches/module/template_spec.rb → modules/base_spec.rb} +41 -20
  38. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/a/a_b +1 -0
  39. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/c +1 -0
  40. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/prepended_module/c +1 -0
  41. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/super_class/a/a_b +1 -0
  42. data/sub/eac_templates/spec/lib/eac_templates/variables/{file_spec.rb → content_spec.rb} +4 -4
  43. metadata +33 -28
  44. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/breadcrumbs_macro_value.rb +0 -59
  45. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/child_docs_macro_value.rb +0 -49
  46. data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/a_module/a/a_b +0 -1
  47. data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/a_module/c +0 -1
  48. data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/super_class/a/a_b +0 -1
  49. /data/sub/eac_templates/spec/lib/eac_templates/{patches/module/template_spec_files → modules/base_spec_files}/path1/a_module/a/a_a +0 -0
  50. /data/sub/eac_templates/spec/lib/eac_templates/{patches/module/template_spec_files → modules/base_spec_files}/path1/a_module/b +0 -0
  51. /data/sub/eac_templates/spec/lib/eac_templates/{patches/module/template_spec_files → modules/base_spec_files}/path1/super_class/a/a_b +0 -0
  52. /data/sub/eac_templates/spec/lib/eac_templates/{patches/module/template_spec_files → modules/base_spec_files}/path1/super_class/b +0 -0
  53. /data/sub/eac_templates/spec/lib/eac_templates/{patches/module/template_spec_files → modules/base_spec_files}/path2/a_module/b +0 -0
  54. /data/sub/eac_templates/spec/lib/eac_templates/{patches/module/template_spec_files → modules/base_spec_files}/path2/sub_class/b +0 -0
  55. /data/sub/eac_templates/spec/lib/eac_templates/{patches/module/template_spec_files → modules/base_spec_files}/path2/super_class/b +0 -0
  56. /data/sub/eac_templates/spec/lib/eac_templates/variables/{file_spec_files → content_spec_files}/expected_content +0 -0
  57. /data/sub/eac_templates/spec/lib/eac_templates/variables/{file_spec_files → content_spec_files}/source.template +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45d93cbf1d3d3ff2f5b76c8fffeae344c0025b822fcfd9fac2a2f4aabffd92cf
4
- data.tar.gz: c1a141d90c59c987c7f2f08a1aed69561782042a04ff42cf238b5c78baa996dc
3
+ metadata.gz: a00f661cc45fae52c9754c08ad739ca0b401f18eab714f32624cd3fc43617873
4
+ data.tar.gz: e9f70e33cb5d6cb6b82e9ab47baa474717b65566533aab724494cf604234ba59
5
5
  SHA512:
6
- metadata.gz: 201e612bf01ed05f4c1e2f7478591cb6aecfbdc526af61931cc05aebaf916e4ed00592ffb7d66e86d90e48074d264f96d18b91d17f4cc49aad5db6450a9ec3a6
7
- data.tar.gz: 1372d4f44f77b4ea330e6233509faee81f6ac75e0316f6e18517fbafebe270c475826272edc28b62663667cb13ac0edb4ad5c220290a9f5650974e31224174ea
6
+ metadata.gz: 97736cf986ece6075c9c7b019021e2d84fc7b82c8e3a146f7a52d34460825047bcf9c45cce03664ddfd9a4a1d9acab72c88052770c024056c74dab8b30b21182
7
+ data.tar.gz: 665937d9379e2fd16de13e599c59d623d101c18f271bf45085a99f9d5c57847b41649580af8447848847b0164621abaf6af32ad18dbd657f93e7954def080474
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.60.3)
4
+ eac_tools (0.61.1)
5
5
  avm (~> 0.67, >= 0.67.1)
6
- avm-eac_asciidoctor_base0 (~> 0.18, >= 0.18.1)
6
+ avm-eac_asciidoctor_base0 (~> 0.19)
7
7
  avm-eac_generic_base0 (~> 0.12)
8
8
  avm-eac_latex_base0 (~> 0.3, >= 0.3.1)
9
9
  avm-eac_php_base0 (~> 0.4, >= 0.4.2)
@@ -16,7 +16,7 @@ PATH
16
16
  avm-eac_ruby_base1 (~> 0.30, >= 0.30.2)
17
17
  avm-eac_webapp_base0 (~> 0.15)
18
18
  avm-eac_wordpress_base0 (~> 0.3, >= 0.3.1)
19
- avm-git (~> 0.13, >= 0.13.1)
19
+ avm-git (~> 0.13, >= 0.13.2)
20
20
  avm-tools (~> 0.145, >= 0.145.1)
21
21
  eac_ruby_utils (~> 0.112)
22
22
 
@@ -34,7 +34,7 @@ PATH
34
34
  PATH
35
35
  remote: sub/avm-eac_asciidoctor_base0
36
36
  specs:
37
- avm-eac_asciidoctor_base0 (0.18.1)
37
+ avm-eac_asciidoctor_base0 (0.19.0)
38
38
  asciidoctor (~> 2.0, >= 2.0.18)
39
39
  avm-eac_webapp_base0 (~> 0.15)
40
40
  eac_ruby_utils (~> 0.112)
@@ -153,19 +153,19 @@ PATH
153
153
  PATH
154
154
  remote: sub/avm-files
155
155
  specs:
156
- avm-files (0.6.1)
156
+ avm-files (0.6.2)
157
157
  avm (~> 0.67, >= 0.67.1)
158
158
  eac_cli (~> 0.30, >= 0.30.1)
159
159
  eac_fs (~> 0.16)
160
160
  eac_ruby_utils (~> 0.112)
161
- eac_templates (~> 0.4)
161
+ eac_templates (~> 0.5)
162
162
 
163
163
  PATH
164
164
  remote: sub/avm-git
165
165
  specs:
166
- avm-git (0.13.1)
167
- avm (~> 0.64, >= 0.64.2)
168
- avm-files (~> 0.6)
166
+ avm-git (0.13.2)
167
+ avm (~> 0.67, >= 0.67.1)
168
+ avm-files (~> 0.6, >= 0.6.2)
169
169
  eac_git (~> 0.14, >= 0.14.1)
170
170
  eac_ruby_utils (~> 0.112)
171
171
  git (~> 1.18)
@@ -263,7 +263,7 @@ PATH
263
263
  PATH
264
264
  remote: sub/eac_templates
265
265
  specs:
266
- eac_templates (0.4.0)
266
+ eac_templates (0.5.0)
267
267
  eac_config (~> 0.12)
268
268
  eac_ruby_utils (~> 0.112)
269
269
 
@@ -287,7 +287,7 @@ GEM
287
287
  parslet (~> 2.0)
288
288
  curb (0.9.11)
289
289
  diff-lcs (1.5.0)
290
- eac_envs-http (0.3.0)
290
+ eac_envs-http (0.3.1)
291
291
  eac_fs (~> 0.16)
292
292
  eac_ruby_utils (~> 0.112)
293
293
  faraday (~> 2.7, >= 2.7.4)
@@ -295,8 +295,8 @@ GEM
295
295
  faraday-gzip (~> 0.1)
296
296
  faraday-multipart (~> 1.0, >= 1.0.4)
297
297
  faraday-retry (~> 2.1)
298
- eac_rest (0.7.3)
299
- eac_envs-http (~> 0.2)
298
+ eac_rest (0.8.0)
299
+ eac_envs-http (~> 0.3, >= 0.3.1)
300
300
  eac_fs (~> 0.16)
301
301
  eac_ruby_utils (~> 0.112)
302
302
  eac_ruby_gem_support (0.5.1)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.60.3'
4
+ VERSION = '0.61.1'
5
5
  end
@@ -45,7 +45,7 @@ module Avm
45
45
 
46
46
  # @return [String]
47
47
  def breadcrumbs_lines
48
- ['[.normal]', document.breadcrumbs_macro_value]
48
+ ['[.normal]', document.macro_lines(:breadcrumbs)]
49
49
  end
50
50
 
51
51
  # @return [Array<String>]
@@ -11,8 +11,10 @@ module Avm
11
11
  enable_method_class
12
12
  enable_simple_cache
13
13
 
14
- MACRO_PARSER = %r{\A\s*//\#(\S+.*)}.to_parser do |m|
15
- m[1]
14
+ ARGUMENT_SEPARATOR = ','
15
+ MACRO_PARSER = %r{\A\s*//\#(\S+)(?:\s+(.+))?\s*?\z}.to_parser do |m|
16
+ ::Struct.new(:name, :arguments).new(m[1],
17
+ m[2].to_s.split(ARGUMENT_SEPARATOR).map(&:strip))
16
18
  end
17
19
 
18
20
  common_constructor :document, :line
@@ -30,18 +32,28 @@ module Avm
30
32
  macro_name.present?
31
33
  end
32
34
 
35
+ # @return [Array<String>, nil]
36
+ def macro_arguments
37
+ parsed_macro.if_present(&:arguments)
38
+ end
39
+
40
+ # @return [String, nil]
41
+ def macro_name
42
+ parsed_macro.if_present(&:name)
43
+ end
44
+
33
45
  def macro_parser
34
46
  MACRO_PARSER
35
47
  end
36
48
 
37
49
  # @return [Array<String>]
38
50
  def macro_value
39
- document.send("#{macro_name}_macro_value")
51
+ document.macro_lines(macro_name, macro_arguments)
40
52
  end
41
53
 
42
54
  private
43
55
 
44
- def macro_name_uncached
56
+ def parsed_macro_uncached
45
57
  macro_parser.parse(line)
46
58
  end
47
59
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'asciidoctor'
4
+ require 'avm/eac_asciidoctor_base0/instances/macros'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module Avm
@@ -22,6 +23,15 @@ module Avm
22
23
  other.body_target_path.relative_path_from(body_target_path.dirname)
23
24
  end
24
25
 
26
+ # @return [Enumerable<String>]
27
+ def body_source_lines
28
+ if source_document.body_path.file?
29
+ source_document.body_path.read.each_line
30
+ else
31
+ default_body_source_lines
32
+ end
33
+ end
34
+
25
35
  # Absolute path to the output of Asciidoctor's source file.
26
36
  #
27
37
  # @return [Pathname]
@@ -56,6 +66,18 @@ module Avm
56
66
  source_document.root_path
57
67
  end
58
68
 
69
+ # @return [Enumerable<String>]
70
+ def default_body_source_lines
71
+ macro_lines(:default_body)
72
+ end
73
+
74
+ # @param name [String]
75
+ # @return [Array<String>]
76
+ def macro_lines(name, arguments = [])
77
+ ::Avm::EacAsciidoctorBase0::Instances::Macros.const_get(name.to_s.camelize)
78
+ .new(self, arguments).result
79
+ end
80
+
59
81
  def perform
60
82
  perform_self
61
83
  perform_children
@@ -74,7 +96,7 @@ module Avm
74
96
  # @return [String]
75
97
  def pre_processed_body_source_content
76
98
  (
77
- header_lines + [''] + source_document.body_path.read.each_line
99
+ header_lines + [''] + body_source_lines
78
100
  .flat_map { |line| pre_process_line(line.rstrip) }
79
101
  ).map { |line| "#{line.rstrip}\n" }.join
80
102
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacAsciidoctorBase0
7
+ module Instances
8
+ module Macros
9
+ class Base
10
+ enable_abstract_methods
11
+ common_constructor :document, :arguments, default: [[]]
12
+
13
+ # @return [Array<String>]
14
+ def result
15
+ raise_abstract_method __method__
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_asciidoctor_base0/instances/macros/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module Instances
9
+ module Macros
10
+ class Breadcrumbs < ::Avm::EacAsciidoctorBase0::Instances::Macros::Base
11
+ NODE_SEPARATOR = ' » '
12
+ ROOT_DOCUMENT_TITLE = 'Home'
13
+
14
+ # @return [Array<String>]
15
+ def result
16
+ trail_nodes.join(NODE_SEPARATOR)
17
+ end
18
+
19
+ def trail_nodes
20
+ r = []
21
+ current = document
22
+ while current.present?
23
+ r.unshift(Node.new(document, current))
24
+ current = current.parent_document
25
+ end
26
+ r
27
+ end
28
+
29
+ class Node
30
+ common_constructor :current, :document
31
+
32
+ # @return [String]
33
+ def address
34
+ current.href_to_other_body(document)
35
+ end
36
+
37
+ # @return [String]
38
+ def title
39
+ if document.parent_document.present?
40
+ document.source_document.title
41
+ else
42
+ ROOT_DOCUMENT_TITLE
43
+ end
44
+ end
45
+
46
+ # @return [String]
47
+ def to_s
48
+ "link:#{address}[#{title}]"
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_asciidoctor_base0/instances/macros/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module Instances
9
+ module Macros
10
+ class ChildDocs < ::Avm::EacAsciidoctorBase0::Instances::Macros::Base
11
+ class DocumentBuilder
12
+ common_constructor :child_docs, :document, :depth, default: [0]
13
+ compare_by :title, :address
14
+
15
+ # @return [Pathname]
16
+ def address
17
+ root_document.href_to_other_body(document)
18
+ end
19
+
20
+ # @return [Array] Document's children mapped to document builders.
21
+ def children
22
+ document.children.map { |c| self.class.new(child_docs, c, depth + 1) }.sort
23
+ end
24
+
25
+ # @return [Boolean]
26
+ def lines_for_children?
27
+ child_docs.maximum_depth.negative? || child_docs.maximum_depth <= depth
28
+ end
29
+
30
+ # @return [String]
31
+ def link
32
+ "link:#{address}[#{title}]"
33
+ end
34
+
35
+ # @return [Array<String>]
36
+ def result
37
+ children.flat_map do |child|
38
+ r = [child.self_line]
39
+ r += child.result if lines_for_children?
40
+ r
41
+ end
42
+ end
43
+
44
+ # @return [Avm::EacAsciidoctorBase0::Instances::Build::Document]
45
+ def root_document
46
+ child_docs.document
47
+ end
48
+
49
+ # @return [String]
50
+ def self_line
51
+ "#{'*' * depth} #{link}"
52
+ end
53
+
54
+ # @return [String]
55
+ def title
56
+ document.source_document.title
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_asciidoctor_base0/instances/macros/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module Instances
9
+ module Macros
10
+ class ChildDocs < ::Avm::EacAsciidoctorBase0::Instances::Macros::Base
11
+ DEFAULT_MAXIMUM_DEPTH = -1
12
+
13
+ # @return [Array<String>]
14
+ def result
15
+ document_builder_class.new(self, document).result
16
+ end
17
+
18
+ # @return [Integer]
19
+ def maximum_depth
20
+ arguments[0].if_present(DEFAULT_MAXIMUM_DEPTH, &:to_i)
21
+ end
22
+
23
+ private
24
+
25
+ # @return [Class]
26
+ def document_builder_class
27
+ ::Avm::EacAsciidoctorBase0::Instances::Macros::ChildDocs::DocumentBuilder
28
+ end
29
+
30
+ require_sub __FILE__
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_asciidoctor_base0/instances/macros/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacAsciidoctorBase0
8
+ module Instances
9
+ module Macros
10
+ class DefaultBody < ::Avm::EacAsciidoctorBase0::Instances::Macros::Base
11
+ RESULT_LINES = ['== Índice', '', '//#child_docs'].freeze
12
+
13
+ # @return [Array<String>]
14
+ def result
15
+ RESULT_LINES
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacAsciidoctorBase0
7
+ module Instances
8
+ module Macros
9
+ require_sub __FILE__
10
+ end
11
+ end
12
+ end
13
+ end
@@ -8,9 +8,13 @@ module Avm
8
8
  module EacAsciidoctorBase0
9
9
  module Sources
10
10
  class Base < ::Avm::EacWebappBase0::Sources::Base
11
+ require_sub __FILE__
12
+
11
13
  CONTENT_DIRECTORY_SUBPATH = ::Pathname.new('content')
12
14
  CONTENT_DOCUMENT_BASENAME = ::Pathname.new('body.adoc')
13
- MAIN_FILE_SUBPATH = CONTENT_DIRECTORY_SUBPATH.join(CONTENT_DOCUMENT_BASENAME)
15
+ MAIN_FILE_SUBPATH = CONTENT_DIRECTORY_SUBPATH.join(
16
+ ::Avm::EacAsciidoctorBase0::Sources::Base::Document::TITLE_BASENAME
17
+ )
14
18
 
15
19
  require_sub __FILE__, include_modules: true
16
20
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacAsciidoctorBase0
5
- VERSION = '0.18.1'
5
+ VERSION = '0.19.0'
6
6
  end
7
7
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency 'eac_cli', '~> 0.30', '>= 0.30.1'
17
17
  s.add_dependency 'eac_fs', '~> 0.16'
18
18
  s.add_dependency 'eac_ruby_utils', '~> 0.112'
19
- s.add_dependency 'eac_templates', '~> 0.4'
19
+ s.add_dependency 'eac_templates', '~> 0.5'
20
20
 
21
21
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
22
22
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Files
5
- VERSION = '0.6.1'
5
+ VERSION = '0.6.2'
6
6
  end
7
7
  end
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,locale}/**/*']
14
14
 
15
- s.add_dependency 'avm', '~> 0.64', '>= 0.64.2'
16
- s.add_dependency 'avm-files', '~> 0.6'
15
+ s.add_dependency 'avm', '~> 0.67', '>= 0.67.1'
16
+ s.add_dependency 'avm-files', '~> 0.6', '>= 0.6.2'
17
17
  s.add_dependency 'eac_git', '~> 0.14', '>= 0.14.1'
18
18
  s.add_dependency 'eac_ruby_utils', '~> 0.112'
19
19
  s.add_dependency 'git', '~> 1.18'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Git
5
- VERSION = '0.13.1'
5
+ VERSION = '0.13.2'
6
6
  end
7
7
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/interface_methods'
5
+ require 'eac_templates/abstract/fs_object'
6
+ require 'eac_templates/variables/directory'
7
+
8
+ module EacTemplates
9
+ module Abstract
10
+ class Directory < ::EacTemplates::Abstract::FsObject
11
+ enable_abstract_methods
12
+ delegate(*::EacTemplates::InterfaceMethods::DIRECTORY - %i[child chidren], to: :applier)
13
+
14
+ # @param basename [Pathname]
15
+ # @return [EacTemplates::Abstract::FsObject
16
+ def build_child(child_basename, child_type)
17
+ child_basename = child_basename.to_pathname
18
+ child_type = type_list.value_validate!(child_type)
19
+ category_module.const_get(child_type.to_s.camelize)
20
+ .new(owner, self, child_basename, options)
21
+ end
22
+
23
+ # @param basename [Pathname]
24
+ # @return [EacTemplates::Abstract::FsObject]
25
+ def child(basename)
26
+ basename = basename.to_pathname
27
+ children.find { |c| c.basename == basename } ||
28
+ raise_not_found("No child found with basename \"#{basename}\"")
29
+ end
30
+
31
+ # @return [Enumerable<EacTemplates::Abstract::FsObject>]
32
+ def children
33
+ children_basenames.map { |c_basename, c_type| build_child(c_basename, c_type) }
34
+ end
35
+
36
+ # @return [Hash<Pathname, Symbol>]
37
+ def children_basenames
38
+ raise_abstract_method __method__
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/interface_methods'
5
+ require 'eac_templates/abstract/fs_object'
6
+ require 'eac_templates/variables/file'
7
+
8
+ module EacTemplates
9
+ module Abstract
10
+ class File < ::EacTemplates::Abstract::FsObject
11
+ enable_abstract_methods
12
+ delegate(*::EacTemplates::InterfaceMethods::FILE - %i[content path], to: :applier)
13
+
14
+ # @return [String]
15
+ def content
16
+ path.read
17
+ end
18
+
19
+ # @return [Pathname]
20
+ def path
21
+ raise_abstract_method __method__
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/abstract/fs_object_by_pathname'
5
+ require 'eac_templates/abstract/not_found_error'
6
+
7
+ module EacTemplates
8
+ module Abstract
9
+ class FsObject
10
+ class << self
11
+ # @param obj [Object]
12
+ # @return [EacTemplates::Abstract::FsObject, EacTemplates::Abstracts::FsObjectByPathname]
13
+ def assert(obj)
14
+ if obj.is_a?(self)
15
+ obj
16
+ else
17
+ ::EacTemplates::Abstract::FsObjectByPathname.new(obj)
18
+ end
19
+ end
20
+
21
+ # @param owner [Object]
22
+ # @param parent_object [Object, nil]
23
+ # @param subpath [Pathname]
24
+ # @return [EacTemplates::Abstract::FsObject]
25
+ def by_subpath(owner, parent_object, subpath, options = {})
26
+ r = nil
27
+ subpath.to_pathname.each_filename do |basename|
28
+ r = new(owner, parent_object, basename, options)
29
+ parent_object = r
30
+ end
31
+ r || raise("Subpath is empty: #{subpath}")
32
+ end
33
+ end
34
+
35
+ enable_abstract_methods
36
+ enable_simple_cache
37
+ enable_listable
38
+ lists.add_symbol :option, :source_set
39
+ lists.add_symbol :type, :directory, :file
40
+ common_constructor :owner, :parent_object, :basename, :options, default: [{}] do
41
+ self.basename = basename.present? ? basename.to_pathname : ::Pathname.new('')
42
+ self.options = ::EacTemplates::Abstract::FsObject.lists.option.hash_keys_validate!(options)
43
+ end
44
+
45
+ # @return [EacTemplates::Variables::Directory, EacTemplates::Variables::File]
46
+ def applier
47
+ applier_class.new(self)
48
+ end
49
+
50
+ # @return [Class]
51
+ def applier_class
52
+ ::EacTemplates::Variables.const_get(type.to_s.camelize)
53
+ end
54
+
55
+ # @return [Module]
56
+ def category_module
57
+ self.class.module_parent
58
+ end
59
+
60
+ # @return [Pathname]
61
+ def path_for_search
62
+ if parent_object.present?
63
+ parent_object.path_for_search.join(basename)
64
+ else
65
+ path_for_search_prefix.join(basename)
66
+ end
67
+ end
68
+
69
+ # @return [Pathname]
70
+ def path_for_search_prefix
71
+ raise_abstract_method __method__
72
+ end
73
+
74
+ def raise_not_found(message)
75
+ raise ::EacTemplates::Abstract::NotFoundError, message
76
+ end
77
+
78
+ # @return [EacTemplates::Sources::Set]
79
+ def source_set
80
+ options[OPTION_SOURCE_SET] || ::EacTemplates::Sources::Set.default
81
+ end
82
+
83
+ # @return [Symbol]
84
+ def type
85
+ type_list.value_validate!(self.class.name.demodulize.underscore.to_sym)
86
+ end
87
+
88
+ # @return [EacRubyUtils::Listable::SymbolList]
89
+ def type_list
90
+ ::EacTemplates::Abstract::FsObject.lists.type
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacTemplates
6
+ module Abstract
7
+ class FsObjectByPathname
8
+ common_constructor :path do
9
+ self.path = path.to_pathname
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacTemplates
4
+ module Abstract
5
+ class NotFoundError < ::RuntimeError
6
+ end
7
+ end
8
+ end