Module: CoffeeScript::Source
- Defined in:
- lib/coffee_script.rb
Constant Summary collapse
- COMPILE_FUNCTION_SOURCE =
" ;function compile(script, options) {\n try {\n return CoffeeScript.compile(script, options);\n } catch (err) {\n if (err instanceof SyntaxError && err.location) {\n throw new SyntaxError([\n err.filename || \"[stdin]\",\n err.location.first_line + 1,\n err.location.first_column + 1\n ].join(\":\") + \": \" + err.message)\n } else {\n throw err;\n }\n }\n }\n"
Class Method Summary collapse
- .bare_option ⇒ Object
- .contents ⇒ Object
- .context ⇒ Object
- .path ⇒ Object
- .path=(path) ⇒ Object
- .version ⇒ Object
Class Method Details
.bare_option ⇒ Object
45 46 47 |
# File 'lib/coffee_script.rb', line 45 def self. ||= contents.match(/noWrap/) ? 'noWrap' : 'bare' end |
.contents ⇒ Object
37 38 39 |
# File 'lib/coffee_script.rb', line 37 def self.contents @contents ||= File.read(path) + COMPILE_FUNCTION_SOURCE end |
.context ⇒ Object
49 50 51 |
# File 'lib/coffee_script.rb', line 49 def self.context @context ||= ExecJS.compile(contents) end |
.path ⇒ Object
10 11 12 |
# File 'lib/coffee_script.rb', line 10 def self.path @path ||= ENV['COFFEESCRIPT_SOURCE_PATH'] || bundled_path end |
.path=(path) ⇒ Object
14 15 16 17 |
# File 'lib/coffee_script.rb', line 14 def self.path=(path) @contents = @version = = @context = nil @path = path end |
.version ⇒ Object
41 42 43 |
# File 'lib/coffee_script.rb', line 41 def self.version @version ||= contents[/CoffeeScript Compiler v([\d.]+)/, 1] end |