Class: ExecJS::ExternalRuntime
- Inherits:
-
Runtime
- Object
- Runtime
- ExecJS::ExternalRuntime
- Defined in:
- lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #deprecated? ⇒ Boolean
- #exec_runtime(filename) ⇒ Object
-
#initialize(options) ⇒ ExternalRuntime
constructor
A new instance of ExternalRuntime.
Constructor Details
#initialize(options) ⇒ ExternalRuntime
Returns a new instance of ExternalRuntime.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb', line 92 def initialize() @name = [:name] @command = [:command] @runner_path = [:runner_path] @encoding = [:encoding] @deprecated = !![:deprecated] @binary = nil @popen_options = {} @popen_options[:external_encoding] = @encoding if @encoding @popen_options[: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.
90 91 92 |
# File 'lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb', line 90 def name @name end |
Instance Method Details
#available? ⇒ Boolean
109 110 111 112 |
# File 'lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb', line 109 def available? require 'json' binary ? true : false end |
#deprecated? ⇒ Boolean
114 115 116 |
# File 'lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb', line 114 def deprecated? @deprecated end |
#exec_runtime(filename) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb', line 171 def exec_runtime(filename) path = Dir::Tmpname.create(['execjs', 'json']) {} begin command = binary.split(" ") << filename `#{shell_escape(*command)} 2>&1 > #{path}` output = File.open(path, 'rb', **@popen_options) { |f| f.read } ensure File.unlink(path) if path end if $?.success? output else raise exec_runtime_error(output) end end |