Class: EacRubyUtils::Templates::Searcher
- Defined in:
- lib/eac_ruby_utils/templates/searcher.rb
Class Method Summary collapse
Instance Method Summary collapse
- #included_paths ⇒ Object
- #template(subpath, required = true) ⇒ Object
-
#template_path(subpath) ⇒ Object
The absolute path of template if found,
nil
otherwise.
Class Method Details
.default ⇒ Object
11 12 13 |
# File 'lib/eac_ruby_utils/templates/searcher.rb', line 11 def default @default ||= new end |
Instance Method Details
#included_paths ⇒ Object
38 39 40 |
# File 'lib/eac_ruby_utils/templates/searcher.rb', line 38 def included_paths @included_paths ||= ::Set.new end |
#template(subpath, required = true) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/eac_ruby_utils/templates/searcher.rb', line 16 def template(subpath, required = true) path = template_path(subpath) if path.blank? return nil unless required raise_template_not_found(subpath) end return ::EacRubyUtils::Templates::File.new(path) if ::File.file?(path) return ::EacRubyUtils::Templates::Directory.new(path) if ::File.directory?(path) raise 'Invalid branching' end |
#template_path(subpath) ⇒ Object
Returns The absolute path of template if found, nil
otherwise.
30 31 32 33 34 35 36 |
# File 'lib/eac_ruby_utils/templates/searcher.rb', line 30 def template_path(subpath) included_paths.each do |included_path| r = search_template_in_included_path(included_path, subpath) return r if r end nil end |