Sha256: 4cce6752325c1fce16e26cb7e758e0794512c98fa96d3f90f75ad92774643456
Contents?: true
Size: 1.05 KB
Versions: 38
Compression:
Stored size: 1.05 KB
Contents
class Ree::TemplateDetector DEFAULT_TEMPLATES_DIRECTORY = File.expand_path(__dir__) def initialize(project_path) @all_templates_directory ||= File.join(project_path, ".ree", "templates") end def detect_template_folder(template_name) template_path = [@all_templates_directory, DEFAULT_TEMPLATES_DIRECTORY] .map {|dir| File.join(dir, template_name.to_s)} .detect {|dir| Dir.exist?(dir)} raise Ree::Error.new('Template does not exist') if template_path.nil? template_path end def gem_template_folder(template_name) File.join(DEFAULT_TEMPLATES_DIRECTORY, template_name.to_s) end def project_template_folder(template_name) File.join(@all_templates_directory, template_name.to_s) end def template_file_path(template_name, relative_path) file_path = [detect_template_folder(template_name), DEFAULT_TEMPLATES_DIRECTORY] .map {|folder| File.join(folder, relative_path)} .detect {|file| File.exist?(file)} raise Ree::Error.new('Template does not exist') if file_path.nil? file_path end end
Version data entries
38 entries across 38 versions & 1 rubygems