Class: RubyInstaller::Build::ErbCompiler
- Inherits:
-
Object
- Object
- RubyInstaller::Build::ErbCompiler
- Includes:
- Utils
- Defined in:
- lib/ruby_installer/build/erb_compiler.rb
Defined Under Namespace
Classes: Box
Constant Summary
Constants included from Utils
Utils::GEM_ROOT, Utils::WINDOWS_CMD_SHEBANG
Instance Attribute Summary collapse
-
#erb_filename ⇒ Object
readonly
Returns the value of attribute erb_filename.
-
#erb_filename_abs ⇒ Object
readonly
Returns the value of attribute erb_filename_abs.
Instance Method Summary collapse
-
#initialize(erb_file_rel, result_file_rel = nil) ⇒ ErbCompiler
constructor
A new instance of ErbCompiler.
- #result(task = nil) ⇒ Object
- #result_filename ⇒ Object
- #write_result(task = nil, filename = nil) ⇒ Object
Methods included from Utils
#eval_file, #gem_expand_file, #msys_sh, #ovl_compile_erb, #ovl_expand_file, #ovl_glob, #ovl_read_file, #q_inno, #rubyinstaller_build_gem_files, #with_env
Constructor Details
#initialize(erb_file_rel, result_file_rel = nil) ⇒ ErbCompiler
Returns a new instance of ErbCompiler.
36 37 38 39 40 41 42 |
# File 'lib/ruby_installer/build/erb_compiler.rb', line 36 def initialize(erb_file_rel, result_file_rel=nil) @erb_filename = erb_file_rel @erb_filename_abs = (erb_file_rel) @erb = ERB.new(File.read(@erb_filename_abs, encoding: "UTF-8")) @result_file_rel = result_file_rel || erb_file_rel.sub(/\.erb$/, "") @erb.filename = @result_file_rel end |
Instance Attribute Details
#erb_filename ⇒ Object (readonly)
Returns the value of attribute erb_filename.
33 34 35 |
# File 'lib/ruby_installer/build/erb_compiler.rb', line 33 def erb_filename @erb_filename end |
#erb_filename_abs ⇒ Object (readonly)
Returns the value of attribute erb_filename_abs.
34 35 36 |
# File 'lib/ruby_installer/build/erb_compiler.rb', line 34 def erb_filename_abs @erb_filename_abs end |
Instance Method Details
#result(task = nil) ⇒ Object
48 49 50 51 |
# File 'lib/ruby_installer/build/erb_compiler.rb', line 48 def result(task=nil) box = Box.new(self, task) @erb.result(box.binding) end |
#result_filename ⇒ Object
44 45 46 |
# File 'lib/ruby_installer/build/erb_compiler.rb', line 44 def result_filename @result_file_rel end |
#write_result(task = nil, filename = nil) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/ruby_installer/build/erb_compiler.rb', line 53 def write_result(task=nil, filename=nil) filename ||= result_filename FileUtils.mkdir_p File.dirname(filename) File.binwrite(filename, result(task)) filename end |