Class: Opal::BuilderProcessors::RubyProcessor

Inherits:
Processor show all
Defined in:
opal/lib/opal/builder_processors.rb

Direct Known Subclasses

OpalERBProcessor

Instance Attribute Summary

Attributes inherited from Processor

#filename, #options

Instance Method Summary collapse

Methods inherited from Processor

extensions, handles, inherited, #initialize, #mark_as_required, match?, match_regexp, #to_s

Constructor Details

This class inherits a constructor from Opal::BuilderProcessors::Processor

Instance Method Details

#compiledObject



88
89
90
91
92
93
94
# File 'opal/lib/opal/builder_processors.rb', line 88

def compiled
  @compiled ||= begin
    compiler = compiler_for(@source, file: @filename.gsub(/\.(rb|js|opal)#{REGEXP_END}/, ''))
    compiler.compile
    compiler
  end
end

#compiler_classObject



111
112
113
# File 'opal/lib/opal/builder_processors.rb', line 111

def compiler_class
  ::Opal::Compiler
end

#compiler_for(source, options = {}) ⇒ Object



96
97
98
# File 'opal/lib/opal/builder_processors.rb', line 96

def compiler_for(source, options = {})
  compiler_class.new(source, @options.merge(options))
end

#required_treesObject



104
105
106
107
108
109
# File 'opal/lib/opal/builder_processors.rb', line 104

def required_trees
  compiled.required_trees.map do |tree|
    # Remove any leading ./ after joining to dirname
    File.join(File.dirname(@filename), tree).sub(%r{^(\./)*}, '')
  end
end

#requiresObject



100
101
102
# File 'opal/lib/opal/builder_processors.rb', line 100

def requires
  compiled.requires
end

#sourceObject



80
81
82
# File 'opal/lib/opal/builder_processors.rb', line 80

def source
  compiled.result
end

#source_mapObject



84
85
86
# File 'opal/lib/opal/builder_processors.rb', line 84

def source_map
  compiled.source_map.map
end