Sha256: eae29b8425429fbe04da6bb2bbab4724a735ae01bdcac9ddabf6b4d743360bb9

Contents?: true

Size: 841 Bytes

Versions: 8

Compression:

Stored size: 841 Bytes

Contents

# ==========================================================================
# Project:   Spade - CommonJS Runtime
# Copyright: ©2010 Strobe Inc. All rights reserved.
# License:   Licened under MIT license (see LICENSE)
# ==========================================================================

module Spade

  # Compiler plugin for the default context.  Know how to create a new
  # isolated context for the object
  class Compiler
    
    def initialize(ctx)
      @ctx = ctx
    end
    
    def setup(sandbox)
      if sandbox['isIsolated']
        sandbox['ctx'] = Context.new :reactor => @ctx.reactor
      end
    end
    
    def compile(data, sandbox, filename)
      ctx = sandbox['ctx'] || @ctx
      ctx.eval("(#{data})", filename)
    end
    
    def teardown(sandbox)
      sandbox['ctx'] = nil
    end
    
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spade-0.0.8.1 lib/spade/compiler.rb
spade-0.0.7 lib/spade/compiler.rb
spade-0.0.6 lib/spade/compiler.rb
spade-0.0.5 lib/spade/compiler.rb
spade-0.0.4 lib/spade/compiler.rb
spade-0.0.3 lib/spade/compiler.rb
spade-0.0.2 lib/spade/compiler.rb
spade-0.0.1 lib/spade/compiler.rb