Module: Opal
- Defined in:
- opal/lib/opal.rb,
opal/lib/opal/cli.rb,
opal/lib/opal/erb.rb,
opal/lib/opal/util.rb,
opal/lib/opal/parser.rb,
opal/lib/opal/builder.rb,
opal/lib/opal/version.rb,
opal/lib/opal/compiler.rb,
opal/lib/opal/fragment.rb,
opal/lib/opal/nodes/if.rb,
opal/lib/opal/nodes/def.rb,
opal/lib/opal/nodes/top.rb,
opal/lib/opal/nodes/base.rb,
opal/lib/opal/nodes/call.rb,
opal/lib/opal/nodes/case.rb,
opal/lib/opal/nodes/hash.rb,
opal/lib/opal/nodes/iter.rb,
opal/lib/opal/source_map.rb,
opal/lib/opal/cli_options.rb,
opal/lib/opal/nodes/array.rb,
opal/lib/opal/nodes/class.rb,
opal/lib/opal/nodes/logic.rb,
opal/lib/opal/nodes/masgn.rb,
opal/lib/opal/nodes/scope.rb,
opal/lib/opal/nodes/super.rb,
opal/lib/opal/nodes/while.rb,
opal/lib/opal/nodes/yield.rb,
opal/lib/opal/parser/sexp.rb,
opal/lib/opal/nodes/module.rb,
opal/lib/opal/nodes/rescue.rb,
opal/lib/opal/parser/lexer.rb,
opal/lib/opal/nodes/arglist.rb,
opal/lib/opal/nodes/defined.rb,
opal/lib/opal/nodes/helpers.rb,
opal/lib/opal/nodes/literal.rb,
opal/lib/opal/sprockets/erb.rb,
opal/lib/opal/parser/grammar.rb,
opal/lib/opal/nodes/constants.rb,
opal/lib/opal/nodes/variables.rb,
opal/lib/opal/parser/keywords.rb,
opal/lib/opal/sprockets/server.rb,
opal/lib/opal/nodes/definitions.rb,
opal/lib/opal/nodes/call_special.rb,
opal/lib/opal/parser/parser_scope.rb,
opal/lib/opal/sprockets/processor.rb,
opal/lib/opal/nodes/runtime_helpers.rb,
opal/lib/opal/nodes/singleton_class.rb,
opal/lib/opal/sprockets/environment.rb
Overview
Opal is a ruby to javascript compiler, with a runtime for running in any javascript environment.
Defined Under Namespace
Modules: ERB, Keywords, Nodes, Util Classes: Builder, CLI, CLIOptions, Compiler, Environment, Fragment, Lexer, Parser, ParserScope, Processor, Server, Sexp, SourceMap, SourceMapServer
Constant Summary
- VERSION =
'0.6.3'
Class Method Summary collapse
-
.append_path(path) ⇒ Object
Add a file path to opals load path.
- .compile(source, options = {}) ⇒ Object
- .core_dir ⇒ Object
- .gem_dir ⇒ Object
-
.paths ⇒ Object
Private, don't add to these directly (use .append_path instead).
-
.process(asset) ⇒ Object
Proccess using Sprockets.
- .std_dir ⇒ Object
- .use_gem(gem_name, include_dependecies = true) ⇒ Object
Class Method Details
.append_path(path) ⇒ Object
Add a file path to opals load path. Any gem containing ruby code that Opal has access to should add a load path through this method. Load paths added here should only be paths which contain code targeted at being compiled by Opal.
26 27 28 |
# File 'opal/lib/opal.rb', line 26 def self.append_path(path) paths << path end |
.compile(source, options = {}) ⇒ Object
7 8 9 |
# File 'opal/lib/opal/compiler.rb', line 7 def self.compile(source, = {}) Compiler.new.compile(source, ) end |
.core_dir ⇒ Object
14 15 16 |
# File 'opal/lib/opal.rb', line 14 def self.core_dir File.('../../opal', __FILE__.untaint) end |
.gem_dir ⇒ Object
10 11 12 |
# File 'opal/lib/opal.rb', line 10 def self.gem_dir File.('..', __FILE__.untaint) end |
.paths ⇒ Object
Private, don't add to these directly (use .append_path instead).
41 42 43 |
# File 'opal/lib/opal.rb', line 41 def self.paths @paths ||= [core_dir.untaint, std_dir.untaint, gem_dir.untaint] end |
.process(asset) ⇒ Object
Proccess using Sprockets
Opal.process('opal-jquery') # => String
9 10 11 |
# File 'opal/lib/opal/sprockets/environment.rb', line 9 def self.process asset Environment.new[asset].to_s end |
.std_dir ⇒ Object
18 19 20 |
# File 'opal/lib/opal.rb', line 18 def self.std_dir File.('../../stdlib', __FILE__.untaint) end |
.use_gem(gem_name, include_dependecies = true) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'opal/lib/opal.rb', line 30 def self.use_gem(gem_name, include_dependecies = true) spec = Gem::Specification.find_by_name(gem_name) spec.runtime_dependencies.each do |dependency| use_gem dependency.name end if include_dependecies Opal.append_path File.join(spec.gem_dir, 'lib') end |