Module: Arkrb

Defined in:
lib/arkrb.rb,
lib/arkrb/cli.rb,
lib/arkrb/error.rb,
lib/arkrb/server.rb,
lib/arkrb/install.rb,
lib/arkrb/version.rb,
lib/arkrb/constants.rb,
lib/arkrb/server/mod.rb,
lib/arkrb/server/mods.rb,
lib/arkrb/error_parsing.rb,
lib/arkrb/output_parsing.rb

Defined Under Namespace

Modules: Error Classes: CLI, ErrorParsing, Install, Mod, Mods, OutputParsing, Server

Constant Summary collapse

VERSION =
'0.6.0'
BASH_EXEC =
find_executable0 'bash'
CURL_EXEC =
find_executable0 'curl'
USER_HOME =
Dir.home
ARK_SERVER_TOOLS_MD5 =
'773b17d67eff8944bcd0e2a39089c96d'

Class Method Summary collapse

Class Method Details

.executable(path = "#{USER_HOME}/bin") ⇒ String

Returns:

  • (String)

Raises:



15
16
17
18
19
20
21
22
# File 'lib/arkrb.rb', line 15

def self.executable(path = "#{USER_HOME}/bin")
  old_mkmf_log = MakeMakefile::Logging.instance_variable_get(:@logfile)
  MakeMakefile::Logging.instance_variable_set(:@logfile, '/dev/null')
  arkmanager_exec = find_executable0('arkmanager', path)
  MakeMakefile::Logging.instance_variable_set(:@logfile, old_mkmf_log)
  raise Arkrb::Error::ArkManagerExecutableNotFound, 'We could not find the ark_rb binary! Please install it by running Arkrb.install.server_tools or executing the command `ark_rb install tools``' if arkmanager_exec.nil?
  arkmanager_exec
end

.execute(command, command_opts = '', instance = 'main', sanitize = false) ⇒ Integer, String

Returns:

  • (Integer, String)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/arkrb.rb', line 25

def self.execute(command, command_opts = '', instance = 'main', sanitize = false)
  exec_this = format('%s %s %s @%s', executable, command.to_s.tr('_', ''), command_opts, instance)
  stdin, stdout, stderr = Open3.popen3(exec_this)
  output = stdout.read.chomp
  errors = stderr.read.chomp
  errors += 'Your ARK server exec could not be found.' if output =~ /#{'ARK server exec could not be found'}/im

  Arkrb::ErrorParsing.new.sanitize!(command, errors) unless errors.strip.empty?

  if sanitize
    output_parsing = Arkrb::OutputParsing.new
    output_parsing.sanitize!(command, output)
  else
    puts output
    puts errors
  end

end

.installArkrb::Install

Returns:



10
11
12
# File 'lib/arkrb.rb', line 10

def self.install
  Arkrb::Install.new
end