class Opal::BuilderProcessors::Processor

Attributes

extensions[R]
abs_path[R]
autoloads[R]
filename[R]
options[R]
required_trees[R]
requires[R]
source[R]

Public Class Methods

handles(*extensions) click to toggle source
# File lib/opal/builder_processors.rb, line 28
def handles(*extensions)
  @extensions = extensions
  matches = extensions.join('|')
  matches = "(#{matches})" unless extensions.size == 1
  @match_regexp = Regexp.new "\\.#{matches}#{REGEXP_END}"

  ::Opal::Builder.register_processor(self, extensions)
  nil
end
match?(other) click to toggle source
# File lib/opal/builder_processors.rb, line 38
def match?(other)
  other.is_a?(String) && other.match(match_regexp)
end
match_regexp() click to toggle source
# File lib/opal/builder_processors.rb, line 42
def match_regexp
  @match_regexp || raise(NotImplementedError)
end
new(source, filename, abs_path = nil, options = {}) click to toggle source
# File lib/opal/builder_processors.rb, line 9
def initialize(source, filename, abs_path = nil, options = {})
  options = abs_path if abs_path.is_a? Hash

  source += "\n" unless source.end_with?("\n")
  @source, @filename, @abs_path, @options = source, filename, abs_path, options.dup
  @cache = @options.delete(:cache) { Opal.cache }
  @requires = []
  @required_trees = []
  @autoloads = []
end

Public Instance Methods

mark_as_required(filename) click to toggle source
# File lib/opal/builder_processors.rb, line 47
def mark_as_required(filename)
  "Opal.loaded([#{filename.to_s.inspect}]);"
end
to_s() click to toggle source
# File lib/opal/builder_processors.rb, line 21
def to_s
  source.to_s
end