Runtime
# File lib/execjs/external_runtime.rb, line 71 def initialize(options) @name = options[:name] @command = options[:command] @runner_path = options[:runner_path] @encoding = options[:encoding] @deprecated = !!options[: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
# File lib/execjs/external_runtime.rb, line 88 def available? require 'json' binary ? true : false end
# File lib/execjs/external_runtime.rb, line 133 def encode_source(source) encoded_source = encode_unicode_codepoints(source) ::JSON.generate("(function(){ #{encoded_source} })()", quirks_mode: true) end
# File lib/execjs/external_runtime.rb, line 138 def encode_unicode_codepoints(str) str.gsub(/[\u0080-\uffff]/) do |ch| "\\u%04x" % ch.codepoints.to_a end end
# File lib/execjs/external_runtime.rb, line 119 def generate_compile_method(path) def compile_source(source) <<-RUNNER #{IO.read(path)} RUNNER end end
# File lib/execjs/external_runtime.rb, line 129 def json2_source @json2_source ||= IO.read(ExecJS.root + "/support/json2.js") end
Internally exposed for Context.
# File lib/execjs/external_runtime.rb, line 158 def which(command) Array(command).find do |name| name, args = name.split(/\s+/, 2) path = locate_executable(name) next unless path args ? "#{path} #{args}" : path end end
Generated with the Darkfish Rdoc Generator 2.