Module: Avm::Sources::Base::Subs
- Defined in:
- lib/avm/sources/base/subs.rb
Constant Summary collapse
- CONFIGURATION_SUBS_EXCLUDE_PATHS_KEY =
'subs.exclude_path'
- CONFIGURATION_SUBS_INCLUDE_PATHS_KEY =
'subs.include_path'
- SUBS_EXCLUDE_PATHS_DEFAULT =
[].freeze
- SUBS_INCLUDE_PATHS_DEFAULT =
['sub/*'].freeze
Instance Method Summary collapse
- #sub(sub_path) ⇒ Avm::Sources::Base::Sub
- #sub_for_path(path) ⇒ Avm::Sources::Base?
- #subs ⇒ Enumerable<Avm::Sources::Base>
- #subs_paths_to_search ⇒ Object
Instance Method Details
#sub(sub_path) ⇒ Avm::Sources::Base::Sub
23 24 25 |
# File 'lib/avm/sources/base/subs.rb', line 23 def sub(sub_path) ::Avm::Sources::Base::Sub.new(self, sub_path) end |
#sub_for_path(path) ⇒ Avm::Sources::Base?
17 18 19 |
# File 'lib/avm/sources/base/subs.rb', line 17 def sub_for_path(path) subs.lazy.map { |sub| path..child_of?(sub.path) ? sub : nil }.find(&:present?) end |
#subs ⇒ Enumerable<Avm::Sources::Base>
28 29 30 31 32 33 |
# File 'lib/avm/sources/base/subs.rb', line 28 def subs subs_paths_to_search .map { |sub_path| ::Avm::Registry.sources.detect_optional(sub_path, parent: self) } .compact_blank .sort_by { |sub| [sub.path] } end |
#subs_paths_to_search ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/avm/sources/base/subs.rb', line 35 def subs_paths_to_search subs_include_paths.flat_map do |subs_include_path| ::Pathname.glob(path.join(subs_include_path)).reject do |sub_path| subs_exclude_paths.any? do |subs_exclude_path| sub_path.fnmatch?(path.join(subs_exclude_path).to_path) end end end end |