standalone-ruby 1.4.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -22
  3. data/lib/data/{tcc → c_compilers/tcc}/include/_mingw.h +54 -54
  4. data/lib/data/{tcc → c_compilers/tcc}/include/assert.h +71 -71
  5. data/lib/data/{tcc → c_compilers/tcc}/include/conio.h +159 -159
  6. data/lib/data/{tcc → c_compilers/tcc}/include/ctype.h +232 -232
  7. data/lib/data/{tcc → c_compilers/tcc}/include/dir.h +26 -26
  8. data/lib/data/{tcc → c_compilers/tcc}/include/direct.h +95 -95
  9. data/lib/data/{tcc → c_compilers/tcc}/include/dirent.h +96 -96
  10. data/lib/data/{tcc → c_compilers/tcc}/include/dos.h +110 -110
  11. data/lib/data/{tcc → c_compilers/tcc}/include/errno.h +117 -117
  12. data/lib/data/{tcc → c_compilers/tcc}/include/excpt.h +20 -20
  13. data/lib/data/{tcc → c_compilers/tcc}/include/fcntl.h +135 -135
  14. data/lib/data/{tcc → c_compilers/tcc}/include/fenv.h +85 -85
  15. data/lib/data/{tcc → c_compilers/tcc}/include/float.h +224 -224
  16. data/lib/data/{tcc → c_compilers/tcc}/include/inttypes.h +275 -275
  17. data/lib/data/{tcc → c_compilers/tcc}/include/io.h +296 -296
  18. data/lib/data/{tcc → c_compilers/tcc}/include/limits.h +115 -115
  19. data/lib/data/{tcc → c_compilers/tcc}/include/locale.h +100 -100
  20. data/lib/data/{tcc → c_compilers/tcc}/include/malloc.h +87 -87
  21. data/lib/data/{tcc → c_compilers/tcc}/include/math.h +438 -438
  22. data/lib/data/{tcc → c_compilers/tcc}/include/mem.h +8 -8
  23. data/lib/data/{tcc → c_compilers/tcc}/include/memory.h +9 -9
  24. data/lib/data/{tcc → c_compilers/tcc}/include/process.h +158 -158
  25. data/lib/data/{tcc → c_compilers/tcc}/include/setjmp.h +72 -72
  26. data/lib/data/{tcc → c_compilers/tcc}/include/share.h +44 -44
  27. data/lib/data/{tcc → c_compilers/tcc}/include/signal.h +111 -111
  28. data/lib/data/{tcc → c_compilers/tcc}/include/stdarg.h +16 -16
  29. data/lib/data/{tcc → c_compilers/tcc}/include/stdbool.h +10 -10
  30. data/lib/data/{tcc → c_compilers/tcc}/include/stddef.h +26 -26
  31. data/lib/data/{tcc → c_compilers/tcc}/include/stdint.h +184 -184
  32. data/lib/data/{tcc → c_compilers/tcc}/include/stdio.h +413 -413
  33. data/lib/data/{tcc → c_compilers/tcc}/include/stdlib.h +482 -482
  34. data/lib/data/{tcc → c_compilers/tcc}/include/string.h +206 -206
  35. data/lib/data/{tcc → c_compilers/tcc}/include/sys/fcntl.h +8 -8
  36. data/lib/data/{tcc → c_compilers/tcc}/include/sys/file.h +9 -9
  37. data/lib/data/{tcc → c_compilers/tcc}/include/sys/locking.h +52 -52
  38. data/lib/data/{tcc → c_compilers/tcc}/include/sys/stat.h +190 -190
  39. data/lib/data/{tcc → c_compilers/tcc}/include/sys/time.h +3 -3
  40. data/lib/data/{tcc → c_compilers/tcc}/include/sys/timeb.h +82 -82
  41. data/lib/data/{tcc → c_compilers/tcc}/include/sys/types.h +118 -118
  42. data/lib/data/{tcc/include → c_compilers/tcc/include/sys}/unistd.h +9 -10
  43. data/lib/data/{tcc → c_compilers/tcc}/include/sys/utime.h +89 -89
  44. data/lib/data/{tcc → c_compilers/tcc}/include/tchar.h +367 -367
  45. data/lib/data/{tcc → c_compilers/tcc}/include/time.h +219 -219
  46. data/lib/data/{tcc/include/sys → c_compilers/tcc/include}/unistd.h +10 -9
  47. data/lib/data/{tcc → c_compilers/tcc}/include/values.h +4 -4
  48. data/lib/data/{tcc → c_compilers/tcc}/include/varargs.h +11 -11
  49. data/lib/data/{tcc → c_compilers/tcc}/include/wchar.h +318 -318
  50. data/lib/data/{tcc → c_compilers/tcc}/include/wctype.h +127 -127
  51. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/basetsd.h +119 -119
  52. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/basetyps.h +144 -144
  53. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winbase.h +1852 -1852
  54. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/wincon.h +207 -207
  55. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/windef.h +240 -240
  56. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/windows.h +176 -176
  57. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winerror.h +1054 -1054
  58. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/wingdi.h +2843 -2843
  59. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winnetwk.h +346 -346
  60. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winnls.h +651 -651
  61. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winnt.h +2667 -2667
  62. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winreg.h +159 -159
  63. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winsvc.h +309 -309
  64. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winuser.h +3472 -3472
  65. data/lib/data/{tcc → c_compilers/tcc}/include/winapi/winver.h +133 -133
  66. data/lib/data/{tcc → c_compilers/tcc}/lib/gdi32.def +337 -337
  67. data/lib/data/{tcc → c_compilers/tcc}/lib/kernel32.def +763 -763
  68. data/lib/data/{tcc → c_compilers/tcc}/lib/msvcrt.def +782 -782
  69. data/lib/data/{tcc → c_compilers/tcc}/lib/user32.def +654 -654
  70. data/lib/data/{exe_template → exe_templates}/launcher_stub.c +2 -2
  71. data/lib/data/exe_templates/launcher_stub.cpp +31 -0
  72. data/lib/data/{vbs → launcher_templates/vbs}/default_vbs.txt +7 -7
  73. data/lib/data/{vbs → launcher_templates/vbs}/vbs_gui.txt +8 -8
  74. data/lib/data/resource_files/default.rc +17 -0
  75. data/lib/{utils/displayer.rb → displayer.rb} +6 -6
  76. data/lib/exe_packer.rb +68 -0
  77. data/lib/{utils/launcher.rb → launcher.rb} +18 -24
  78. data/lib/launcher_handler.rb +41 -0
  79. data/lib/parameter_parser.rb +201 -0
  80. data/lib/{utils/ruby_copy.rb → ruby_copy.rb} +0 -6
  81. data/lib/sfx_generator.rb +9 -0
  82. data/lib/standalone_ruby.rb +1 -1
  83. data/lib/version/version.rb +1 -1
  84. metadata +84 -87
  85. data/lib/data/bat-cmd/default_bat_cmd.txt +0 -9
  86. data/lib/data/exe_template/launcher_stub.cpp +0 -9
  87. data/lib/data/tcc/tiny_impdef.exe +0 -0
  88. data/lib/data/tcc/tiny_libmaker.exe +0 -0
  89. data/lib/utils/config_generator.rb +0 -5
  90. data/lib/utils/exe_packer.rb +0 -72
  91. data/lib/utils/launcher_handler.rb +0 -111
  92. data/lib/utils/logger_helper.rb +0 -24
  93. data/lib/utils/parameter_parser.rb +0 -211
  94. /data/lib/data/{tcc → c_compilers/tcc}/lib/libtcc1.a +0 -0
  95. /data/lib/data/{tcc → c_compilers/tcc}/tcc.exe +0 -0
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standalone-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arda Tetik
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-08 00:00:00.000000000 Z
10
+ date: 2025-04-13 00:00:00.000000000 Z
11
11
  dependencies: []
12
- description: Make your projects installation independent!
12
+ description: Convert your Ruby projects to exe files!
13
13
  email:
14
14
  - ardatetik1881@gmail.com
15
15
  executables:
@@ -19,91 +19,88 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - CHANGELOG.md
21
21
  - bin/standalone-ruby
22
- - lib/data/bat-cmd/default_bat_cmd.txt
23
- - lib/data/exe_template/launcher_stub.c
24
- - lib/data/exe_template/launcher_stub.cpp
25
- - lib/data/tcc/include/_mingw.h
26
- - lib/data/tcc/include/assert.h
27
- - lib/data/tcc/include/conio.h
28
- - lib/data/tcc/include/ctype.h
29
- - lib/data/tcc/include/dir.h
30
- - lib/data/tcc/include/direct.h
31
- - lib/data/tcc/include/dirent.h
32
- - lib/data/tcc/include/dos.h
33
- - lib/data/tcc/include/errno.h
34
- - lib/data/tcc/include/excpt.h
35
- - lib/data/tcc/include/fcntl.h
36
- - lib/data/tcc/include/fenv.h
37
- - lib/data/tcc/include/float.h
38
- - lib/data/tcc/include/inttypes.h
39
- - lib/data/tcc/include/io.h
40
- - lib/data/tcc/include/limits.h
41
- - lib/data/tcc/include/locale.h
42
- - lib/data/tcc/include/malloc.h
43
- - lib/data/tcc/include/math.h
44
- - lib/data/tcc/include/mem.h
45
- - lib/data/tcc/include/memory.h
46
- - lib/data/tcc/include/process.h
47
- - lib/data/tcc/include/setjmp.h
48
- - lib/data/tcc/include/share.h
49
- - lib/data/tcc/include/signal.h
50
- - lib/data/tcc/include/stdarg.h
51
- - lib/data/tcc/include/stdbool.h
52
- - lib/data/tcc/include/stddef.h
53
- - lib/data/tcc/include/stdint.h
54
- - lib/data/tcc/include/stdio.h
55
- - lib/data/tcc/include/stdlib.h
56
- - lib/data/tcc/include/string.h
57
- - lib/data/tcc/include/sys/fcntl.h
58
- - lib/data/tcc/include/sys/file.h
59
- - lib/data/tcc/include/sys/locking.h
60
- - lib/data/tcc/include/sys/stat.h
61
- - lib/data/tcc/include/sys/time.h
62
- - lib/data/tcc/include/sys/timeb.h
63
- - lib/data/tcc/include/sys/types.h
64
- - lib/data/tcc/include/sys/unistd.h
65
- - lib/data/tcc/include/sys/utime.h
66
- - lib/data/tcc/include/tchar.h
67
- - lib/data/tcc/include/time.h
68
- - lib/data/tcc/include/unistd.h
69
- - lib/data/tcc/include/values.h
70
- - lib/data/tcc/include/varargs.h
71
- - lib/data/tcc/include/wchar.h
72
- - lib/data/tcc/include/wctype.h
73
- - lib/data/tcc/include/winapi/basetsd.h
74
- - lib/data/tcc/include/winapi/basetyps.h
75
- - lib/data/tcc/include/winapi/winbase.h
76
- - lib/data/tcc/include/winapi/wincon.h
77
- - lib/data/tcc/include/winapi/windef.h
78
- - lib/data/tcc/include/winapi/windows.h
79
- - lib/data/tcc/include/winapi/winerror.h
80
- - lib/data/tcc/include/winapi/wingdi.h
81
- - lib/data/tcc/include/winapi/winnetwk.h
82
- - lib/data/tcc/include/winapi/winnls.h
83
- - lib/data/tcc/include/winapi/winnt.h
84
- - lib/data/tcc/include/winapi/winreg.h
85
- - lib/data/tcc/include/winapi/winsvc.h
86
- - lib/data/tcc/include/winapi/winuser.h
87
- - lib/data/tcc/include/winapi/winver.h
88
- - lib/data/tcc/lib/gdi32.def
89
- - lib/data/tcc/lib/kernel32.def
90
- - lib/data/tcc/lib/libtcc1.a
91
- - lib/data/tcc/lib/msvcrt.def
92
- - lib/data/tcc/lib/user32.def
93
- - lib/data/tcc/tcc.exe
94
- - lib/data/tcc/tiny_impdef.exe
95
- - lib/data/tcc/tiny_libmaker.exe
96
- - lib/data/vbs/default_vbs.txt
97
- - lib/data/vbs/vbs_gui.txt
22
+ - lib/data/c_compilers/tcc/include/_mingw.h
23
+ - lib/data/c_compilers/tcc/include/assert.h
24
+ - lib/data/c_compilers/tcc/include/conio.h
25
+ - lib/data/c_compilers/tcc/include/ctype.h
26
+ - lib/data/c_compilers/tcc/include/dir.h
27
+ - lib/data/c_compilers/tcc/include/direct.h
28
+ - lib/data/c_compilers/tcc/include/dirent.h
29
+ - lib/data/c_compilers/tcc/include/dos.h
30
+ - lib/data/c_compilers/tcc/include/errno.h
31
+ - lib/data/c_compilers/tcc/include/excpt.h
32
+ - lib/data/c_compilers/tcc/include/fcntl.h
33
+ - lib/data/c_compilers/tcc/include/fenv.h
34
+ - lib/data/c_compilers/tcc/include/float.h
35
+ - lib/data/c_compilers/tcc/include/inttypes.h
36
+ - lib/data/c_compilers/tcc/include/io.h
37
+ - lib/data/c_compilers/tcc/include/limits.h
38
+ - lib/data/c_compilers/tcc/include/locale.h
39
+ - lib/data/c_compilers/tcc/include/malloc.h
40
+ - lib/data/c_compilers/tcc/include/math.h
41
+ - lib/data/c_compilers/tcc/include/mem.h
42
+ - lib/data/c_compilers/tcc/include/memory.h
43
+ - lib/data/c_compilers/tcc/include/process.h
44
+ - lib/data/c_compilers/tcc/include/setjmp.h
45
+ - lib/data/c_compilers/tcc/include/share.h
46
+ - lib/data/c_compilers/tcc/include/signal.h
47
+ - lib/data/c_compilers/tcc/include/stdarg.h
48
+ - lib/data/c_compilers/tcc/include/stdbool.h
49
+ - lib/data/c_compilers/tcc/include/stddef.h
50
+ - lib/data/c_compilers/tcc/include/stdint.h
51
+ - lib/data/c_compilers/tcc/include/stdio.h
52
+ - lib/data/c_compilers/tcc/include/stdlib.h
53
+ - lib/data/c_compilers/tcc/include/string.h
54
+ - lib/data/c_compilers/tcc/include/sys/fcntl.h
55
+ - lib/data/c_compilers/tcc/include/sys/file.h
56
+ - lib/data/c_compilers/tcc/include/sys/locking.h
57
+ - lib/data/c_compilers/tcc/include/sys/stat.h
58
+ - lib/data/c_compilers/tcc/include/sys/time.h
59
+ - lib/data/c_compilers/tcc/include/sys/timeb.h
60
+ - lib/data/c_compilers/tcc/include/sys/types.h
61
+ - lib/data/c_compilers/tcc/include/sys/unistd.h
62
+ - lib/data/c_compilers/tcc/include/sys/utime.h
63
+ - lib/data/c_compilers/tcc/include/tchar.h
64
+ - lib/data/c_compilers/tcc/include/time.h
65
+ - lib/data/c_compilers/tcc/include/unistd.h
66
+ - lib/data/c_compilers/tcc/include/values.h
67
+ - lib/data/c_compilers/tcc/include/varargs.h
68
+ - lib/data/c_compilers/tcc/include/wchar.h
69
+ - lib/data/c_compilers/tcc/include/wctype.h
70
+ - lib/data/c_compilers/tcc/include/winapi/basetsd.h
71
+ - lib/data/c_compilers/tcc/include/winapi/basetyps.h
72
+ - lib/data/c_compilers/tcc/include/winapi/winbase.h
73
+ - lib/data/c_compilers/tcc/include/winapi/wincon.h
74
+ - lib/data/c_compilers/tcc/include/winapi/windef.h
75
+ - lib/data/c_compilers/tcc/include/winapi/windows.h
76
+ - lib/data/c_compilers/tcc/include/winapi/winerror.h
77
+ - lib/data/c_compilers/tcc/include/winapi/wingdi.h
78
+ - lib/data/c_compilers/tcc/include/winapi/winnetwk.h
79
+ - lib/data/c_compilers/tcc/include/winapi/winnls.h
80
+ - lib/data/c_compilers/tcc/include/winapi/winnt.h
81
+ - lib/data/c_compilers/tcc/include/winapi/winreg.h
82
+ - lib/data/c_compilers/tcc/include/winapi/winsvc.h
83
+ - lib/data/c_compilers/tcc/include/winapi/winuser.h
84
+ - lib/data/c_compilers/tcc/include/winapi/winver.h
85
+ - lib/data/c_compilers/tcc/lib/gdi32.def
86
+ - lib/data/c_compilers/tcc/lib/kernel32.def
87
+ - lib/data/c_compilers/tcc/lib/libtcc1.a
88
+ - lib/data/c_compilers/tcc/lib/msvcrt.def
89
+ - lib/data/c_compilers/tcc/lib/user32.def
90
+ - lib/data/c_compilers/tcc/tcc.exe
91
+ - lib/data/exe_templates/launcher_stub.c
92
+ - lib/data/exe_templates/launcher_stub.cpp
93
+ - lib/data/launcher_templates/vbs/default_vbs.txt
94
+ - lib/data/launcher_templates/vbs/vbs_gui.txt
95
+ - lib/data/resource_files/default.rc
96
+ - lib/displayer.rb
97
+ - lib/exe_packer.rb
98
+ - lib/launcher.rb
99
+ - lib/launcher_handler.rb
100
+ - lib/parameter_parser.rb
101
+ - lib/ruby_copy.rb
102
+ - lib/sfx_generator.rb
98
103
  - lib/standalone_ruby.rb
99
- - lib/utils/config_generator.rb
100
- - lib/utils/displayer.rb
101
- - lib/utils/exe_packer.rb
102
- - lib/utils/launcher.rb
103
- - lib/utils/launcher_handler.rb
104
- - lib/utils/logger_helper.rb
105
- - lib/utils/parameter_parser.rb
106
- - lib/utils/ruby_copy.rb
107
104
  - lib/version/version.rb
108
105
  homepage: https://github.com/ardatetikbey/Standalone-Ruby
109
106
  licenses:
@@ -1,9 +0,0 @@
1
- @echo off
2
- setlocal
3
-
4
- set "RUBY_PATH=%~dp0STANDALONE_RUBY_PATH"
5
- set "SCRIPT_PATH=%~dp0STANDALONE_MAIN_FILE"
6
-
7
- start "" /B "%RUBY_PATH%" "%SCRIPT_PATH%"
8
-
9
- exit
@@ -1,9 +0,0 @@
1
- #include <iostream>
2
- #include <cstdlib>
3
-
4
- int main() {
5
- const char* command = "wscript.exe LAUNCHER_FILE";
6
-
7
- int result = system(command);
8
- return 0;
9
- }
Binary file
Binary file
@@ -1,5 +0,0 @@
1
- require_relative 'logger_helper'
2
-
3
- class ConfigGenerator
4
-
5
- end
@@ -1,72 +0,0 @@
1
- require_relative 'logger_helper'
2
-
3
- class ExePacker
4
- def initialize(params)
5
- @params = params
6
- @logger = LoggerHelper.instance
7
- end
8
-
9
- def pack
10
- begin
11
- stub_path = File.join(File.expand_path("../data/exe_template", __dir__), "launcher_stub.c")
12
- @logger.info("Reading stub template from: #{stub_path}")
13
-
14
- stub_content = File.read(stub_path)
15
- stub_content.gsub!("LAUNCHER_FILE", "#{File.basename(@params[:launcher])}")
16
-
17
- stub_output = "#{File.join(@params[:project_path].to_s, "launcher_stub.c")}"
18
- exe_path = "#{File.join(@params[:project_path].to_s, @params[:exe].to_s)}"
19
-
20
- File.open(stub_output, 'w') { |f| f.write(stub_content) }
21
-
22
- if @params[:use_gcc]
23
- puts "\nChecking GCC..."
24
- output = `where gcc`
25
-
26
- if File.exist?(output.strip)
27
- gcc_path = output.strip
28
- puts "GCC Path: #{gcc_path}"
29
-
30
- command = "#{gcc_path} -o #{exe_path} #{stub_output}"
31
- @logger.info("Running command: #{command}")
32
- `#{command}`
33
- else
34
- print("Error: ".red); puts("GCC could not be found!");
35
- exit!
36
- end
37
- else
38
- puts "\nUsing TCC..."
39
-
40
- tcc_path = File.join(File.expand_path("../data/tcc", __dir__), "tcc.exe")
41
- @logger.info("TCC Path: #{tcc_path}")
42
-
43
- command = "#{tcc_path} -o #{exe_path} #{stub_output} -lkernel32"
44
- @logger.info("Running command: #{command}")
45
- `#{command}`
46
- end
47
-
48
- File.delete(stub_output)
49
- @logger.info("Stub file deleted successfully")
50
-
51
- puts("\nExe file has been generated!".green_bold_dark)
52
- @logger.info("Exe file generated successfully at: #{exe_path}")
53
- rescue Exception => err
54
- @logger.error("Error occurred: #{err.message}")
55
- print("Error: ".red); puts(err.message)
56
- end
57
- end
58
- end
59
-
60
- class String
61
- def red
62
- "\e[31m#{self}\e[0m"
63
- end
64
-
65
- def yellow
66
- "\e[33m#{self}\e[0m"
67
- end
68
-
69
- def green_bold_dark
70
- "\e[1m\e[38;5;28m#{self}\e[0m"
71
- end
72
- end
@@ -1,111 +0,0 @@
1
- require 'fileutils'
2
-
3
- require_relative 'logger_helper'
4
-
5
- class LauncherHandler
6
- def initialize(params)
7
- @params = params
8
- @logger = LoggerHelper.instance
9
- end
10
-
11
- def handle
12
- begin
13
- puts("\nThe template creation process has been started.")
14
-
15
- # FileUtils.mkdir(File.join(@params[:project_path], "sRb_files"))
16
-
17
- if @params[:template]
18
- if @params[:gui] == true
19
- ruby_file = "rubyw.exe"
20
- else
21
- ruby_file = "ruby.exe"
22
- end
23
-
24
- user_template = @params[:template].to_s
25
- content = File.read(user_template)
26
- @logger.info("The content of the user template has been read.")
27
-
28
- content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "#{ruby_file}")}")
29
- @logger.info("Placed the defined Ruby interpreter path in the template.")
30
-
31
- content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
32
- @logger.info("The main project file path defined in the template is placed.")
33
-
34
- new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
35
- File.open(new_launcher_path, "w") do |f_man|
36
- f_man.puts content
37
- end
38
-
39
- @logger.info("New launcher file directory created as #{new_launcher_path.to_s}")
40
- else
41
- if @params[:launcher_type] == "vbs"
42
- if @params[:gui] == true
43
- vbs_template = File.join(File.expand_path("../data/vbs", __dir__), "vbs_gui.txt")
44
- ruby_file = "rubyw.exe"
45
- else
46
- vbs_template = File.join(File.expand_path("../data/vbs", __dir__), "default_vbs.txt")
47
- ruby_file = "ruby.exe"
48
- end
49
-
50
- puts "Using: #{vbs_template}"
51
-
52
- if File.exist?(vbs_template)
53
- content = File.read(vbs_template)
54
- @logger.info("The content of the template has been read.")
55
-
56
- content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "#{ruby_file}")}")
57
- @logger.info("Placed the defined Ruby interpreter path in the template.")
58
-
59
- content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
60
- @logger.info("The main project file path defined in the template is placed.")
61
-
62
- new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
63
- File.open(new_launcher_path, "w") do |f_man|
64
- f_man.puts content
65
- end
66
-
67
- @logger.info("New launcher file directory created as #{new_launcher_path.to_s}")
68
- else
69
- print("Handler Error: ".red); puts("The template file could not be found.")
70
- @logger.error("Template file not found!")
71
- exit!
72
- end
73
- else
74
- if @params[:gui] == true
75
- ruby_file = "rubyw.exe"
76
- else
77
- ruby_file = "ruby.exe"
78
- end
79
-
80
- bat_template = File.join(File.expand_path("../data/bat-cmd", __dir__), "default_bat_cmd.txt")
81
- puts "Using: #{bat_template}"
82
-
83
- if File.exist?(bat_template)
84
- content = File.read(bat_template)
85
- @logger.info("The content of the template has been read.")
86
-
87
- content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "#{ruby_file}")}")
88
- @logger.info("Placed the defined Ruby interpreter path in the template.")
89
-
90
- content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
91
- @logger.info("The main project file path defined in the template is placed.")
92
-
93
- new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
94
- File.open(new_launcher_path, "w") do |f_man|
95
- f_man.puts content
96
- end
97
-
98
- @logger.info("New launcher file directory created as #{new_launcher_path.to_s}")
99
- else
100
- print("Handler Error: ".red); puts("The template file could not be found.")
101
- @logger.error("Handler Error: Template file not found!")
102
- exit!
103
- end
104
- end
105
- end
106
- rescue Exception => e
107
- print("Handler Error: ".red); puts("#{e.message}")
108
- @logger.error("Handler Error: #{e.message}")
109
- end
110
- end
111
- end
@@ -1,24 +0,0 @@
1
- require 'logger'
2
- require 'time'
3
- require 'fileutils'
4
-
5
- class LoggerHelper
6
- def self.instance
7
- documents_path = File.join(ENV['USERPROFILE'], 'Documents', 'standalone-ruby-logs')
8
-
9
- FileUtils.mkdir_p(documents_path) unless Dir.exist?(documents_path)
10
-
11
- timestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
12
- log_file = File.join(documents_path, "standalone-ruby_#{timestamp}.log")
13
-
14
- logger = Logger.new(log_file)
15
- logger.level = Logger::INFO
16
-
17
- logger.formatter = proc do |severity, datetime, progname, msg|
18
- msg = "(empty message)" if msg.nil? || msg.strip.empty?
19
- "#{datetime.strftime('%Y-%m-%d %H:%M:%S')} [#{severity}] #{msg}\n"
20
- end
21
-
22
- return logger
23
- end
24
- end
@@ -1,211 +0,0 @@
1
- require 'fileutils'
2
- require 'optparse'
3
-
4
- require_relative 'logger_helper'
5
- require_relative '../version/version'
6
-
7
- class ParameterParser
8
- def initialize
9
- @params = {
10
- threads: 5
11
- }
12
-
13
- @logger = LoggerHelper.instance
14
- end
15
-
16
- def normalize_paths!
17
- @params.each do |key, value|
18
- @params[key] = value.gsub('\\', '/') if value.is_a?(String)
19
- end
20
- end
21
-
22
- def display_help
23
- help_text = <<~EOT
24
- Standalone-Ruby v#{StandaloneRuby::VERSION} - Package your Ruby projects as exe!
25
-
26
- Usage: standalone-ruby [-h] [-p PROJECT_PATH] [-r RUBY_PATH] [-m MAIN_FILE] [-l LAUNCHER] [-t TEMPLATE] [-e EXE_FILE] [-c THREADS] [-g] [-v]
27
-
28
- Options:
29
- -p, --project PROJECT_PATH Target Ruby project path.
30
- Ensures that the given project path exists. If not, an error is displayed.
31
-
32
- -r, --ruby RUBY_PATH Path to the Ruby interpreter.
33
- Ensures that the given Ruby path exists and contains a 'bin' directory.
34
-
35
- -m, --main MAIN_FILE Path to the main Ruby file of the project.
36
- Ensures that the specified Ruby file exists.
37
-
38
- -l, --launcher LAUNCHER Launcher file name (either .vbs or .bat-cmd).
39
- Ensure the launcher file exists and is of the correct type (either .vbs or .bat-cmd).
40
-
41
- -t, --template TEMPLATE Template file for launcher.
42
- Ensures that the specified template file exists.
43
-
44
- -e, --exe EXE_FILE Name of the exe file to be used for output
45
-
46
- -c, --threads THREADS Number of threads to use (default is 5).
47
- Determines the number of threads used during the Ruby interpreter copy process and for Rubocopy operations.
48
- A higher number of threads can speed up the process, but requires more system resources.
49
-
50
- -g, --gui This option allows the rubyw.exe file in the bin folder to be used.
51
- You can choose it for projects that include GUI.
52
-
53
- -h, --help Show this help message.
54
-
55
- -v, --version Show program version.
56
-
57
- Notes:
58
- - Make sure that the Ruby interpreter you are using includes all the gems required for the target project.
59
- - The Ruby interpreter uses Robocopy for copying, and the number of threads given affects the speed of this operation.
60
-
61
- For more details, please visit the documentation at:
62
- https://github.com/ardatetikbey/Standalone-Ruby
63
-
64
- EOT
65
-
66
- puts help_text
67
- end
68
-
69
- def parse
70
- begin
71
- OptionParser.new do |opts|
72
- note = "Note: https://github.com/ardatetikbey/Standalone-Ruby Don't forget to review my github document to get the best results."
73
- opts.banner = "Usage: ruby #{$0} [options]\n#{note}"
74
-
75
- opts.on("-p", "--project PROJECT_PATH", String, "Target Ruby project path") do |project_path|
76
- project_path.strip!
77
- if Dir.exist?("#{project_path}")
78
- @params[:project_path] = project_path
79
- else
80
- print("Parser Error: ".red); puts("The specified project path #{project_path} could not be found!")
81
- @logger.error("Parser Error: The project path #{project_path} could not be found!")
82
- exit!
83
- end
84
- end
85
-
86
- opts.on("-e", "--exe EXE", "Exe file name") do |exe|
87
- @params[:exe] = exe
88
- end
89
-
90
- opts.on("-r", "--ruby RUBY_PATH", String, "Ruby interpreter path") do |ruby_path|
91
- ruby_path.strip!
92
- if Dir.exist?("#{ruby_path}")
93
- if Dir.exist?(File.join(ruby_path, "bin"))
94
- @params[:ruby_path] = ruby_path
95
- end
96
- else
97
- print("Parser Error: ".red); puts("The specified Ruby path #{ruby_path} could not be found!")
98
- @logger.error("Parser Error: The specified Ruby path #{ruby_path} could not be found!")
99
- exit!
100
- end
101
- end
102
-
103
- opts.on("--gcc") do
104
- @params[:use_gcc] = true
105
- end
106
-
107
- opts.on("-m", "--main MAIN_FILE", String, "Path to the main ruby file of the project") do |main_file|
108
- main_file.strip!
109
- if File.exist?(main_file)
110
- @params[:main_file] = main_file
111
- else
112
- print("Parser Error: ".red); puts("The specified file #{main_file} could not be found!")
113
- @logger.error("Parser Error: The specified file #{main_file} could not be found!")
114
- exit!
115
- end
116
- end
117
-
118
- opts.on("-c", "--threads THREADS", Integer, "Number of threads to use (default is 5)") do |threads|
119
- if threads.is_a?(Integer)
120
- @params[:threads] = threads
121
- else
122
- print("Parser Error: ".red); puts("Invalid value for threads. Please provide an integer.")
123
- @logger.error("Parser Error: Invalid value for threads.")
124
- exit!
125
- end
126
- end
127
-
128
- opts.on("-l", "--launcher LAUNCHER", String, "Launcher file name.type (vbs or bat-cmd)") do |launcher|
129
- launcher.strip!
130
- if launcher.include?(".vbs")
131
- @params[:launcher] = launcher
132
- @params[:launcher_type] = "vbs"
133
- @params[:launcher_name] = File.basename(launcher)
134
- elsif launcher.include?(".bat")
135
- @params[:launcher] = launcher
136
- @params[:launcher_type] = "bat"
137
- @params[:launcher_name] = File.basename(launcher)
138
- elsif launcher.include?(".cmd")
139
- @params[:launcher] = launcher
140
- @params[:launcher_type] = "cmd"
141
- @params[:launcher_name] = File.basename(launcher)
142
- else
143
- print("Parser Error: ".red); puts("The supported launcher #{launcher} could not be found!")
144
- @logger.error("Parser Error: The supported launcher path #{launcher} could not be found!")
145
- exit!
146
- end
147
- end
148
-
149
- opts.on("-t", "--template TEMPLATE", "Template file for launcher") do |template|
150
- template.strip!
151
- if File.exist?(template)
152
- @params[:template] = template
153
- else
154
- print("Parser Error: ".red); puts("The specified template file #{template} could not be found!")
155
- @logger.error("Parser Error: The specified template file #{template} could not be found!")
156
- exit!
157
- end
158
- end
159
-
160
- opts.on("-g", "--gui", "Project mode with visual interface") do
161
- @params[:gui] = true
162
- end
163
-
164
- opts.on("-v", "--version") do
165
- puts "Standalone Ruby Gem Version #{StandaloneRuby::VERSION}"
166
- exit!
167
- end
168
-
169
- opts.on("-h", "--help", "Show this help message") do
170
- display_help
171
- exit!
172
- end
173
-
174
- normalize_paths!
175
- end.parse!
176
-
177
- if @params[:project_path].nil? || @params[:ruby_path].nil? || @params[:main_file].nil?
178
- print("Error: ".red); puts("Missing required parameters. Please provide the necessary parameters:\n -p, -r, -m.\nYou can use the -h parameter for the help menu.")
179
- @logger.error("Parser Error: Missing required parameters.")
180
- exit!
181
- end
182
-
183
- rescue Exception => e
184
- print("Parser Error: ".red); puts("#{e.message}".red)
185
- @logger.error("Parser Error: #{e.message}")
186
- exit!
187
- end
188
- end
189
-
190
- def params
191
- @params
192
- end
193
- end
194
-
195
- class String
196
- def red
197
- "\e[31m#{self}\e[0m"
198
- end
199
-
200
- def green
201
- "\e[32m#{self}\e[0m"
202
- end
203
-
204
- def magenta
205
- "\e[35m#{self}\e[0m"
206
- end
207
-
208
- def yellow
209
- "\e[33m#{self}\e[0m"
210
- end
211
- end
File without changes
File without changes