Class: ProxyPacRb::JavascriptCompiler
- Inherits:
-
Object
- Object
- ProxyPacRb::JavascriptCompiler
- Defined in:
- lib/proxy_pac_rb/javascript_compiler.rb
Overview
Compile javascript
Instance Method Summary collapse
- #compile(content:, environment:) ⇒ Object
-
#initialize(runtime: Runtimes.autodetect) ⇒ JavascriptCompiler
constructor
A new instance of JavascriptCompiler.
Constructor Details
#initialize(runtime: Runtimes.autodetect) ⇒ JavascriptCompiler
Returns a new instance of JavascriptCompiler.
11 12 13 14 15 |
# File 'lib/proxy_pac_rb/javascript_compiler.rb', line 11 def initialize( runtime: Runtimes.autodetect ) @runtime = runtime end |
Instance Method Details
#compile(content:, environment:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/proxy_pac_rb/javascript_compiler.rb', line 17 def compile(content:, environment:) raise Exceptions::RuntimeUnavailable, "#{runtime.name} is unavailable on this system" unless runtime.available? proxy_pac_content = content.to_s.dup proxy_pac_content = environment.prepare(proxy_pac_content) context = runtime.compile(proxy_pac_content) context.include environment Javascript.new(context) rescue StandardError => err raise CompilerError, err. end |