Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.tool.ruby.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2026 Bearsampp
4 * License: GNU General Public License version 3 or later; see LICENSE.txt
5 * Author: Bear
6 * Website: https://bearsampp.com
7 * Github: https://github.com/Bearsampp
8 */
9
18class ToolRuby extends Module
19{
23 const ROOT_CFG_VERSION = 'rubyVersion';
24
28 const LOCAL_CFG_EXE = 'rubyExe';
29
33 const LOCAL_CFG_CONSOLE_EXE = 'rubyConsoleExe';
34
38 private $exe;
39
43 private $consoleExe;
44
51 public function __construct($id, $type)
52 {
53 Log::initClass($this);
54 $this->reload($id, $type);
55 }
56
63 public function reload($id = null, $type = null)
64 {
66 Log::reloadClass($this);
67
68 $this->name = $bearsamppLang->getValue(Lang::RUBY);
69 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
70 parent::reload($id, $type);
71
72 if ($this->bearsamppConfRaw !== false) {
73 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
74 $this->consoleExe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONSOLE_EXE];
75 }
76
77 if (!$this->enable) {
78 Log::info($this->name . ' is not enabled!');
79
80 return;
81 }
82 if (!is_dir($this->currentPath)) {
83 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
84 }
85 if (!is_dir($this->symlinkPath)) {
86 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
87
88 return;
89 }
90 if (!is_file($this->bearsamppConf)) {
91 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
92 }
93 if (!is_file($this->exe)) {
94 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
95 }
96 if (!is_file($this->consoleExe)) {
97 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->consoleExe));
98 }
99 }
100
106 public function setVersion($version)
107 {
108 global $bearsamppConfig;
109 $this->version = $version;
110 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
111 $this->reload();
112 }
113
119 public function getExe()
120 {
121 return $this->exe;
122 }
123
129 public function getConsoleExe()
130 {
131 return $this->consoleExe;
132 }
133}
134
global $bearsamppLang
const RUBY
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const ERROR_FILE_NOT_FOUND
static info($data, $file=null)
static reloadClass($classInstance)
static error($data, $file=null)
static initClass($classInstance)
const LOCAL_CFG_EXE
const LOCAL_CFG_CONSOLE_EXE
setVersion($version)
reload($id=null, $type=null)
const ROOT_CFG_VERSION
__construct($id, $type)
global $bearsamppConfig
Definition homepage.php:46