Class: Captify::TemplateLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/captify/template_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ TemplateLoader

Returns a new instance of TemplateLoader.



4
5
6
7
8
9
10
11
12
# File 'lib/captify/template_loader.rb', line 4

def initialize(opts={})
  @file_name_pattern   = opts.fetch(:file_name_pattern,   'template_bundle')
  @file_suffix_pattern = opts.fetch(:file_suffix_pattern, Gem.suffix_pattern)

  @load_path = opts.fetch(:load_path, $LOAD_PATH)
  @gem_spec  = opts.fetch(:gem_spec,  Gem::Specification)
  @kernel    = opts.fetch(:kernel,    Kernel)
  @file      = opts.fetch(:file,      File)
end

Instance Method Details

#find(template_name) ⇒ Object



20
21
22
# File 'lib/captify/template_loader.rb', line 20

def find(template_name)
  Captify::TemplateRegistrar.instance.find template_name
end

#reload!(load_path_only = false) ⇒ Object



14
15
16
17
18
# File 'lib/captify/template_loader.rb', line 14

def reload!(load_path_only=false)
  latest_files(@file_name_pattern, load_path_only).each do |path|
    @kernel.load path if @file.exist? path
  end
end