class Bashly::Script::Wrapper
Attributes
Public Class Methods
Source
# File lib/bashly/script/wrapper.rb, line 8 def initialize(command, function_name = nil) @command = command @function_name = function_name end
Public Instance Methods
Source
# File lib/bashly/script/wrapper.rb, line 13 def code(tab_indent: false) tab_indent ? base_code.expand_tabs : base_code end
Private Instance Methods
Source
# File lib/bashly/script/wrapper.rb, line 19 def base_code result = if function_name [header, render('wrapper')] else [header, body] end clean_code result.join("\n") end
Source
# File lib/bashly/script/wrapper.rb, line 53 def body @body ||= command.render 'master_script' end
Source
# File lib/bashly/script/wrapper.rb, line 29 def clean_code(script) result = script.remove_private_comments formatter = Formatter.new result, mode: Settings.formatter formatter.formatted_script end
Source
# File lib/bashly/script/wrapper.rb, line 57 def custom_header_path @custom_header_path ||= "#{Settings.source_dir}/header.#{Settings.partials_extension}" end
Source
# File lib/bashly/script/wrapper.rb, line 47 def default_header result = render 'header' result += render('bash3_bouncer') unless function_name || !Settings.enabled?(:bash3_bouncer) result end
Source
# File lib/bashly/script/wrapper.rb, line 39 def header! if File.exist? custom_header_path File.read custom_header_path else default_header end end