class StaticShellTemplates::Template
Constants
- CLOSING
- OPENING
Public Class Methods
new(content, verbose: false)
click to toggle source
# File lib/static_shell_templates.rb, line 10 def initialize(content, verbose: false) @content = content @logger = Logger.new(STDOUT) @verbose = verbose end
Public Instance Methods
delete_end_end(content)
click to toggle source
# File lib/static_shell_templates.rb, line 22 def delete_end_end(content) content.gsub(/#{CLOSING}.*#{CLOSING}/m, CLOSING) end
includes()
click to toggle source
# File lib/static_shell_templates.rb, line 26 def includes @content.scan(/#{OPENING}.*$/).map do |tpl| Include.new tpl, @logger end end
replace()
click to toggle source
# File lib/static_shell_templates.rb, line 16 def replace delete_end_end(includes.reduce(@content) do |memo, inc| memo.gsub(inc.template, inc.output) end) end