Module: Xpring::Javascript

Defined in:
lib/xpring/javascript.rb

Overview

Basic Ruby to Javascript interop

Constant Summary collapse

ENTRY_POINT =
"XpringCommonJS"
LIBRARY_PATH =
File.expand_path("./javascript/library.js", __dir__)

Class Method Summary collapse

Class Method Details

.runHash<Symbol, Object>, ...

Yield Returns:

  • (String)

Returns:

  • (Hash<Symbol, Object>, String, nil)


17
18
19
20
21
22
23
# File 'lib/xpring/javascript.rb', line 17

def self.run
  script = prepare(yield)
  cmd = "node -p #{script.dump}"
  Xpring.debug_log(cmd)
  raw = IO.popen(cmd, &:readlines).first&.strip
  parse(raw)
end