class Bundlegem::TemplateManager
This class handles the logic for finding templates in the user's dir, the gem's builtin templates (and on the web some day)
Public Class Methods
create_new_template(template_name)
click to toggle source
# File lib/bundlegem/template_manager.rb, line 12 def create_new_template(template_name) end
file_in_source?(target)
click to toggle source
Get's path to 'target' from within the gem's “templates” folder within the gem's source
# File lib/bundlegem/template_manager.rb, line 52 def file_in_source?(target) src_in_source_path = "#{File.dirname(__FILE__)}/templates/#{target}" File.exists?(src_in_source_path) end
find_in_source_paths(target)
click to toggle source
EDIT: Reworked from Thor to not rely on Thor (or do so much unneeded stuff)
# File lib/bundlegem/template_manager.rb, line 44 def find_in_source_paths(target) src_in_source_path = "#{File.dirname(__FILE__)}/templates/#{target}" return src_in_source_path if File.exists?(src_in_source_path) target # failed, hopefully full path to a user specified gem template file end
get_default_template_name()
click to toggle source
# File lib/bundlegem/template_manager.rb, line 17 def get_default_template_name "newgem" end
get_internal_template_location()
click to toggle source
# File lib/bundlegem/template_manager.rb, line 33 def get_internal_template_location File.expand_path("#{File.dirname(__FILE__)}/templates") end
get_template_src(options)
click to toggle source
# File lib/bundlegem/template_manager.rb, line 21 def get_template_src(options) template_name = options["template"].nil? ? get_default_template_name : options["template"] if template_exists_within_repo?(template_name) template_location = get_internal_template_location else template_location = File.expand_path("~/.bundlegem/templates") end template_src = "#{template_location}/#{template_name}" end
template_exists_within_repo?(template_name)
click to toggle source
# File lib/bundlegem/template_manager.rb, line 37 def template_exists_within_repo?(template_name) TemplateManager.file_in_source?(template_name) end