Class: Opal::BuilderProcessors::RubyProcessor

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

Direct Known Subclasses

OpalERBProcessor, RubyERBProcessor

Instance Attribute Summary

Attributes inherited from Processor

#abs_path, #filename, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Processor

handles, #initialize, #mark_as_required, match_regexp, #to_s

Constructor Details

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

Class Method Details

.match?(other) ⇒ Boolean

Also catch a files with missing extensions and nil.

Returns:

  • (Boolean)


114
115
116
# File 'opal/lib/opal/builder_processors.rb', line 114

def self.match?(other)
  super || File.extname(other.to_s) == ''
end

Instance Method Details

#autoloadsObject



109
110
111
# File 'opal/lib/opal/builder_processors.rb', line 109

def autoloads
  compiled.autoloads
end

#cache_keyObject



93
94
95
# File 'opal/lib/opal/builder_processors.rb', line 93

def cache_key
  [self.class, @filename, @source, @options]
end

#compiledObject



85
86
87
88
89
90
91
# File 'opal/lib/opal/builder_processors.rb', line 85

def compiled
  @compiled ||= Opal::Cache.fetch(@cache, cache_key) do
    compiler = compiler_for(@source, file: @filename)
    compiler.compile
    compiler
  end
end

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



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

def compiler_for(source, options = {})
  ::Opal::Compiler.new(source, @options.merge(options))
end

#required_treesObject



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

def required_trees
  compiled.required_trees
end

#requiresObject



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

def requires
  compiled.requires
end

#sourceObject



77
78
79
# File 'opal/lib/opal/builder_processors.rb', line 77

def source
  compiled.result
end

#source_mapObject



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

def source_map
  compiled.source_map
end