Class: Ocran::LauncherBatchBuilder
- Inherits:
-
Object
- Object
- Ocran::LauncherBatchBuilder
- Includes:
- BuildConstants, WindowsCommandEscaping
- Defined in:
- lib/ocran/launcher_batch_builder.rb
Constant Summary collapse
- BATCH_FILE_DIR =
BATCH_FILE_DIR is a parameter expansion used in Windows batch files, representing the full path to the directory where the batch file resides. It allows for the use of pseudo-relative paths by referencing the batch file’s own location without changing the working directory.
"%~dp0"- BATCH_FILE_PATH =
BATCH_FILE_PATH is a parameter expansion used in Windows batch files, representing the full path to the batch file itself, including the file name.
"%~f0"
Constants included from BuildConstants
BuildConstants::BINDIR, BuildConstants::EXTRACT_ROOT, BuildConstants::GEMDIR, BuildConstants::LIBDIR, BuildConstants::SRCDIR
Instance Method Summary collapse
- #build ⇒ Object
- #exec(executable, script, *args) ⇒ Object
- #export(name, value) ⇒ Object
-
#initialize(chdir_before: nil, title: nil) ⇒ LauncherBatchBuilder
constructor
A new instance of LauncherBatchBuilder.
- #path ⇒ Object
Methods included from WindowsCommandEscaping
escape_double_quotes, quote_and_escape
Constructor Details
#initialize(chdir_before: nil, title: nil) ⇒ LauncherBatchBuilder
20 21 22 23 24 25 |
# File 'lib/ocran/launcher_batch_builder.rb', line 20 def initialize(chdir_before: nil, title: nil) @build_file = Tempfile.new @title = title @chdir_before = chdir_before @environments = {} end |
Instance Method Details
#build ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ocran/launcher_batch_builder.rb', line 27 def build @build_file.tap do |f| f.puts "@echo off" @environments.each { |name, val| f.puts build_set_command(name, val) } f.puts build_set_command("OCRAN_EXECUTABLE", BATCH_FILE_PATH) f.puts build_start_command(@title, @executable, @script, *@args, chdir_before: @chdir_before) f end.close path end |
#exec(executable, script, *args) ⇒ Object
46 47 48 |
# File 'lib/ocran/launcher_batch_builder.rb', line 46 def exec(executable, script, *args) @executable, @script, @args = executable, script, args end |
#export(name, value) ⇒ Object
42 43 44 |
# File 'lib/ocran/launcher_batch_builder.rb', line 42 def export(name, value) @environments[name] = value end |
#path ⇒ Object
38 39 40 |
# File 'lib/ocran/launcher_batch_builder.rb', line 38 def path @build_file.to_path end |