Class: Opal::Builder
- Inherits:
- 
      Object
      
        - Object
- Opal::Builder
 
- Includes:
- BuilderProcessors, UseGem
- Defined in:
- opal/lib/opal/builder.rb
Defined Under Namespace
Classes: MissingRequire
Constant Summary
Constants included from BuilderProcessors
Opal::BuilderProcessors::DEFAULT_PROCESSORS
Instance Attribute Summary collapse
- 
  
    
      #compiler_options  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute compiler_options. 
- 
  
    
      #default_processor  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute default_processor. 
- 
  
    
      #path_reader  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute path_reader. 
- 
  
    
      #preload  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute preload. 
- 
  
    
      #prerequired  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute prerequired. 
- 
  
    
      #processed  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute processed. 
- 
  
    
      #processors  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute processors. 
- 
  
    
      #stubs  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute stubs. 
Class Method Summary collapse
Instance Method Summary collapse
- #append_paths(*paths) ⇒ Object
- #build(path, options = {}) ⇒ Object
- #build_require(path, options = {}) ⇒ Object
- #build_str(source, filename, options = {}) ⇒ Object
- 
  
    
      #initialize(options = nil)  ⇒ Builder 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Builder. 
- #initialize_copy(other) ⇒ Object
- #source_map ⇒ Object
- #to_s ⇒ Object
Methods included from UseGem
Constructor Details
#initialize(options = nil) ⇒ Builder
Returns a new instance of Builder
| 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # File 'opal/lib/opal/builder.rb', line 13 def initialize( = nil) ( || {}).each_pair do |k,v| public_send("#{k}=", v) end @stubs ||= [] @preload ||= [] @processors ||= DEFAULT_PROCESSORS @path_reader ||= PathReader.new @prerequired ||= [] @compiler_options ||= {} @default_processor ||= RubyProcessor @processed = [] end | 
Instance Attribute Details
#compiler_options ⇒ Object
Returns the value of attribute compiler_options
| 80 81 82 | # File 'opal/lib/opal/builder.rb', line 80 def @compiler_options end | 
#default_processor ⇒ Object
Returns the value of attribute default_processor
| 80 81 82 | # File 'opal/lib/opal/builder.rb', line 80 def default_processor @default_processor end | 
#path_reader ⇒ Object
Returns the value of attribute path_reader
| 80 81 82 | # File 'opal/lib/opal/builder.rb', line 80 def path_reader @path_reader end | 
#preload ⇒ Object
Returns the value of attribute preload
| 80 81 82 | # File 'opal/lib/opal/builder.rb', line 80 def preload @preload end | 
#prerequired ⇒ Object
Returns the value of attribute prerequired
| 80 81 82 | # File 'opal/lib/opal/builder.rb', line 80 def prerequired @prerequired end | 
#processed ⇒ Object (readonly)
Returns the value of attribute processed
| 78 79 80 | # File 'opal/lib/opal/builder.rb', line 78 def processed @processed end | 
#processors ⇒ Object
Returns the value of attribute processors
| 80 81 82 | # File 'opal/lib/opal/builder.rb', line 80 def processors @processors end | 
#stubs ⇒ Object
Returns the value of attribute stubs
| 80 81 82 | # File 'opal/lib/opal/builder.rb', line 80 def stubs @stubs end | 
Class Method Details
.build(*args, &block) ⇒ Object
| 29 30 31 | # File 'opal/lib/opal/builder.rb', line 29 def self.build(*args, &block) new.build(*args, &block) end | 
Instance Method Details
#append_paths(*paths) ⇒ Object
| 72 73 74 | # File 'opal/lib/opal/builder.rb', line 72 def append_paths(*paths) path_reader.append_paths(*paths) end | 
#build(path, options = {}) ⇒ Object
| 33 34 35 36 | # File 'opal/lib/opal/builder.rb', line 33 def build(path, = {}) source = read(path) build_str(source, path, ) end | 
#build_require(path, options = {}) ⇒ Object
| 49 50 51 | # File 'opal/lib/opal/builder.rb', line 49 def build_require(path, = {}) process_require(path, ) end | 
#build_str(source, filename, options = {}) ⇒ Object
| 38 39 40 41 42 43 44 45 46 47 | # File 'opal/lib/opal/builder.rb', line 38 def build_str source, filename, = {} path = path_reader.(filename).to_s unless stub?(filename) asset = processor_for(source, filename, path, ) requires = preload + asset.requires + tree_requires(asset, path) requires.map { |r| process_require(r, ) } processed << asset self rescue MissingRequire => error raise error, "A file required by #{filename.inspect} wasn't found.\n#{error.}", error.backtrace end | 
#initialize_copy(other) ⇒ Object
| 53 54 55 56 57 58 59 60 61 62 | # File 'opal/lib/opal/builder.rb', line 53 def initialize_copy(other) super @stubs = other.stubs.dup @preload = other.preload.dup @processors = other.processors.dup @path_reader = other.path_reader.dup @prerequired = other.prerequired.dup @compiler_options = other..dup @processed = other.processed.dup end | 
#source_map ⇒ Object
| 68 69 70 | # File 'opal/lib/opal/builder.rb', line 68 def source_map processed.map(&:source_map).reduce(:+).as_json.to_json end | 
#to_s ⇒ Object
| 64 65 66 | # File 'opal/lib/opal/builder.rb', line 64 def to_s processed.map(&:to_s).join("\n") end |