Sha256: fa538ad127e1d467d8168537351fb433affe6d4a0dd797cf79e2900f6bd7d66e

Contents?: true

Size: 603 Bytes

Versions: 2

Compression:

Stored size: 603 Bytes

Contents

module ProxyPacRb
  # Compile javascript
  class JavascriptCompiler
    private

    attr_reader :runtime

    public

    def initialize(
      runtime: Runtimes.autodetect
    )
      @runtime = runtime
    end

    def compile(content:, environment:)
      fail Exceptions::RuntimeUnavailable, "#{runtime.name} is unavailable on this system" unless runtime.available?

      environment.prepare(content)

      context = runtime.compile(content)
      context.include environment

      Javascript.new(context)
    rescue StandardError => err
      raise CompilerError, err.message
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proxy_pac_rb-0.5.1 lib/proxy_pac_rb/javascript_compiler.rb
proxy_pac_rb-0.5.0 lib/proxy_pac_rb/javascript_compiler.rb