standalone-ruby 1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d1237b95df08557619fbe5fd80c60b199a31f1b520ba35593974edd1e9f38a0a
4
+ data.tar.gz: ce4bd5695f976ede6c841fe999c831d3ae14c55572a864d9d36ed25e2f10e5d9
5
+ SHA512:
6
+ metadata.gz: ea1f45628a065473385cf67ec2a2e751a743ad58e7db5ea0f7b03351404fc0e481aa59588a71c4a7cba1089eedf620c282d07c7280e6bf20e58fb6b1cc8c8c02
7
+ data.tar.gz: 92c2ccc58520de7f618049f827de0c70f08b5ec6386539bd168c9225a1b4c5312c4762254dfd20bb85602ac4b59524cd332a8abda2006ddec5119c65e1a89dc8
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2025-03-27
4
+ ### Added
5
+ - First version of Standalone-Ruby released.
data/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # Project: Standalone Ruby
2
+
3
+ ![Project Banner](images/banner.jpg)
4
+
5
+ Contact: ardatetikruby@gmail.com
6
+
7
+ ---
8
+
9
+ ## Özellikler / Features / Funktionen / 機能
10
+
11
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Windows sistemlerde Ruby kurulumuna ihtiyaç duymadan Ruby ile yazdığınız projelerinizi çalıştırabilmenize olanak sağlar.
12
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> It allows you to run your projects written with Ruby on Windows systems without the need for a Ruby installation.
13
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Es ermöglicht Ihnen, Ihre mit Ruby geschriebenen Projekte auf Windows-Systemen auszuführen, ohne dass eine Ruby-Installation erforderlich ist.
14
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> これにより、Ruby をインストールしなくても、Windows システム上で Ruby で記述されたプロジェクトを実行できるようになります。
15
+
16
+ ---
17
+
18
+ ## Program Mantığı / Logic / Logik / 論理
19
+
20
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Bu program, Ruby yorumlayıcısının dizinini, proje klasörünü ve projenin ana dosyasının yolunu alır. Bu değerleri, seçime bağlı olarak VBS veya BAT uzantılı başlatıcı dosyanın içine uygun şekilde yerleştirir ve belirtilen Ruby yorumlayıcısını proje dizinine kopyalar. Başlatıcı dosya çalıştırıldığında, ilgili Ruby yorumlayıcısını kullanarak projenin ana dosyasını açar.
21
+
22
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/>This program takes the Ruby interpreter directory, the project folder, and the path to the project's main file. It places these values ​​appropriately in a starter file, optionally with a VBS or BAT extension, and copies the specified Ruby interpreter to the project directory. When the starter file is run, it opens the project's main file using the corresponding Ruby interpreter.
23
+
24
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Dieses Programm verwendet das Ruby-Interpreterverzeichnis, den Projektordner und den Pfad zur Hauptdatei des Projekts. Es platziert diese Werte entsprechend in einer Starterdatei, optional mit einer VBS- oder BAT-Erweiterung, und kopiert den angegebenen Ruby-Interpreter in das Projektverzeichnis. Wenn die Startdatei ausgeführt wird, öffnet sie die Hauptdatei des Projekts mithilfe des zugehörigen Ruby-Interpreters.
25
+
26
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> このプログラムは、Ruby インタープリター ディレクトリ、プロジェクト フォルダー、およびプロジェクトのメイン ファイルへのパスを受け取ります。これらの値をスターター ファイル(オプションで VBS または BAT 拡張子)に適切に配置し、指定された Ruby インタープリターをプロジェクト ディレクトリにコピーします。ランチャー ファイルが実行されると、関連付けられた Ruby インタープリターを使用してプロジェクトのメイン ファイルが開きます。
27
+
28
+ ---
29
+
30
+ ## Kullanım / Use / Verwenden / 使用するには
31
+
32
+ ## Example Command:
33
+
34
+ ```bash
35
+ standalone-ruby -p "C:/Users/User/Desktop/PRJCT" -r "C:/Users/User/Documents/Ruby34-x64" -m "C:/Users/User/Desktop/myproject/main.rb" -l launcher1.vbs -c 10
36
+ ```
37
+
38
+ ## Parametreler / Parameters / Parameter / パラメータ
39
+
40
+ #### 1. `-p, --project PROJECT_PATH`
41
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Hedef Ruby projesinin yolunu belirtir. Verilen proje yolunun varlığını kontrol eder.
42
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> Specifies the target Ruby project path. It checks that the given project path exists.
43
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Gibt den Pfad zum Ziel-Ruby-Projekt an. Überprüft, ob der angegebene Projektpfad existiert.
44
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> ターゲット Ruby プロジェクトへのパスを指定します。指定されたプロジェクト パスが存在するかどうかを確認します。
45
+
46
+ #### 2. `-r, --ruby RUBY_PATH`
47
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Ruby yorumlayıcısının yolunu tanımlar. Verilen Ruby yolunun varlığını ve içinde 'bin' dizini olup olmadığını kontrol eder.
48
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> Defines the path to the Ruby interpreter. It checks that the given Ruby path exists and contains a 'bin' directory.
49
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Definiert den Pfad zum Ruby-Interpreter. Überprüft, ob der angegebene Ruby-Pfad existiert und ob er das Verzeichnis „bin“ enthält.
50
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> Ruby インタープリターへのパスを定義します。指定された Ruby パスが存在するかどうか、またそこに 'bin' ディレクトリが含まれているかどうかを確認します。
51
+
52
+ #### 3. `-m, --main MAIN_FILE`
53
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Projenin ana Ruby dosyasının yolunu belirtir. Verilen Ruby dosyasının varlığını kontrol eder.
54
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> Provides the path to the main Ruby file of the project. It ensures that the specified Ruby file exists.
55
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Gibt den Pfad zur Ruby-Hauptdatei des Projekts an. Überprüft, ob die angegebene Ruby-Datei vorhanden ist.
56
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> プロジェクトのメイン Ruby ファイルのパスを指定します。指定された Ruby ファイルの存在を確認します。
57
+
58
+ #### 4. `-l, --launcher LAUNCHER`
59
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Çalıştırıcı dosyasının adını belirtir, bu dosya `.vbs` veya `.bat` formatlarında olabilir. Çalıştırıcı dosyasının varlığını ve uygun türde olduğunu kontrol eder.
60
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> Specifies the launcher file name, which can either be `.vbs` or `.bat`. It checks whether the launcher file exists and is of the correct type.
61
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Gibt den Namen der ausführbaren Datei an. Diese Datei kann „.vbs“ oder „.bat“ sein. Überprüft, ob die ausführbare Datei vorhanden ist und vom richtigen Typ ist.
62
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> 実行可能ファイルの名前を指定します。このファイルは `.vbs` または `.bat` にすることができます。実行可能ファイルが存在し、正しいタイプであることを確認します。
63
+
64
+ #### 5. `-c, --threads THREADS`
65
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Kullanılacak thread sayısını belirtir. Varsayılan değer 5'tir. Bu parametre, Ruby yorumlayıcısının kopyalanma işlemi sırasında kullanılacak thread sayısını belirtir.
66
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> Specifies the number of threads to use. The default value is 5. This parameter specifies the number of threads to use during the copy operation of the Ruby interpreter.
67
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Gibt die Anzahl der zu verwendenden Threads an. Der Standardwert ist 5. Dieser Parameter gibt die Anzahl der Threads an, die während des Kopiervorgangs des Ruby-Interpreters verwendet werden sollen.
68
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> 使用するスレッドの数を指定します。デフォルト値は 5 です。このパラメータは、Ruby インタープリタのコピー プロセス中に使用されるスレッドの数を指定します。
69
+
70
+ #### 6. `-h, --help`
71
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Yardım mesajını görüntüler.
72
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> Displays the help message.
73
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Zeigt die Hilfemeldung an.
74
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> ヘルプメッセージを表示します。
75
+
76
+ ---
77
+
78
+ ## Notlar / Notes / Anmerkungen / ノート
79
+
80
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> **Program Notları**
81
+ - Sağlanan yolların geçerli ve sisteminizden erişilebilir olduğundan emin olun.
82
+ - Başlatıcı dosya türü Windows sistemleri için `.vbs` veya `.bat` olmalıdır.
83
+ - `threads` seçeneği kopyalama sürecinde performansı önemli ölçüde etkileyebilir, bu nedenle sisteminizin kapasitesine göre dikkatli kullanın.
84
+ - Kullandığınız Ruby yorumlayıcısının çalıştıracağınız proje için bütün gem dosyalarını içerdiğinden emin olun.
85
+ - Daha fazla ayrıntı için resmi [GitHub Deposu](https://github.com/ardatetikbey/Standalone-Ruby)'na bakın.
86
+
87
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> **Program Notes**
88
+ - Make sure that the provided paths are valid and accessible from your system.
89
+ - The launcher file type must be either `.vbs` or `.bat` for Windows systems.
90
+ - The `threads` option can significantly impact performance during the copying process, so use it wisely based on your system’s capabilities.
91
+ - Make sure that the Ruby interpreter you are using includes all the gem files for the project you will be running.
92
+ - For more details, refer to the official [GitHub Repository](https://github.com/ardatetikbey/Standalone-Ruby).
93
+
94
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> **Programmanmerkungen**
95
+ - Stellen Sie sicher, dass die angegebenen Pfade gültig und von Ihrem System zugänglich sind.
96
+ - Der Typ der Startdatei muss entweder `.vbs` oder `.bat` für Windows-Systeme sein.
97
+ - Die Option `threads` kann die Leistung während des Kopiervorgangs erheblich beeinflussen. Verwenden Sie sie daher entsprechend den Fähigkeiten Ihres Systems.
98
+ - Stellen Sie sicher, dass der von Ihnen verwendete Ruby-Interpreter alle Gem-Dateien für das Projekt enthält, das Sie ausführen werden.
99
+ - Weitere Details finden Sie im offiziellen [GitHub-Repository](https://github.com/ardatetikbey/Standalone-Ruby).
100
+
101
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> **プログラムの注意事項**
102
+ - 指定されたパスが有効であり、システムからアクセス可能であることを確認してください。
103
+ - ランチャーファイルの種類は、Windows システムでは `.vbs` または `.bat` である必要があります。
104
+ - `threads` オプションはコピー処理中のパフォーマンスに大きな影響を与える可能性があるため、システムの能力に応じて適切に使用してください。
105
+ - 使用している Ruby インタープリターに、実行するプロジェクトのすべての gem ファイルが含まれていることを確認してください。
106
+ - 詳細については、公式の [GitHub リポジトリ](https://github.com/ardatetikbey/Standalone-Ruby) を参照してください。
107
+
108
+ ---
109
+
110
+ ## Yapılacaklar / To Do List / やるべきこと
111
+
112
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> **Yapılacaklar**
113
+ - Logger Desteği - Programın çalışmasını ve hata ayıklamayı kolaylaştırmak için loglama mekanizması eklenecek.
114
+ - GUI Arayüzü - Kullanıcıların daha kolay işlem yapabilmesi için basit bir grafik arayüz geliştirilecek.
115
+ - Şifrelenmiş Ruby Çalıştırma - Ruby betiklerini şifreleyerek koruma sağlanacak ve çözüp çalıştırma özelliği eklenecek.
116
+ - Çapraz Platform Desteği - Linux ve macOS sistemlerinde benzer bir çalışma mantığı sunacak destek eklenmesi.
117
+ - Özel Çalıştırıcı Dosya Biçimleri - .vbs ve .bat dışında alternatif çalıştırıcı dosya formatları eklenmesi.
118
+ - Inno Setup EXE Desteği - Proje çıktısında oluşan başlatıcı dosyanın proje dosyalarıyla beraber bir setup haline getirilmesi.
119
+
120
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> **To-Do List**
121
+ - Logger Support - A logging mechanism will be added to facilitate debugging and monitoring the program’s operation.
122
+ - GUI Interface - A simple graphical user interface will be developed to make it easier for users to operate.
123
+ - Encrypted Ruby Execution - Ruby scripts will be encrypted for protection and will have an option to be decrypted and executed.
124
+ - Cross-Platform Support - Support for running on Linux and macOS with similar functionality will be added.
125
+ - Custom Execution File Formats - Alternative execution file formats will be introduced beyond .vbs and .bat.
126
+ - Inno Setup EXE Support - Converting the launcher file created in the project output into a setup along with the project files.
127
+
128
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> **Aufgabenliste**
129
+ - Logger-Unterstützung - Ein Logging-Mechanismus wird hinzugefügt, um die Programmausführung und das Debuggen zu erleichtern.
130
+ - GUI-Oberfläche - Eine einfache grafische Benutzeroberfläche wird entwickelt, um den Benutzern die Durchführung von Aufgaben zu erleichtern.
131
+ - Verschlüsselte Ruby-Ausführung - Ruby-Skripte werden zum Schutz verschlüsselt, und eine Entschlüsselungs- und Ausführungsfunktion wird hinzugefügt.
132
+ - Cross-Platform-Unterstützung - Es wird Unterstützung hinzugefügt, um ähnliche Funktionen auf Linux- und macOS-Systemen bereitzustellen.
133
+ - Benutzerdefinierte Launcher-Dateiformate - Es werden alternative Launcher-Dateiformate hinzugefügt, außer .vbs und .bat.
134
+ - Konvertieren der in der Projektausgabe erstellten Launcher-Datei zusammen mit den Projektdateien in ein Setup.
135
+
136
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> **やることリスト**
137
+ - ロガーサポート - プログラムの実行とデバッグを容易にするためにロギングメカニズムが追加されます。
138
+ - GUIインターフェース - ユーザーがより簡単に作業を行えるようにシンプルなグラフィカルインターフェースが開発されます。
139
+ - 暗号化されたRuby実行 - Rubyスクリプトが保護のために暗号化され、復号化して実行する機能が追加されます。
140
+ - クロスプラットフォームサポート - LinuxおよびmacOSシステムで同様の機能が提供されるサポートが追加されます。
141
+ - カスタムランチャーファイル形式 - .vbsおよび.bat以外の代替ランチャーファイル形式が追加されます。
142
+ - プロジェクト出力で作成されたランチャー ファイルをプロジェクト ファイルとともにセットアップに変換します。
143
+
144
+ ---
145
+
146
+ ## Lisans / License / Lizenz / ライセンス
147
+
148
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg" width="20"/> Bu proje MIT Lisansı altında lisanslanmıştır.
149
+ - <img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" width="20"/> This project is licensed under the MIT License.
150
+ - <img src="https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg" width="20"/> Dieses Projekt ist unter der MIT-Lizenz lizenziert.
151
+ - <img src="https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg" width="20"/> このプロジェクトはMITライセンスの下でライセンスされています。
152
+
153
+ 🔗 **GitHub:** [Project Standalone-Ruby](https://github.com/ardatetikbey/Standalone-Ruby)
@@ -0,0 +1,4 @@
1
+ require File.expand_path('../lib/standalone_ruby', __dir__)
2
+
3
+ standalone_ruby = StandaloneRuby.new
4
+ standalone_ruby.run
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,7 @@
1
+ Set objShell = CreateObject("WScript.Shell")
2
+
3
+ rubyPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "/STANDALONE_RUBY_PATH"
4
+ scriptPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "/STANDALONE_MAIN_FILE"
5
+
6
+ command = """" & rubyPath & """ """ & scriptPath & """"
7
+ objShell.Run command, 0, False
@@ -0,0 +1,36 @@
1
+ require 'optparse'
2
+ require_relative 'utils/displayer'
3
+ require_relative 'utils/parameter_parser'
4
+ require_relative 'utils/ruby_copy'
5
+ require_relative 'utils/launcher_handler'
6
+ # require_relative 'utils/logger_helper'
7
+
8
+ class StandaloneRuby
9
+ def initialize
10
+ @parser = ParameterParser.new
11
+ @parser.parse
12
+
13
+ @params = @parser.params
14
+ @displayer = Displayer.new(@params)
15
+ @ruby_copy = RubyCopy.new(@params)
16
+ @launcher_handler = LauncherHandler.new(@params)
17
+ end
18
+
19
+ def run
20
+ Signal.trap("INT") do
21
+ puts "\nProgram interrupted. Shutting down..."
22
+ exit(0)
23
+ end
24
+
25
+ if @params[:version]
26
+ puts "Standalone Ruby Gem Version 1.0"
27
+ return
28
+ end
29
+
30
+ @displayer.banner
31
+ @displayer.display_params
32
+
33
+ @launcher_handler.handle
34
+ @ruby_copy.robocopy_interpreter
35
+ end
36
+ end
@@ -0,0 +1,57 @@
1
+ class Displayer
2
+ def initialize(params)
3
+ @params = params
4
+ end
5
+
6
+ def display_params
7
+ begin
8
+ display_text = []
9
+
10
+ display_text << "Project Path: #{@params[:project_path]}" if @params[:project_path]
11
+ display_text << "Ruby Path: #{@params[:ruby_path]}" if @params[:ruby_path]
12
+ display_text << "Ruby Folder: #{File.basename(@params[:ruby_path])}" if @params[:ruby_path]
13
+ display_text << "Main File: #{@params[:main_file]}" if @params[:main_file]
14
+ display_text << "Launcher: #{@params[:launcher]}" if @params[:launcher]
15
+ display_text << "Launcher Type: #{@params[:launcher_type]}" if @params[:launcher_type]
16
+ display_text << "Template: #{@params[:template]}" if @params[:template]
17
+ display_text << "Template: Default Template" unless @params[:template]
18
+
19
+ puts display_text.join("\n") unless display_text.empty?
20
+
21
+ rescue Exception => e
22
+ print("Display Error: ".red); puts("#{e.message}".red)
23
+ end
24
+ end
25
+
26
+ def banner
27
+ banner = -<<'BANNER'
28
+
29
+ ┌─┐┌┬┐┌─┐┌┐┌┌┬┐┌─┐┬ ┌─┐┌┐┌┌─┐ ┬─┐┬ ┬┌┐ ┬ ┬
30
+ └─┐ │ ├─┤│││ ││├─┤│ │ ││││├┤ ├┬┘│ │├┴┐└┬┘
31
+ └─┘ ┴ ┴ ┴┘└┘─┴┘┴ ┴┴─┘└─┘┘└┘└─┘ ┴└─└─┘└─┘ ┴
32
+
33
+ # Github: https://github.com/ardatetikbey/Standalone-Ruby
34
+
35
+ BANNER
36
+
37
+ puts banner
38
+ end
39
+ end
40
+
41
+ class String
42
+ def red
43
+ "\e[31m#{self}\e[0m"
44
+ end
45
+
46
+ def green
47
+ "\e[32m#{self}\e[0m"
48
+ end
49
+
50
+ def magenta
51
+ "\e[35m#{self}\e[0m"
52
+ end
53
+
54
+ def yellow
55
+ "\e[33m#{self}\e[0m"
56
+ end
57
+ end
@@ -0,0 +1,69 @@
1
+ require 'fileutils'
2
+
3
+ class LauncherHandler
4
+ def initialize(params)
5
+ @params = params
6
+ end
7
+
8
+ def handle
9
+ begin
10
+ puts("\nThe template creation process has been started.")
11
+
12
+ if @params[:template]
13
+ user_template = @params[:template].to_s
14
+ content = File.read(user_template)
15
+
16
+ content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "ruby.exe")}")
17
+ content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
18
+
19
+ new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
20
+
21
+ File.open(new_launcher_path, "w") do |f_man|
22
+ f_man.puts content
23
+ end
24
+ else
25
+ if @params[:launcher_type] == "vbs"
26
+ vbs_template = File.join(File.expand_path("../data/vbs", __dir__), "default_vbs.txt")
27
+ puts "Using: #{vbs_template}"
28
+
29
+ if File.exist?(vbs_template)
30
+ content = File.read(vbs_template)
31
+
32
+ content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "ruby.exe")}")
33
+ content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
34
+
35
+ new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
36
+
37
+ File.open(new_launcher_path, "w") do |f_man|
38
+ f_man.puts content
39
+ end
40
+ else
41
+ print("Handler Error: ".red); puts("Template file not found!")
42
+ exit!
43
+ end
44
+ else
45
+ bat_template = File.join(File.expand_path("../data/bat", __dir__), "default_bat.txt")
46
+ puts "Using: #{bat_template}"
47
+
48
+ if File.exist?(bat_template)
49
+ content = File.read(bat_template)
50
+
51
+ content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "ruby.exe")}")
52
+ content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
53
+
54
+ new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
55
+
56
+ File.open(new_launcher_path, "w") do |f_man|
57
+ f_man.puts content
58
+ end
59
+ else
60
+ print("Handler Error: ".red); puts("The template file could not be found.")
61
+ exit!
62
+ end
63
+ end
64
+ end
65
+ rescue Exception => e
66
+ print("Handler Error: ".red); puts("#{e.message}")
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,22 @@
1
+ require 'logger'
2
+ require 'time'
3
+ require 'fileutils'
4
+
5
+ class LoggerHelper
6
+ def self.instance
7
+ log_directory = 'program_logs'
8
+ FileUtils.mkdir_p(log_directory) unless Dir.exist?(log_directory)
9
+
10
+ timestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
11
+ log_file = "#{log_directory}/application_#{timestamp}.log"
12
+
13
+ @logger ||= Logger.new(log_file)
14
+ @logger.level = Logger::INFO
15
+
16
+ @logger.formatter = proc do |severity, datetime, msg|
17
+ "#{datetime.strftime('%Y-%m-%d %H:%M:%S')} [#{severity}] #{msg}\n"
18
+ end
19
+
20
+ return @logger
21
+ end
22
+ end
@@ -0,0 +1,165 @@
1
+ require 'fileutils'
2
+ require 'optparse'
3
+
4
+ class ParameterParser
5
+ def initialize
6
+ @params = {
7
+ threads: 5
8
+ }
9
+ end
10
+
11
+ def normalize_paths!
12
+ @params.each do |key, value|
13
+ @params[key] = value.gsub('\\', '/') if value.is_a?(String)
14
+ end
15
+ end
16
+
17
+ def display_help
18
+ help_text = <<~EOT
19
+ Standalone-Ruby - Make your projects installation independent!
20
+
21
+ Usage: ruby #{$0} [options]
22
+
23
+ Options:
24
+ -p, --project PROJECT_PATH Target Ruby project path.
25
+ Ensures that the given project path exists. If not, an error is displayed.
26
+
27
+ -r, --ruby RUBY_PATH Path to the Ruby interpreter.
28
+ Ensures that the given Ruby path exists and contains a 'bin' directory.
29
+
30
+ -m, --main MAIN_FILE Path to the main Ruby file of the project.
31
+ Ensures that the specified Ruby file exists.
32
+
33
+ -l, --launcher LAUNCHER Launcher file name (either .vbs or .bat).
34
+ Ensure the launcher file exists and is of the correct type (either .vbs or .bat).
35
+
36
+ -t, --template TEMPLATE Template file for launcher.
37
+ Ensures that the specified template file exists.
38
+
39
+ -c, --threads THREADS Number of threads to use (default is 5).
40
+ Determines the number of threads used during the Ruby interpreter copy process and for Rubocopy operations.
41
+ A higher number of threads can speed up the process, but requires more system resources.
42
+
43
+ -h, --help Show this help message
44
+
45
+ For more details, please visit the documentation at:
46
+ https://github.com/ardatetikbey/Standalone-Ruby
47
+
48
+ EOT
49
+
50
+ puts help_text
51
+ end
52
+
53
+
54
+ def parse
55
+ begin
56
+ OptionParser.new do |opts|
57
+ note = "Note: https://github.com/ardatetikbey/Standalone-Ruby Don't forget to review my github document to get the best results."
58
+ opts.banner = "Usage: ruby #{$0} [options]\n#{note}"
59
+
60
+ opts.on("-p", "--project PROJECT_PATH", String, "Target Ruby project path") do |project_path|
61
+ project_path.strip!
62
+ if Dir.exist?("#{project_path}")
63
+ @params[:project_path] = project_path
64
+ else
65
+ print("Parser Error: ".red); puts("The specified project path #{project_path} could not be found!")
66
+ exit!
67
+ end
68
+ end
69
+
70
+ opts.on("-r", "--ruby RUBY_PATH", String, "Ruby interpreter path") do |ruby_path|
71
+ ruby_path.strip!
72
+ if Dir.exist?("#{ruby_path}")
73
+ if Dir.exist?(File.join(ruby_path, "bin"))
74
+ @params[:ruby_path] = ruby_path
75
+ end
76
+ else
77
+ print("Parser Error: ".red); puts("The specified Ruby path #{ruby_path} could not be found!")
78
+ exit!
79
+ end
80
+ end
81
+
82
+ opts.on("-m", "--main MAIN_FILE", String, "Path to the main ruby file of the project") do |main_file|
83
+ main_file.strip!
84
+ if File.exist?(main_file)
85
+ @params[:main_file] = main_file
86
+ else
87
+ print("Parser Error: ".red); puts("The specified file #{main_file} could not be found!")
88
+ exit!
89
+ end
90
+ end
91
+
92
+ opts.on("-c", "--threads THREADS", Integer, "Number of threads to use (default is 5)") do |threads|
93
+ if threads.is_a?(Integer)
94
+ @params[:threads] = threads
95
+ else
96
+ print("Parser Error: ".red); puts("Invalid value for threads. Please provide an integer.")
97
+ exit!
98
+ end
99
+ end
100
+
101
+ opts.on("-l", "--launcher LAUNCHER", String, "Launcher file name.type (vbs or bat)") do |launcher|
102
+ launcher.strip!
103
+ if launcher.include?(".vbs")
104
+ @params[:launcher] = launcher
105
+ @params[:launcher_type] = "vbs"
106
+ @params[:launcher_name] = File.basename(launcher)
107
+ elsif launcher.include?(".bat")
108
+ @params[:launcher] = launcher
109
+ @params[:launcher_type] = "bat"
110
+ @params[:launcher_name] = File.basename(launcher)
111
+ else
112
+ print("Parser Error: ".red); puts("The supported launcher #{launcher} could not be found!")
113
+ exit!
114
+ end
115
+ end
116
+
117
+ opts.on("-t", "--template TEMPLATE", "Template file for launcher") do |template|
118
+ template.strip!
119
+ if File.exist?(template)
120
+ @params[:template] = template
121
+ else
122
+ print("Parser Error: ".red); puts("The specified template file #{template} could not be found!")
123
+ exit!
124
+ end
125
+ end
126
+
127
+ opts.on("-h", "--help", "Show this help message") do
128
+ display_help
129
+ exit!
130
+ end
131
+ end.parse!
132
+
133
+ if @params[:project_path].nil? || @params[:ruby_path].nil? || @params[:main_file].nil?
134
+ 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.")
135
+ exit!
136
+ end
137
+
138
+ normalize_paths!
139
+ rescue Exception => e
140
+ print("Parser Error: ".red); puts("#{e.message}".red)
141
+ end
142
+ end
143
+
144
+ def params
145
+ @params
146
+ end
147
+ end
148
+
149
+ class String
150
+ def red
151
+ "\e[31m#{self}\e[0m"
152
+ end
153
+
154
+ def green
155
+ "\e[32m#{self}\e[0m"
156
+ end
157
+
158
+ def magenta
159
+ "\e[35m#{self}\e[0m"
160
+ end
161
+
162
+ def yellow
163
+ "\e[33m#{self}\e[0m"
164
+ end
165
+ end
@@ -0,0 +1,21 @@
1
+ class RubyCopy
2
+ def initialize(params)
3
+ @params = params
4
+ end
5
+
6
+ def robocopy_interpreter
7
+ begin
8
+ puts("\nThe Ruby interpreter copying process has been started.")
9
+ print("WARNING: ".yellow); puts("If you are using a development kit, the copying process may take a long time.")
10
+
11
+ copy_output = `robocopy "#{@params[:ruby_path]}" "#{File.join(@params[:project_path].to_s, File.basename(@params[:ruby_path].to_s))}" /E /MT:#{@params[:threads].to_i} /V /ETA /NFL /NDL /R:1000000 /W:30 /NP`
12
+ puts "Robocopy Command: robocopy \"#{@params[:ruby_path]}\" \"#{File.join(@params[:project_path], File.basename(@params[:ruby_path]))}\" /E /MT:#{@params[:threads].to_i} /V /ETA /NFL /NDL /R:1000000 /W:30 /NP"
13
+
14
+ puts copy_output
15
+
16
+ puts("The Ruby interpreter copying process has been completed.")
17
+ rescue Exception => e
18
+ print("Copy Error: ".red); puts("#{e.message}".red)
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: standalone-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Arda Tetik
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-03-27 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Make your projects installation independent!
13
+ email:
14
+ - ardatetikruby@gmail.com
15
+ executables:
16
+ - standalone-ruby
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - README.md
22
+ - bin/standalone-ruby
23
+ - lib/data/bat/default_bat.txt
24
+ - lib/data/vbs/default_vbs.txt
25
+ - lib/standalone_ruby.rb
26
+ - lib/utils/displayer.rb
27
+ - lib/utils/launcher_handler.rb
28
+ - lib/utils/logger_helper.rb
29
+ - lib/utils/parameter_parser.rb
30
+ - lib/utils/ruby_copy.rb
31
+ homepage: https://github.com/ardatetikbey/Standalone-Ruby
32
+ licenses:
33
+ - MIT
34
+ metadata:
35
+ homepage_uri: https://github.com/ardatetikbey/Standalone-Ruby
36
+ source_code_uri: https://github.com/ardatetikbey/Standalone-Ruby
37
+ changelog_uri: https://github.com/ardatetikbey/Standalone-Ruby/blob/main/CHANGELOG.md
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 3.1.0
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.6.2
53
+ specification_version: 4
54
+ summary: Standalone Ruby application packager
55
+ test_files: []