Class: EacTemplates::Searcher
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
10 11 12 |
# File 'lib/eac_templates/searcher.rb', line 10 def default @default ||= new end |
Instance Method Details
#included_paths ⇒ Object
37 38 39 |
# File 'lib/eac_templates/searcher.rb', line 37 def included_paths @included_paths ||= ::Set.new end |
#template(subpath, required = true) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eac_templates/searcher.rb', line 15 def template(subpath, required = true) path = template_path(subpath) if path.blank? return nil unless required raise_template_not_found(subpath) end return ::EacTemplates::File.new(path) if ::File.file?(path) return ::EacTemplates::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.
29 30 31 32 33 34 35 |
# File 'lib/eac_templates/searcher.rb', line 29 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 |