coffee-script-redux 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2010 Joshua Peek
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ Ruby CoffeeScript
2
+ =================
3
+
4
+ Ruby CoffeeScript is a bridge to the official CoffeeScript compiler.
5
+
6
+ CoffeeScript.compile File.read("script.coffee")
7
+
8
+
9
+ Installation
10
+ ------------
11
+
12
+ gem install coffee-script
13
+
14
+ *Note: This compiler library has replaced the original CoffeeScript
15
+ compiler that was written in Ruby.*
16
+
17
+
18
+ Dependencies
19
+ ------------
20
+
21
+ This library depends on the `coffee-script-source` gem which is
22
+ updated any time a new version of CoffeeScript is released. (The
23
+ `coffee-script-source` gem's version number is synced with each
24
+ official CoffeeScript release.) This way you can build against
25
+ different versions of CoffeeScript by requiring the correct version of
26
+ the `coffee-script-source` gem.
27
+
28
+ In addition, you can use this library with unreleased versions of
29
+ CoffeeScript by setting the `COFFEESCRIPT_SOURCE_PATH` environment
30
+ variable:
31
+
32
+ export COFFEESCRIPT_SOURCE_PATH=/path/to/coffee-script/extras/coffee-script.js
33
+
34
+ ### JSON
35
+
36
+ The `json` library is also required but is not explicitly stated as a
37
+ gem dependency. If you're on Ruby 1.8 you'll need to install the
38
+ `json` or `json_pure` gem. On Ruby 1.9, `json` is included in the
39
+ standard library.
40
+
41
+ ### ExecJS
42
+
43
+ The [ExecJS](https://github.com/sstephenson/execjs) library is used to automatically choose the best JavaScript engine for your platform. Check out its [README](https://github.com/sstephenson/execjs/blob/master/README.md) for a complete list of supported engines.
@@ -0,0 +1 @@
1
+ require 'coffee_script'
@@ -0,0 +1,60 @@
1
+ require 'execjs'
2
+ require 'coffee_script/source'
3
+
4
+ module CoffeeScript
5
+ EngineError = ExecJS::RuntimeError
6
+ CompilationError = ExecJS::ProgramError
7
+
8
+ module Source
9
+ def self.path
10
+ @path ||= ENV['COFFEESCRIPT_SOURCE_PATH'] || bundled_path
11
+ end
12
+
13
+ def self.path=(path)
14
+ @contents = @version = @bare_option = @context = nil
15
+ @path = path
16
+ end
17
+
18
+ def self.contents
19
+ @contents ||= File.read(path)
20
+ end
21
+
22
+ def self.version
23
+ @version ||= contents[/CoffeeScript Compiler v([\d.]+)/, 1]
24
+ end
25
+
26
+ def self.bare_option
27
+ @bare_option ||= contents.match(/noWrap/) ? 'noWrap' : 'bare'
28
+ end
29
+
30
+ def self.context
31
+ @context ||= ExecJS.compile(contents)
32
+ end
33
+ end
34
+
35
+ class << self
36
+ def engine
37
+ end
38
+
39
+ def engine=(engine)
40
+ end
41
+
42
+ def version
43
+ Source.version
44
+ end
45
+
46
+ # Compile a script (String or IO) to JavaScript.
47
+ def compile(script, options = {})
48
+ script = script.read if script.respond_to?(:read)
49
+
50
+ if options.key?(:bare)
51
+ elsif options.key?(:no_wrap)
52
+ options[:bare] = options[:no_wrap]
53
+ else
54
+ options[:bare] = false
55
+ end
56
+
57
+ Source.context.call("CoffeeScript.compile", script, options)
58
+ end
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coffee-script-redux
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeremy Ashkenas
9
+ - Joshua Peek
10
+ - Sam Stephenson
11
+ - Sam Goldman
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2010-11-01 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: coffee-script-redux-source
19
+ requirement: !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: execjs
35
+ requirement: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ description: ! ' Ruby CoffeeScriptRedux is a bridge to the JS CoffeeScriptRedux
50
+ compiler.
51
+
52
+ '
53
+ email: sam@smartlogicsolutions.com
54
+ executables: []
55
+ extensions: []
56
+ extra_rdoc_files: []
57
+ files:
58
+ - lib/coffee-script.rb
59
+ - lib/coffee_script.rb
60
+ - LICENSE
61
+ - README.md
62
+ homepage: http://github.com/samwgoldman/ruby-coffee-script-redux
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.24
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Ruby CoffeeScriptRedux Compiler
86
+ test_files: []