Skip to content

Commit

Permalink
Align builder class method names with POSIX shell commands
Browse files Browse the repository at this point in the history
- Renamed 'setenv' and 'set_script' methods in the Builder class to 'export' and 'exec' respectively.
- This change aligns method names in the Builder's DSL with POSIX shell command names, enhancing consistency and intuitiveness.
  • Loading branch information
shinokaro committed Jun 13, 2024
1 parent 84553c6 commit afd621b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions bin/ocran
Original file line number Diff line number Diff line change
Expand Up @@ -757,13 +757,13 @@ EOF
# built in a bundle exec environment, particularly for Ruby 3.2 and later where
# absolute paths are included in RUBYOPT.
# In the future, we plan to implement a more appropriate solution.
builder.setenv("RUBYOPT", Ocran.rubyopt.gsub(%r(-r#{Regexp.escape(RbConfig::TOPDIR)}(/.*/bundler/setup)), ""))
builder.setenv("RUBYLIB", load_path.uniq.join(";"))
builder.setenv("GEM_PATH", TEMPDIR_ROOT / GEMHOMEDIR)
builder.export("RUBYOPT", Ocran.rubyopt.gsub(%r(-r#{Regexp.escape(RbConfig::TOPDIR)}(/.*/bundler/setup)), ""))
builder.export("RUBYLIB", load_path.uniq.join(";"))
builder.export("GEM_PATH", TEMPDIR_ROOT / GEMHOMEDIR)

# Add the opcode to launch the script
installed_ruby_exe = BINDIR / Ocran.ruby_executable
builder.set_script(installed_ruby_exe, target_script, *Ocran.arg)
builder.exec(installed_ruby_exe, target_script, *Ocran.arg)
end

unless Ocran.inno_script
Expand Down
8 changes: 4 additions & 4 deletions lib/ocran/inno_setup_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ def touch(target)

# Specifies the final application script to be launched, which can be called
# from any position in the data stream. It cannot be specified more than once.
def set_script(image, script, *argv)
def exec(image, script, *argv)
if @script_info
raise "Script is already set"
end
@script_info = true

@launcher.set_script(image, script, *argv)
@launcher.exec(image, script, *argv)
extra_argc = argv.map { |arg| quote_and_escape(arg) }.join(" ")
Ocran.verbose_msg "p #{image} #{script} #{show_path extra_argc}"
end

def setenv(name, value)
@launcher.setenv(name, value)
def export(name, value)
@launcher.export(name, value)
Ocran.verbose_msg "e #{name} #{show_path value}"
end

Expand Down
4 changes: 2 additions & 2 deletions lib/ocran/launcher_batch_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def build
end
end

def setenv(name, value)
def export(name, value)
@environments[name] = value
end

def set_script(executable, script, *args)
def exec(executable, script, *args)
@executable, @script, @args = executable, script, args
end

Expand Down
4 changes: 2 additions & 2 deletions lib/ocran/stub_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def touch(tgt)
# You can omit setting OP_SET_SCRIPT without issues, in which case
# the stub terminates without launching anything after performing other
# runtime operations.
def set_script(image, script, *argv)
def exec(image, script, *argv)
if @script_set
raise "Script is already set"
end
Expand All @@ -148,7 +148,7 @@ def set_script(image, script, *argv)
write_string_array(convert_to_native(image), convert_to_native(script), *argv)
end

def setenv(name, value)
def export(name, value)
Ocran.verbose_msg "e #{name} #{show_path value}"
write_opcode(OP_SETENV)
write_string(name.to_s)
Expand Down

0 comments on commit afd621b

Please sign in to comment.