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
-
#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 |
# 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, @requires = [] @required_trees = [] end |
Class Attribute Details
.extensions ⇒ Object (readonly)
Returns the value of attribute extensions
22 23 24 |
# File 'opal/lib/opal/builder_processors.rb', line 22 def extensions @extensions end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename
15 16 17 |
# File 'opal/lib/opal/builder_processors.rb', line 15 def filename @filename end |
#options ⇒ Object (readonly)
Returns the value of attribute options
15 16 17 |
# File 'opal/lib/opal/builder_processors.rb', line 15 def @options end |
#required_trees ⇒ Object (readonly)
Returns the value of attribute required_trees
15 16 17 |
# File 'opal/lib/opal/builder_processors.rb', line 15 def required_trees @required_trees end |
#requires ⇒ Object (readonly)
Returns the value of attribute requires
15 16 17 |
# File 'opal/lib/opal/builder_processors.rb', line 15 def requires @requires end |
#source ⇒ Object (readonly)
Returns the value of attribute source
15 16 17 |
# File 'opal/lib/opal/builder_processors.rb', line 15 def source @source end |
Class Method Details
.handles(*extensions) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'opal/lib/opal/builder_processors.rb', line 24 def handles(*extensions) @extensions = extensions matches = extensions.join('|') matches = "(#{matches})" if extensions.size == 1 @match_regexp = Regexp.new "\\.#{matches}#{REGEXP_END}" ::Opal::Builder.register_processor(self, extensions) nil end |
.match?(other) ⇒ Boolean
34 35 36 |
# File 'opal/lib/opal/builder_processors.rb', line 34 def match?(other) other.is_a?(String) && other.match(match_regexp) end |
.match_regexp ⇒ Object
38 39 40 |
# File 'opal/lib/opal/builder_processors.rb', line 38 def match_regexp @match_regexp || raise(NotImplementedError) end |
Instance Method Details
#mark_as_required(filename) ⇒ Object
43 44 45 |
# File 'opal/lib/opal/builder_processors.rb', line 43 def mark_as_required(filename) "Opal.loaded([#{filename.to_s.inspect}]);" end |
#to_s ⇒ Object
17 18 19 |
# File 'opal/lib/opal/builder_processors.rb', line 17 def to_s source.to_s end |