Class: Opal::Nodes::CallNode::DependencyResolver
- Inherits:
 - 
      Object
      
        
- Object
 - Opal::Nodes::CallNode::DependencyResolver
 
 
- Defined in:
 - opal/lib/opal/nodes/call.rb
 
Instance Method Summary collapse
- #expand_path(path, base = '') ⇒ Object
 - #handle_part(sexp) ⇒ Object
 - 
  
    
      #initialize(compiler, sexp)  ⇒ DependencyResolver 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of DependencyResolver.
 - #resolve ⇒ Object
 
Constructor Details
#initialize(compiler, sexp) ⇒ DependencyResolver
Returns a new instance of DependencyResolver.
      310 311 312 313  | 
    
      # File 'opal/lib/opal/nodes/call.rb', line 310 def initialize(compiler, sexp) @compiler = compiler @sexp = sexp end  | 
  
Instance Method Details
#expand_path(path, base = '') ⇒ Object
      349 350 351 352 353 354 355 356 357 358 359  | 
    
      # File 'opal/lib/opal/nodes/call.rb', line 349 def (path, base = '') "#{base}/#{path}".split('/').each_with_object([]) do |part, p| if part == '' # we had '//', so ignore elsif part == '..' p.pop else p << part end end.join '/' end  | 
  
#handle_part(sexp) ⇒ Object
      319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347  | 
    
      # File 'opal/lib/opal/nodes/call.rb', line 319 def handle_part(sexp) type = sexp.type if type == :str return sexp.children[0] elsif type == :send recv, meth, *args = sexp.children parts = args.map { |s| handle_part s } if recv.is_a?(::Opal::AST::Node) && recv.type == :const && recv.children.last == :File if meth == :expand_path return (*parts) elsif meth == :join return parts.join('/') elsif meth == :dirname return parts[0].split('/')[0...-1].join('/') end end end msg = 'Cannot handle dynamic require' case @compiler.dynamic_require_severity when :error @compiler.error msg, @sexp.line when :warning @compiler.warning msg, @sexp.line end end  | 
  
#resolve ⇒ Object
      315 316 317  | 
    
      # File 'opal/lib/opal/nodes/call.rb', line 315 def resolve handle_part @sexp end  |