lib/ruby2js.rb in ruby2js-3.0.11 vs lib/ruby2js.rb in ruby2js-3.0.12
- old
+ new
@@ -7,10 +7,11 @@
ensure
$VERBOSE = old_verbose
end
require 'ruby2js/converter'
+require 'ruby2js/filter'
module Ruby2JS
class SyntaxError < RuntimeError
end
@@ -46,19 +47,28 @@
@ast.updated(type, args)
end
end
class Processor < Parser::AST::Processor
+ include Ruby2JS::Filter
BINARY_OPERATORS = Converter::OPERATORS[2..-1].flatten
def initialize(comments)
@comments = comments
@ast = nil
end
def options=(options)
@options = options
+
+ @included = @@included
+ @excluded = @@excluded
+
+ include_all if options[:include_all]
+ include_only(options[:include_only]) if options[:include_only]
+ include(options[:include]) if options[:include]
+ exclude(options[:exclude]) if options[:exclude]
end
def es2015
@options[:eslevel] >= 2015
end
@@ -146,14 +156,16 @@
end
filters = options[:filters] || Filter::DEFAULTS
unless filters.empty?
+
filter = Filter::Processor
filters.reverse.each do |mod|
filter = Class.new(filter) {include mod}
end
filter = filter.new(comments)
+
filter.options = options
ast = filter.process(ast)
end
ruby2js = Ruby2JS::Converter.new(ast, comments)