Class: Opal::Project::Opalfile

Inherits:
Object
  • Object
show all
Defined in:
opal/lib/opal/project.rb

Overview

DSL for Opal::Project

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) {|_self| ... } ⇒ Opalfile

Returns a new instance of Opalfile.

Yields:

  • (_self)

Yield Parameters:



9
10
11
12
# File 'opal/lib/opal/project.rb', line 9

def initialize(project)
  @project = project
  yield self if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



34
35
36
# File 'opal/lib/opal/project.rb', line 34

def method_missing(method, *, **)
  raise OpalfileUnknownDirective, "unknown directive #{method} in Opalfile"
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



14
15
16
# File 'opal/lib/opal/project.rb', line 14

def project
  @project
end

Instance Method Details

#add_gem_dependency(name) ⇒ Object



30
31
32
# File 'opal/lib/opal/project.rb', line 30

def add_gem_dependency(name)
  project.collection.use_gem(name)
end

#add_load_path(*load_paths) ⇒ Object Also known as: add_load_paths



16
17
18
19
20
21
22
23
24
25
26
# File 'opal/lib/opal/project.rb', line 16

def add_load_path(*load_paths)
  # Make relative paths absolute based on Opalfile's location
  load_paths = load_paths.map do |i|
    if File.absolute_path?(i)
      i
    else
      File.realpath(i, project.root_dir)
    end
  end
  project.collection.append_paths(*load_paths)
end

#respond_to_missing?(_method) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'opal/lib/opal/project.rb', line 38

def respond_to_missing?(_method, *)
  false
end