eac_templates 0.3.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/eac_templates/abstract/directory.rb +42 -0
  3. data/lib/eac_templates/abstract/file.rb +25 -0
  4. data/lib/eac_templates/abstract/fs_object.rb +94 -0
  5. data/lib/eac_templates/abstract/fs_object_by_pathname.rb +13 -0
  6. data/lib/eac_templates/abstract/not_found_error.rb +8 -0
  7. data/lib/eac_templates/core_ext.rb +1 -1
  8. data/lib/eac_templates/interface_methods.rb +12 -0
  9. data/lib/eac_templates/modules/ancestor/directory.rb +17 -0
  10. data/lib/eac_templates/modules/ancestor/file.rb +16 -0
  11. data/lib/eac_templates/modules/ancestor/fs_object.rb +25 -0
  12. data/lib/eac_templates/modules/ancestor.rb +51 -0
  13. data/lib/eac_templates/modules/base.rb +35 -0
  14. data/lib/eac_templates/modules.rb +9 -0
  15. data/lib/eac_templates/patches/module/template.rb +2 -3
  16. data/lib/eac_templates/sources/directory.rb +37 -0
  17. data/lib/eac_templates/sources/file.rb +13 -0
  18. data/lib/eac_templates/sources/from_all_gems.rb +4 -0
  19. data/lib/eac_templates/sources/from_gem.rb +37 -0
  20. data/lib/eac_templates/sources/fs_object.rb +53 -0
  21. data/lib/eac_templates/sources/internal_set.rb +22 -0
  22. data/lib/eac_templates/sources/set.rb +55 -0
  23. data/lib/eac_templates/sources/single.rb +29 -0
  24. data/lib/eac_templates/sources.rb +9 -0
  25. data/lib/eac_templates/variables/content.rb +52 -0
  26. data/lib/eac_templates/variables/directory.rb +49 -0
  27. data/lib/eac_templates/variables/file.rb +26 -0
  28. data/lib/eac_templates/variables/fs_object.rb +65 -0
  29. data/lib/eac_templates/variables/not_found_error.rb +7 -0
  30. data/lib/eac_templates/variables/providers/base.rb +23 -0
  31. data/lib/eac_templates/variables/providers/config_reader.rb +29 -0
  32. data/lib/eac_templates/variables/providers/entries_reader.rb +25 -0
  33. data/lib/eac_templates/variables/providers/generic.rb +25 -0
  34. data/lib/eac_templates/variables/providers/hash.rb +29 -0
  35. data/lib/eac_templates/variables/providers.rb +25 -0
  36. data/lib/eac_templates/variables.rb +9 -0
  37. data/lib/eac_templates/version.rb +1 -1
  38. metadata +39 -30
  39. data/lib/eac_templates/directory.rb +0 -108
  40. data/lib/eac_templates/file.rb +0 -48
  41. data/lib/eac_templates/from_all_gems.rb +0 -4
  42. data/lib/eac_templates/from_gem.rb +0 -35
  43. data/lib/eac_templates/searcher.rb +0 -53
  44. data/lib/eac_templates/variable_not_found_error.rb +0 -5
  45. data/lib/eac_templates/variable_providers/base.rb +0 -21
  46. data/lib/eac_templates/variable_providers/config_reader.rb +0 -27
  47. data/lib/eac_templates/variable_providers/entries_reader.rb +0 -23
  48. data/lib/eac_templates/variable_providers/generic.rb +0 -23
  49. data/lib/eac_templates/variable_providers/hash.rb +0 -27
  50. data/lib/eac_templates/variable_providers.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63916b49b6fe5333356bcfa18ed5b3118fb784ffad1ba65d14312a2eafad7a54
4
- data.tar.gz: 0a5e61d751f1bf2194f24623c958134f36f27548bbe0b6e956fe1c80e0f0d024
3
+ metadata.gz: a7a7b07116547967179751347b5600225f96205ee1b1da0fc7bb35d795439fdc
4
+ data.tar.gz: 04cbf8ec7ee2fd753d25a171925bf1d45f61850c2c0ae5f794894f1494be60c6
5
5
  SHA512:
6
- metadata.gz: df42a3b2ec8c86b5b71d0f9713c56e04efa9b8da6533c9858debb610bc1a2a4be6d15dd970ff2b52f10cfc2c18850cfaa1762951b69737a22f7befe0045b7e34
7
- data.tar.gz: 299b5c3aa4ac068d4c598990e41d367c8803cd47fed01a7efa8e49f8372fea4acd20d8b03a7dc4da9394949e87e204d839c39ce03de61b7e39cd7647c22092d3
6
+ metadata.gz: 003734ea51a3c498ee9a49413c0d59a08f48be07183b88491f283eee82cae5beae103a307eb1e7d4c98cfb48c8c720cdf0f4c1b32ebf7ea5861de76d4aeeed16
7
+ data.tar.gz: 48876f4adbbb31f1e34d1593b931c5ac6c62b3525cd626c05aecb1a64adc7eacde058fb46a6a74038de2b3de0a0b866b4c9ba6199f7cde355856fb48e59f831d
@@ -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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_templates/patches'
4
- require 'eac_templates/from_all_gems'
4
+ require 'eac_templates/sources/from_all_gems'
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacTemplates
4
+ module InterfaceMethods
5
+ COMMON = %i[apply path].freeze
6
+ ONLY_DIRECTORY = %i[child children].freeze
7
+ DIRECTORY = COMMON + ONLY_DIRECTORY
8
+ ONLY_FILE = %i[apply_to_file content variables].freeze
9
+ FILE = COMMON + ONLY_FILE
10
+ ALL = COMMON + ONLY_DIRECTORY + ONLY_FILE
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/abstract/directory'
5
+ require 'eac_templates/interface_methods'
6
+ require 'eac_templates/modules/ancestor/fs_object'
7
+
8
+ module EacTemplates
9
+ module Modules
10
+ class Ancestor
11
+ class Directory < ::EacTemplates::Abstract::Directory
12
+ include ::EacTemplates::Modules::Ancestor::FsObject
13
+ delegate :children_basenames, to: :source_object
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/abstract/file'
5
+ require 'eac_templates/interface_methods'
6
+ require 'eac_templates/modules/ancestor/fs_object'
7
+
8
+ module EacTemplates
9
+ module Modules
10
+ class Ancestor
11
+ class File < ::EacTemplates::Abstract::File
12
+ include ::EacTemplates::Modules::Ancestor::FsObject
13
+ end
14
+ end
15
+ end
16
+ 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
+
6
+ module EacTemplates
7
+ module Modules
8
+ class Ancestor
9
+ module FsObject
10
+ delegate :found?, :path, to: :source_object
11
+
12
+ # @return [Pathname]
13
+ def path_for_search_prefix
14
+ owner.path_for_search
15
+ end
16
+
17
+ private
18
+
19
+ def source_object_uncached
20
+ owner.source_set.send(type, path_for_search)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/interface_methods'
5
+ require 'eac_templates/abstract/not_found_error'
6
+
7
+ module EacTemplates
8
+ module Modules
9
+ class Ancestor
10
+ class << self
11
+ # @param a_module [Module]
12
+ # @return [Pathname]
13
+ def path_for_search(a_module)
14
+ a_module.name.underscore.to_pathname
15
+ end
16
+ end
17
+
18
+ common_constructor :base, :ancestor
19
+ delegate :subpath, :source_set, to: :base
20
+ delegate(*::EacTemplates::InterfaceMethods::ALL, to: :source_object)
21
+
22
+ # @return [EacTemplates::Modules::Directory]
23
+ def directory
24
+ @directory ||= ::EacTemplates::Modules::Ancestor::Directory
25
+ .new(self, nil, nil, source_set: source_set)
26
+ end
27
+
28
+ # @return [EacTemplates::Modules::File]
29
+ def file
30
+ @file ||= ::EacTemplates::Modules::Ancestor::File
31
+ .new(self, nil, nil, source_set: source_set)
32
+ end
33
+
34
+ # @return [Pathname]
35
+ def path_for_search
36
+ r = self.class.path_for_search(ancestor)
37
+ subpath.if_present(r) { |v| r.join(v) }
38
+ end
39
+
40
+ # @return [EacTemplates::Modules::Ancestor::FsObject]
41
+ def source_object
42
+ return file if file.found?
43
+ return directory if directory.found?
44
+
45
+ raise ::EacTemplates::Abstract::NotFoundError, "No template found: #{path_for_search}"
46
+ end
47
+
48
+ require_sub __FILE__
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/interface_methods'
5
+ require 'eac_templates/modules/ancestor'
6
+ require 'eac_templates/sources/set'
7
+
8
+ module EacTemplates
9
+ module Modules
10
+ class Base
11
+ enable_listable
12
+ lists.add_symbol :option, :source_set, :subpath
13
+ common_constructor :the_module, :options, default: [{}] do
14
+ self.options = self.class.lists.option.hash_keys_validate!(options)
15
+ end
16
+ delegate(*::EacTemplates::InterfaceMethods::ALL, :path_for_search, :source_object,
17
+ to: :self_ancestor)
18
+
19
+ # @return [EacTemplates::Modules::Ancestor]
20
+ def self_ancestor
21
+ @self_ancestor ||= ::EacTemplates::Modules::Ancestor.new(self, the_module)
22
+ end
23
+
24
+ # @return [EacTemplates::SourceSet]
25
+ def source_set
26
+ options[OPTION_SOURCE_SET] || ::EacTemplates::Sources::Set.default
27
+ end
28
+
29
+ # @return [Pathname, nil]
30
+ def subpath
31
+ options[OPTION_SUBPATH].if_present(&:to_pathname)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacTemplates
6
+ module Modules
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/string/inflections'
4
- require 'eac_templates/searcher'
3
+ require 'eac_templates/modules/base'
5
4
 
6
5
  class Module
7
6
  def template
8
- @template ||= ::EacTemplates::Searcher.default.template(name.underscore)
7
+ @template ||= ::EacTemplates::Modules::Base.new(self)
9
8
  end
10
9
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/abstract/directory'
5
+ require 'eac_templates/sources/fs_object'
6
+
7
+ module EacTemplates
8
+ module Sources
9
+ class Directory < ::EacTemplates::Abstract::Directory
10
+ include ::EacTemplates::Sources::FsObject
11
+
12
+ # @return [Hash<Pathname, Symbol>]
13
+ def children_basenames
14
+ r = {}
15
+ real_paths.each do |real_path|
16
+ real_path.children.each do |child|
17
+ next if r.key?(child.basename)
18
+
19
+ r[child.basename] = real_path_type(child)
20
+ end
21
+ end
22
+ r
23
+ end
24
+
25
+ # @return [Pathname]
26
+ def real_path_type(path)
27
+ if path.file?
28
+ :file
29
+ elsif path.directory?
30
+ :directory
31
+ else
32
+ raise "Path \"#{path}\" is not a file nor a directory"
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/abstract/file'
5
+ require 'eac_templates/sources/fs_object'
6
+
7
+ module EacTemplates
8
+ module Sources
9
+ class File < ::EacTemplates::Abstract::File
10
+ include ::EacTemplates::Sources::FsObject
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/sources/from_gem'
4
+ ::EacTemplates::Sources::FromGem.include_all
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/sources/set'
4
+
5
+ module EacTemplates
6
+ module Sources
7
+ class FromGem
8
+ class << self
9
+ def include_all(searcher = nil)
10
+ ::Gem::Specification.each { |gemspec| new(gemspec, searcher).include }
11
+ end
12
+ end
13
+
14
+ TEMPLATES_DIR_SUBPATH = 'template'
15
+
16
+ common_constructor :gemspec, :searcher, default: [nil] do
17
+ self.searcher ||= ::EacTemplates::Sources::Set.default
18
+ end
19
+
20
+ # @return [Boolean]
21
+ delegate :exist?, to: :path
22
+
23
+ # @return [Pathname]
24
+ def include
25
+ return nil unless exist?
26
+
27
+ searcher.included_paths << path
28
+ path
29
+ end
30
+
31
+ # @return [Pathname]
32
+ def path
33
+ gemspec.gem_dir.to_pathname.join(TEMPLATES_DIR_SUBPATH)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/abstract/not_found_error'
5
+
6
+ module EacTemplates
7
+ module Sources
8
+ module FsObject
9
+ PATH_FOR_SEARCH_PREFIX = ::Pathname.new('')
10
+
11
+ common_concern do
12
+ enable_abstract_methods
13
+ enable_simple_cache
14
+ end
15
+
16
+ # @return [Boolean]
17
+ def found?
18
+ real_paths.any?
19
+ end
20
+
21
+ # @return [Pathname]
22
+ def path
23
+ real_paths.first
24
+ end
25
+
26
+ # @return [Pathname]
27
+ def path_for_search_prefix
28
+ PATH_FOR_SEARCH_PREFIX
29
+ end
30
+
31
+ protected
32
+
33
+ # @return [Array<Pathname>]
34
+ def real_paths_uncached
35
+ source_set.included_paths.lazy.map { |source_single| source_single_search(source_single) }
36
+ .select(&:present?)
37
+ end
38
+
39
+ # @param path [Pathname]
40
+ # @return [Boolean]
41
+ def select_path?(path)
42
+ path.present? && path.send("#{type}?")
43
+ end
44
+
45
+ # @param source_single [EacTemplates::Sources::Single]
46
+ # @return [Pathname, nil]
47
+ def source_single_search(source_single)
48
+ r = source_single.search(path_for_search)
49
+ select_path?(r) ? r : nil
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/sources/single'
5
+
6
+ module EacTemplates
7
+ module Sources
8
+ class InternalSet < ::Set
9
+ # @param single [EacTemplates::Sources::Single]
10
+ # @return [self]
11
+ def add(single)
12
+ super(::EacTemplates::Sources::Single.assert(single))
13
+ end
14
+
15
+ # @param single [EacTemplates::Sources::Single]
16
+ # @return [self]
17
+ def <<(single)
18
+ add(single)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+ require 'eac_templates/sources/directory'
5
+ require 'eac_templates/sources/file'
6
+ require 'eac_templates/sources/internal_set'
7
+ require 'eac_templates/abstract/not_found_error'
8
+
9
+ module EacTemplates
10
+ module Sources
11
+ class Set
12
+ class << self
13
+ def default
14
+ @default ||= new
15
+ end
16
+ end
17
+
18
+ # @param subpath [Pathname]
19
+ # @return [EacTemplates::Sources::Directory]
20
+ def directory(subpath)
21
+ ::EacTemplates::Sources::Directory.by_subpath(self, nil, subpath, source_set: self)
22
+ end
23
+
24
+ # @param subpath [Pathname]
25
+ # @return [EacTemplates::Sources::Directory]
26
+ def file(subpath)
27
+ ::EacTemplates::Sources::File.by_subpath(self, nil, subpath, source_set: self)
28
+ end
29
+
30
+ def template(subpath, required = true)
31
+ found_file = file(subpath)
32
+ return found_file if found_file.found?
33
+
34
+ found_directory = directory(subpath)
35
+ return found_directory if found_directory.found?
36
+
37
+ return nil unless required
38
+
39
+ raise_template_not_found(subpath)
40
+ end
41
+
42
+ # @return [EacTemplates::Sources::InternalSet]
43
+ def included_paths
44
+ @included_paths ||= ::EacTemplates::Sources::InternalSet.new
45
+ end
46
+
47
+ private
48
+
49
+ def raise_template_not_found(subpath)
50
+ raise ::EacTemplates::Abstract::NotFoundError, 'Template not found for subpath ' \
51
+ "\"#{subpath}\" (Included paths: #{included_paths.to_a.join(::File::PATH_SEPARATOR)})"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacTemplates
6
+ module Sources
7
+ class Single
8
+ class << self
9
+ # @param object [EacTemplates::Sources::Single, Pathname]
10
+ # @return [EacTemplates::Sources::Single]
11
+ def assert(object)
12
+ return object if object.is_a?(self)
13
+
14
+ new(object.to_pathname)
15
+ end
16
+ end
17
+
18
+ common_constructor :path do
19
+ self.path = path.to_pathname.expand_path
20
+ end
21
+
22
+ # @return [Pathname, nil]
23
+ def search(subpath)
24
+ r = path.join(subpath)
25
+ r.exist? ? r : nil
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacTemplates
6
+ module Sources
7
+ require_sub __FILE__
8
+ end
9
+ end