Class: Opal::Processor
- Defined in:
- opal/lib/opal/sprockets/processor.rb
Overview
The Processor class is used to make ruby files (with rb or opal extensions) available to any sprockets based server. Processor will then get passed any ruby source file to build. There are some options you can override globally which effect how certain ruby features are handled:
- method_missing_enabled [true by default]
- arity_check_enabled [false by default]
- const_missing_enabled [true by default]
- dynamic_require_severity [:error by default]
- source_map_enabled [true by default]
- irb_enabled [false by default]
- inline_operators_enabled [false by default]
Class Attribute Summary collapse
-
.arity_check_enabled ⇒ Object
Returns the value of attribute arity_check_enabled.
-
.const_missing_enabled ⇒ Object
Returns the value of attribute const_missing_enabled.
-
.dynamic_require_severity ⇒ Object
Returns the value of attribute dynamic_require_severity.
-
.inline_operators_enabled ⇒ Object
Returns the value of attribute inline_operators_enabled.
-
.irb_enabled ⇒ Object
Returns the value of attribute irb_enabled.
-
.method_missing_enabled ⇒ Object
Returns the value of attribute method_missing_enabled.
-
.source_map_enabled ⇒ Object
Returns the value of attribute source_map_enabled.
-
.source_map_register ⇒ Object
Returns the value of attribute source_map_register.
Class Method Summary collapse
- .engine_initialized? ⇒ Boolean
- .new_builder(context) ⇒ Object
- .stub_file(name) ⇒ Object
- .stubbed_files ⇒ Object
- .version ⇒ Object
Instance Method Summary collapse
- #evaluate(context, locals, &block) ⇒ Object
- #initialize_engine ⇒ Object
- #prepare ⇒ Object
- #register_source_map(path, map_contents) ⇒ Object
- #stubbed_files ⇒ Object
Class Attribute Details
.arity_check_enabled ⇒ Object
Returns the value of attribute arity_check_enabled
47 48 49 |
# File 'opal/lib/opal/sprockets/processor.rb', line 47 def arity_check_enabled @arity_check_enabled end |
.const_missing_enabled ⇒ Object
Returns the value of attribute const_missing_enabled
48 49 50 |
# File 'opal/lib/opal/sprockets/processor.rb', line 48 def const_missing_enabled @const_missing_enabled end |
.dynamic_require_severity ⇒ Object
Returns the value of attribute dynamic_require_severity
49 50 51 |
# File 'opal/lib/opal/sprockets/processor.rb', line 49 def dynamic_require_severity @dynamic_require_severity end |
.inline_operators_enabled ⇒ Object
Returns the value of attribute inline_operators_enabled
52 53 54 |
# File 'opal/lib/opal/sprockets/processor.rb', line 52 def inline_operators_enabled @inline_operators_enabled end |
.irb_enabled ⇒ Object
Returns the value of attribute irb_enabled
51 52 53 |
# File 'opal/lib/opal/sprockets/processor.rb', line 51 def irb_enabled @irb_enabled end |
.method_missing_enabled ⇒ Object
Returns the value of attribute method_missing_enabled
46 47 48 |
# File 'opal/lib/opal/sprockets/processor.rb', line 46 def method_missing_enabled @method_missing_enabled end |
.source_map_enabled ⇒ Object
Returns the value of attribute source_map_enabled
50 51 52 |
# File 'opal/lib/opal/sprockets/processor.rb', line 50 def source_map_enabled @source_map_enabled end |
.source_map_register ⇒ Object
Returns the value of attribute source_map_register
54 55 56 |
# File 'opal/lib/opal/sprockets/processor.rb', line 54 def source_map_register @source_map_register end |
Class Method Details
.engine_initialized? ⇒ Boolean
28 29 30 |
# File 'opal/lib/opal/sprockets/processor.rb', line 28 def self.engine_initialized? true end |
.new_builder(context) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'opal/lib/opal/sprockets/processor.rb', line 101 def self.new_builder(context) = { :method_missing => method_missing_enabled, :arity_check => arity_check_enabled, :const_missing => const_missing_enabled, :dynamic_require_severity => dynamic_require_severity, :irb => irb_enabled, :inline_operators => inline_operators_enabled, } path_reader = ::Opal::Sprockets::PathReader.new(context.environment, context) return Builder.new( compiler_options: , stubs: stubbed_files, path_reader: path_reader ) end |
.stub_file(name) ⇒ Object
93 94 95 |
# File 'opal/lib/opal/sprockets/processor.rb', line 93 def self.stub_file(name) stubbed_files << name.to_s end |
.stubbed_files ⇒ Object
89 90 91 |
# File 'opal/lib/opal/sprockets/processor.rb', line 89 def self.stubbed_files @stubbed_files ||= [] end |
Instance Method Details
#evaluate(context, locals, &block) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'opal/lib/opal/sprockets/processor.rb', line 68 def evaluate(context, locals, &block) return Opal.compile data unless context.is_a? ::Sprockets::Context path = context.logical_path prerequired = [] builder = self.class.new_builder(context) result = builder.build_str(data, path, :prerequired => prerequired) if self.class.source_map_enabled register_source_map(context.logical_path, result.source_map.to_s) "#{result.to_s}\n//# sourceMappingURL=#{File.basename(context.logical_path)}.map\n" else result.to_s end end |
#initialize_engine ⇒ Object
36 37 38 |
# File 'opal/lib/opal/sprockets/processor.rb', line 36 def initialize_engine require_template_library 'opal' end |
#prepare ⇒ Object
40 41 |
# File 'opal/lib/opal/sprockets/processor.rb', line 40 def prepare end |
#register_source_map(path, map_contents) ⇒ Object
85 86 87 |
# File 'opal/lib/opal/sprockets/processor.rb', line 85 def register_source_map path, map_contents self.class.source_map_register[path] = map_contents end |
#stubbed_files ⇒ Object
97 98 99 |
# File 'opal/lib/opal/sprockets/processor.rb', line 97 def stubbed_files self.class.stubbed_files end |