Class: NodeRunner::Executor
- Inherits:
-
Object
- Object
- NodeRunner::Executor
- Defined in:
- lib/node-runner.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #exec(filename) ⇒ Object
-
#initialize(options = {}) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(options = {}) ⇒ Executor
Returns a new instance of Executor.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/node-runner.rb', line 86 def initialize( = {}) @command = [:command] || ['node'] @modules_path = [:modules_path] || File.join(Dir.pwd, "node_modules") @runner_path = [:runner_path] || File.join(File.(__dir__), '/node_runner.js') @encoding = [:encoding] || "UTF-8" @binary = nil = {} [:external_encoding] = @encoding if @encoding [:internal_encoding] = ::Encoding.default_internal || 'UTF-8' if @runner_path instance_eval generate_compile_method(@runner_path) end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
84 85 86 |
# File 'lib/node-runner.rb', line 84 def name @name end |
Instance Method Details
#exec(filename) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/node-runner.rb', line 102 def exec(filename) ENV["NODE_PATH"] = @modules_path stdout, stderr, status = Open3.capture3("#{binary} #{filename}") if status.success? stdout else raise exec_runtime_error(stderr) end end |