cough-syrup 0.0.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.
- checksums.yaml +7 -0
- data/LICENSE +24 -0
- data/README.md +39 -0
- data/lib/cough-syrup.rb +1 -0
- data/lib/cough_syrup.rb +60 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1b2d3a93e5ffd80f40b6a99a0c70dc15b03518e4
|
4
|
+
data.tar.gz: 5de6ba39e03f028dbb5321c72c9b1afedbb30dc4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e07db6658fe7bfbea7e2579e3840759b7c33469e1a1a8f37299ce9d8da1c362451e86e4005a1cac72417090ec67a7c6442be26f10e089a10c5fb5124c94b270
|
7
|
+
data.tar.gz: a68fcb46604d20417e49433392df6fbaf0aeb9451ab342aaae8c2cf989e25a944d3ccdcabe253023a14c3e1ec5854336bc65cdcb2ba196166626b31c4fa3b419
|
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2014 Matthew Hilty
|
2
|
+
|
3
|
+
(Original project by Joshua Peek)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
6
|
+
obtaining a copy of this software and associated documentation
|
7
|
+
files (the "Software"), to deal in the Software without
|
8
|
+
restriction, including without limitation the rights to use,
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the
|
11
|
+
Software is furnished to do so, subject to the following
|
12
|
+
conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
Ruby CoughSyrup
|
2
|
+
=================
|
3
|
+
|
4
|
+
Ruby CoughSyrup is a bridge to the official CoughSyrup compiler.
|
5
|
+
|
6
|
+
CoughSyrup.compile File.read("script.cough")
|
7
|
+
|
8
|
+
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
|
12
|
+
gem install cough-syrup
|
13
|
+
|
14
|
+
Dependencies
|
15
|
+
------------
|
16
|
+
|
17
|
+
This library depends on the `cough-syrup-source` gem which is
|
18
|
+
updated any time a new version of CoughSyrup is released. (The
|
19
|
+
`cough-syrup-source` gem's version number is synced with each
|
20
|
+
official CoughSyrup release.) This way you can build against
|
21
|
+
different versions of CoughSyrup by requiring the correct version of
|
22
|
+
the `cough-syrup-source` gem.
|
23
|
+
|
24
|
+
In addition, you can use this library with unreleased versions of
|
25
|
+
CoughSyrup by setting the `COUGHSYRUP_SOURCE_PATH` environment
|
26
|
+
variable:
|
27
|
+
|
28
|
+
export COUGHSYRUP_SOURCE_PATH=/path/to/cough-syrup/extras/cough-syrup.js
|
29
|
+
|
30
|
+
### JSON
|
31
|
+
|
32
|
+
The `json` library is also required but is not explicitly stated as a
|
33
|
+
gem dependency. If you're on Ruby 1.8 you'll need to install the
|
34
|
+
`json` or `json_pure` gem. On Ruby 1.9, `json` is included in the
|
35
|
+
standard library.
|
36
|
+
|
37
|
+
### ExecJS
|
38
|
+
|
39
|
+
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/cough-syrup.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'cough_syrup'
|
data/lib/cough_syrup.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'execjs'
|
2
|
+
require 'cough_syrup/source'
|
3
|
+
|
4
|
+
module CoughSyrup
|
5
|
+
EngineError = ExecJS::RuntimeError
|
6
|
+
CompilationError = ExecJS::ProgramError
|
7
|
+
|
8
|
+
module Source
|
9
|
+
def self.path
|
10
|
+
@path ||= ENV['COUGHSYRUP_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[/CoughSyrup 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("CoughSyrup.compile", script, options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cough-syrup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Ashkenas
|
8
|
+
- Joshua Peek
|
9
|
+
- Sam Stephenson
|
10
|
+
- Matthew Hilty
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: cough-syrup-source
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
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
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: json
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
description: Ruby CoughSyrup is a bridge to the JS CoughSyrup transpiler.
|
73
|
+
email: hilty.matthew@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- lib/cough_syrup.rb
|
81
|
+
- lib/cough-syrup.rb
|
82
|
+
homepage: http://rubygems.org/gems/cough-syrup
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.1.9
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Ruby CoughSyrup Transpiler
|
106
|
+
test_files: []
|