ruby-coco 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/coco.rb +60 -0
- data/lib/coco/version.rb +3 -0
- data/lib/ruby-coco.rb +1 -0
- metadata +70 -0
data/lib/coco.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'execjs'
|
2
|
+
require 'coco/source'
|
3
|
+
|
4
|
+
module Coco
|
5
|
+
EngineError = ExecJS::RuntimeError
|
6
|
+
CompilationError = ExecJS::ProgramError
|
7
|
+
|
8
|
+
module Source
|
9
|
+
def self.path
|
10
|
+
@path ||= ENV['COCO_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[/Coco ([\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
|
+
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("Coco.compile", script, options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/coco/version.rb
ADDED
data/lib/ruby-coco.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'coco'
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-coco
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jacob Swanner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ruby-coco-source
|
16
|
+
requirement: &70324204130540 !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: *70324204130540
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: execjs
|
27
|
+
requirement: &70324204130080 !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: *70324204130080
|
36
|
+
description: Ruby Coco is a bridge to the JS Coco compiler.
|
37
|
+
email:
|
38
|
+
- jacob@jacobswanner.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- lib/coco.rb
|
44
|
+
- lib/coco/version.rb
|
45
|
+
- lib/ruby-coco.rb
|
46
|
+
homepage: https://github.com/jswanner/ruby-coco
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.11
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Coco Compiler as ruby gem.
|
70
|
+
test_files: []
|