From 8f6e072c9e7ee8204b31db2b20e5848ec080e1b1 Mon Sep 17 00:00:00 2001 From: shinokaro Date: Mon, 3 Jun 2024 01:11:03 +0900 Subject: [PATCH] Refactor windowed logic into a method in build_exe - Extract the windowed logic from build_exe into a new class method windowed?. - The windowed? method determines if the application should run in windowed mode based on the script extension and force flags. - This refactoring improves code readability and maintainability by encapsulating the logic in a dedicated method. --- bin/ocran | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/ocran b/bin/ocran index ce6d45b..c35da79 100644 --- a/bin/ocran +++ b/bin/ocran @@ -337,6 +337,10 @@ EOF end end + def self.windowed? + (Ocran.main_script.extname?(".rbw") || Ocran.force_windows) && !Ocran.force_console + end + def Ocran.init(argv) save_environment parseargs(argv) @@ -741,8 +745,6 @@ EOF executable = Ocran.output_executable - windowed = (Ocran.main_script.extname?(".rbw") || Ocran.force_windows) && !Ocran.force_console - Ocran.msg "Building #{executable}" target_script = nil direction = proc do |sb| @@ -772,7 +774,7 @@ EOF end # Add the ruby executable and DLL - rubyexe = windowed ? rubyw_exe : ruby_exe + rubyexe = Ocran.windowed? ? rubyw_exe : ruby_exe Ocran.msg "Adding ruby executable #{rubyexe}" sb.create_file(bindir / rubyexe, BINDIR / rubyexe) if libruby_so @@ -850,7 +852,7 @@ EOF debug_extract: Ocran.debug_extract, debug_mode: Ocran.debug, enable_compression: Ocran.lzma_mode, - gui_mode: windowed, + gui_mode: Ocran.windowed?, icon_path: Ocran.icon_filename, &direction) Ocran.msg "Finished building #{executable} (#{File.size(executable)} bytes)"