Class: Captify::TemplateBundle
- Inherits:
-
Object
- Object
- Captify::TemplateBundle
- Defined in:
- lib/captify/template_bundle.rb
Class Method Summary collapse
- .find_base_path(caller_file_path, root = "/") ⇒ Object
- .find_templates_path(caller_file_path, root = "/") ⇒ Object
- .register ⇒ Object
Class Method Details
.find_base_path(caller_file_path, root = "/") ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/captify/template_bundle.rb', line 15 def self.find_base_path(caller_file_path, root="/") base_path = File.dirname(File.(caller_file_path)) default_base_path = base_path while base_path && File.directory?(base_path) && !File.exist?(File.join(base_path,'lib')) parent = File.dirname base_path if parent == root base_path = default_base_path break end base_path = parent end return base_path end |
.find_templates_path(caller_file_path, root = "/") ⇒ Object
10 11 12 13 |
# File 'lib/captify/template_bundle.rb', line 10 def self.find_templates_path(caller_file_path, root="/") base_path = find_base_path(caller_file_path, root) File.join(base_path, 'templates') end |
.register ⇒ Object
5 6 7 8 |
# File 'lib/captify/template_bundle.rb', line 5 def self.register templates_path = find_templates_path(file_path(Kernel.caller.first)) TemplateRegistrar.instance.register_templates_in_dir templates_path end |