Module: Prremote::Mrbc

Defined in:
lib/prremote/mrbc.rb

Constant Summary collapse

SHIMS_RE =
%r{\.rbenv/shims}

Class Method Summary collapse

Class Method Details

.binObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/prremote/mrbc.rb', line 7

def self.bin
  return ENV['MRBC'] if ENV['MRBC'] && File.executable?(ENV['MRBC'])

  found = ENV['PATH'].split(File::PATH_SEPARATOR)
                     .grep_v(SHIMS_RE)
                     .map    { |d| File.join(d, 'mrbc') }
                     .find   { |f| File.executable?(f) }

  found || raise('mrbc not found. Install mruby: brew install mruby')
end

.versionObject



18
19
20
21
22
23
# File 'lib/prremote/mrbc.rb', line 18

def self.version
  out, = Open3.capture2e(bin, '--version')
  out.strip
rescue RuntimeError
  '(mrbc not found)'
end