livescript 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +41 -0
- data/lib/livescript.rb +60 -0
- metadata +81 -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,41 @@
|
|
1
|
+
Ruby LiveScript
|
2
|
+
=================
|
3
|
+
|
4
|
+
Ruby LiveScript is a bridge to the official LiveScript compiler.
|
5
|
+
|
6
|
+
LiveScript.compile File.read("script.ls)
|
7
|
+
|
8
|
+
This gem is a fork of `ruby-coffee-script` adapted for LiveScript.
|
9
|
+
|
10
|
+
Installation
|
11
|
+
------------
|
12
|
+
|
13
|
+
gem install livescript
|
14
|
+
|
15
|
+
|
16
|
+
Dependencies
|
17
|
+
------------
|
18
|
+
|
19
|
+
This library depends on the `livescript-source` gem which is
|
20
|
+
updated any time a new version of LiveScript is released. (The
|
21
|
+
`livescript-source` gem's version number is synced with each
|
22
|
+
official LiveScript release.) This way you can build against
|
23
|
+
different versions of LiveScript by requiring the correct version of
|
24
|
+
the `livescript-source` gem.
|
25
|
+
|
26
|
+
In addition, you can use this library with unreleased versions of
|
27
|
+
LiveScript by setting the `LIVESCRIPT_SOURCE_PATH` environment
|
28
|
+
variable:
|
29
|
+
|
30
|
+
export LIVESCRIPT_SOURCE_PATH=/path/to/LiveScript/extras/livescript.js
|
31
|
+
|
32
|
+
### JSON
|
33
|
+
|
34
|
+
The `json` library is also required but is not explicitly stated as a
|
35
|
+
gem dependency. If you're on Ruby 1.8 you'll need to install the
|
36
|
+
`json` or `json_pure` gem. On Ruby 1.9, `json` is included in the
|
37
|
+
standard library.
|
38
|
+
|
39
|
+
### ExecJS
|
40
|
+
|
41
|
+
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.
|
data/lib/livescript.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'execjs'
|
2
|
+
require 'livescript/source'
|
3
|
+
|
4
|
+
module LiveScript
|
5
|
+
EngineError = ExecJS::RuntimeError
|
6
|
+
CompilationError = ExecJS::ProgramError
|
7
|
+
|
8
|
+
module Source
|
9
|
+
def self.path
|
10
|
+
@path ||= ENV['LIVESCRIPT_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[/LiveScript 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("LiveScript.compile", script, options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: livescript
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Victor Hugo Borja
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2010-03-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: livescript-source
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: execjs
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: ! ' Ruby LiveScript is a bridge to the JS LiveScript compiler.
|
47
|
+
|
48
|
+
'
|
49
|
+
email: vic.borja@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- lib/livescript.rb
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
homepage: http://github.com/Roonin-mx/livescript-ruby
|
58
|
+
licenses: []
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.8.24
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Ruby LiveScript Compiler
|
81
|
+
test_files: []
|