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