Class: Opal::BuilderProcessors::Processor
- Inherits:
-
Object
- Object
- Opal::BuilderProcessors::Processor
- Defined in:
- opal/lib/opal/builder_processors.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.extensions ⇒ Object
readonly
Returns the value of attribute extensions.
Instance Attribute Summary collapse
-
#autoloads ⇒ Object
readonly
Returns the value of attribute autoloads.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#required_trees ⇒ Object
readonly
Returns the value of attribute required_trees.
-
#requires ⇒ Object
readonly
Returns the value of attribute requires.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source, filename, options = {}) ⇒ Processor
constructor
A new instance of Processor.
- #mark_as_required(filename) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(source, filename, options = {}) ⇒ Processor
Returns a new instance of Processor.
9 10 11 12 13 14 15 16 |
# File 'opal/lib/opal/builder_processors.rb', line 9 def initialize(source, filename, = {}) source += "\n" unless source.end_with?("\n") @source, @filename, @options = source, filename, .dup @cache = @options.delete(:cache) { Opal.cache } @requires = [] @required_trees = [] @autoloads = [] end |
Class Attribute Details
.extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
24 25 26 |
# File 'opal/lib/opal/builder_processors.rb', line 24 def extensions @extensions end |
Instance Attribute Details
#autoloads ⇒ Object (readonly)
Returns the value of attribute autoloads.
17 18 19 |
# File 'opal/lib/opal/builder_processors.rb', line 17 def autoloads @autoloads end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
17 18 19 |
# File 'opal/lib/opal/builder_processors.rb', line 17 def filename @filename end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'opal/lib/opal/builder_processors.rb', line 17 def @options end |
#required_trees ⇒ Object (readonly)
Returns the value of attribute required_trees.
17 18 19 |
# File 'opal/lib/opal/builder_processors.rb', line 17 def required_trees @required_trees end |
#requires ⇒ Object (readonly)
Returns the value of attribute requires.
17 18 19 |
# File 'opal/lib/opal/builder_processors.rb', line 17 def requires @requires end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
17 18 19 |
# File 'opal/lib/opal/builder_processors.rb', line 17 def source @source end |
Class Method Details
.handles(*extensions) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'opal/lib/opal/builder_processors.rb', line 26 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) ⇒ Boolean
36 37 38 |
# File 'opal/lib/opal/builder_processors.rb', line 36 def match?(other) other.is_a?(String) && other.match(match_regexp) end |
.match_regexp ⇒ Object
40 41 42 |
# File 'opal/lib/opal/builder_processors.rb', line 40 def match_regexp @match_regexp || raise(NotImplementedError) end |
Instance Method Details
#mark_as_required(filename) ⇒ Object
45 46 47 |
# File 'opal/lib/opal/builder_processors.rb', line 45 def mark_as_required(filename) "Opal.loaded([#{filename.to_s.inspect}]);" end |
#to_s ⇒ Object
19 20 21 |
# File 'opal/lib/opal/builder_processors.rb', line 19 def to_s source.to_s end |