Bearsampp 2025.8.29
Loading...
Searching...
No Matches
class.tool.ruby.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2024 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 Util::logInitClass($this);
53 $this->reload($id, $type);
54 }
55
62 public function reload($id = null, $type = null) {
65
66 $this->name = $bearsamppLang->getValue(Lang::RUBY);
67 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
68 parent::reload($id, $type);
69
70 if ($this->bearsamppConfRaw !== false) {
71 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
72 $this->consoleExe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONSOLE_EXE];
73 }
74
75 if (!$this->enable) {
76 Util::logInfo($this->name . ' is not enabled!');
77 return;
78 }
79 if (!is_dir($this->currentPath)) {
80 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
81 }
82 if (!is_dir($this->symlinkPath)) {
83 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
84 return;
85 }
86 if (!is_file($this->bearsamppConf)) {
87 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
88 }
89 if (!is_file($this->exe)) {
90 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
91 }
92 if (!is_file($this->consoleExe)) {
93 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->consoleExe));
94 }
95 }
96
102 public function setVersion($version) {
103 global $bearsamppConfig;
104 $this->version = $version;
105 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
106 $this->reload();
107 }
108
114 public function getExe() {
115 return $this->exe;
116 }
117
123 public function getConsoleExe() {
124 return $this->consoleExe;
125 }
126}
global $bearsamppLang
const RUBY
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const ERROR_FILE_NOT_FOUND
const LOCAL_CFG_EXE
const LOCAL_CFG_CONSOLE_EXE
setVersion($version)
reload($id=null, $type=null)
const ROOT_CFG_VERSION
__construct($id, $type)
static logError($data, $file=null)
static logInitClass($classInstance)
static logInfo($data, $file=null)
static logReloadClass($classInstance)
global $bearsamppConfig
Definition homepage.php:27