lib/ronin/templates/template.rb in ronin-support-0.1.0 vs lib/ronin/templates/template.rb in ronin-support-0.2.0.rc1
- old
+ new
@@ -35,10 +35,12 @@
# A stack of directories to search for other templates within.
#
# @return [Array]
# The stack of directory paths.
#
+ # @api semipublic
+ #
def template_dirs
@template_dirs ||= []
end
#
@@ -47,10 +49,12 @@
#
# @return [String, nil]
# Returns the first path in {#template_dirs}, or `nil` if
# {#template_dirs} is empty.
#
+ # @api semipublic
+ #
def template_dir
template_dirs.first
end
#
@@ -66,10 +70,12 @@
# template could not be found.
#
# @example
# find_template 'sub/path/template.erb'
#
+ # @api semipublic
+ #
def find_template(sub_path)
sub_path = sub_path.to_s
if template_dir
path = File.expand_path(File.join(template_dir,sub_path))
@@ -105,10 +111,12 @@
# @example
# enter_template('sub/path/template.erb') do |path|
# # do stuff with the full path
# end
#
+ # @api semipublic
+ #
def enter_template(sub_path)
sub_path = sub_path.to_s
unless (path = find_template(sub_path))
raise(RuntimeError,"could not find template #{sub_path.dump}")
@@ -140,9 +148,11 @@
#
# @example Calling read_template with a block
# read_template 'path/to/_include.txt' do |contents|
# # ...
# end
+ #
+ # @api semipublic
#
def read_template(template_path)
enter_template(template_path) do |path|
contents = File.read(path)