Skip to content

Commit

Permalink
Make opal-parser.rb simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 30, 2013
1 parent 87fb01a commit 0a9aad2
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lib/opal.rb
Expand Up @@ -43,6 +43,6 @@ def self.use_gem(gem_name, include_dependecies = true)

# Private, don't add to these directly (use .append_path instead).
def self.paths
@paths ||= [core_dir.untaint, std_dir.untaint]
@paths ||= [core_dir.untaint, std_dir.untaint, gem_dir.untaint]
end
end
2 changes: 1 addition & 1 deletion lib/opal/source_map.rb
@@ -1,4 +1,4 @@
require 'opal'
# require 'opal'
require 'source_map'

module Opal
Expand Down
28 changes: 0 additions & 28 deletions stdlib/opal-gem.js.erb

This file was deleted.

40 changes: 39 additions & 1 deletion stdlib/opal-parser.rb
@@ -1,8 +1,46 @@
require 'opal-gem'
require 'opal/compiler'
require 'opal/builder'
require 'opal/erb'
require 'opal/version'

module Opal
def self.compile(source, options = {})
Compiler.new.compile(source, options)
end
end

module Kernel
def eval(str)
code = Opal.compile str
`eval(#{code})`
end
end

%x{
Opal.compile = function(str) {
return Opal.Opal.$compile(str);
};
Opal.eval = function(str) {
return eval(Opal.compile(str));
};
function run_ruby_scripts() {
var tags = document.getElementsByTagName('script');
for (var i = 0, len = tags.length; i < len; i++) {
if (tags[i].type === "text/ruby") {
Opal.eval(tags[i].innerHTML);
}
}
}
if (typeof(document) !== 'undefined') {
if (window.addEventListener) {
window.addEventListener('DOMContentLoaded', run_ruby_scripts, false);
}
else {
window.attachEvent('onload', run_ruby_scripts);
}
}
}
3 changes: 0 additions & 3 deletions stdlib/racc/parser.rb.rb

This file was deleted.

0 comments on commit 0a9aad2

Please sign in to comment.