iced-coffee-script 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +22 -0
- data/README.md +43 -0
- data/lib/iced-coffee-script.rb +1 -0
- data/lib/iced_coffee_script.rb +60 -0
- metadata +72 -0
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 IcedCoffeeScript
|
2
|
+
=================
|
3
|
+
|
4
|
+
Ruby IcedCoffeeScript is a bridge to the official CoffeeScript compiler.
|
5
|
+
|
6
|
+
IcedCoffeeScript.compile File.read("script.coffee")
|
7
|
+
|
8
|
+
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
|
12
|
+
gem install iced-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
|
+
`iced-coffee-script-source` gem's version number is synced with each
|
24
|
+
official IcedCoffeeScript release.) This way you can build against
|
25
|
+
different versions of IcedCoffeeScript by requiring the correct version of
|
26
|
+
the `iced-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 'iced_coffee_script'
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'execjs'
|
2
|
+
require 'iced_coffee_script/source'
|
3
|
+
|
4
|
+
module IcedCoffeeScript
|
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[/IcedCoffeeScript 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,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iced-coffee-script
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Max Krohn
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2010-03-11 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: iced-coffee-script-source
|
16
|
+
requirement: &13423880 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *13423880
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: execjs
|
27
|
+
requirement: &13423440 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *13423440
|
36
|
+
description: ! ' Ruby IcedCoffeeScript is a bridge to the JS CoffeeScript compiler.
|
37
|
+
|
38
|
+
'
|
39
|
+
email: themax@gmail.com
|
40
|
+
executables: []
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- lib/iced-coffee-script.rb
|
45
|
+
- lib/iced_coffee_script.rb
|
46
|
+
- LICENSE
|
47
|
+
- README.md
|
48
|
+
homepage: http://github.com/maxtaco/ruby-coffee-script
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.12
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Ruby IcedCoffeeScript Compiler
|
72
|
+
test_files: []
|