Sha256: 10519d4dc9d484aeb8c4a7e4a19025c86bd61b87e3080561f2ee4949a08925dd

Contents?: true

Size: 1.2 KB

Versions: 71

Compression:

Stored size: 1.2 KB

Contents

require 'execjs'
require 'coffee_script/source'

module CoffeeScript
  EngineError      = ExecJS::RuntimeError
  CompilationError = ExecJS::ProgramError

  module Source
    def self.path
      @path ||= ENV['COFFEESCRIPT_SOURCE_PATH'] || bundled_path
    end

    def self.path=(path)
      @contents = @version = @bare_option = @context = nil
      @path = path
    end

    def self.contents
      @contents ||= File.read(path)
    end

    def self.version
      @version ||= contents[/CoffeeScript Compiler v([\d.]+)/, 1]
    end

    def self.bare_option
      @bare_option ||= contents.match(/noWrap/) ? 'noWrap' : 'bare'
    end

    def self.context
      @context ||= ExecJS.compile(contents)
    end
  end

  class << self
    def engine
    end

    def engine=(engine)
    end

    def version
      Source.version
    end

    # Compile a script (String or IO) to JavaScript.
    def compile(script, options = {})
      script = script.read if script.respond_to?(:read)

      if options.key?(:bare)
      elsif options.key?(:no_wrap)
        options[:bare] = options[:no_wrap]
      else
        options[:bare] = false
      end

      Source.context.call("CoffeeScript.compile", script, options)
    end
  end
end

Version data entries

71 entries across 71 versions & 8 rubygems

Version Path
classiccms-0.5.6 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.5.5 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.5.2 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.5.1 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.5.0 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.4.2 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.4.1 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.4.0 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.3.9 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.3.8 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.3.7 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.3.6 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.3.5 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.3.4 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.3.3 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb
classiccms-0.3.2 vendor/bundle/gems/coffee-script-2.2.0/lib/coffee_script.rb