Class: Opal::Project::Opalfile
- Inherits:
-
Object
- Object
- Opal::Project::Opalfile
- Defined in:
- opal/lib/opal/project.rb
Overview
DSL for Opal::Project
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #add_gem_dependency(name) ⇒ Object
- #add_load_path(*load_paths) ⇒ Object (also: #add_load_paths)
-
#initialize(project) {|_self| ... } ⇒ Opalfile
constructor
A new instance of Opalfile.
- #method_missing(method) ⇒ Object
- #respond_to_missing?(_method) ⇒ Boolean
Constructor Details
#initialize(project) {|_self| ... } ⇒ Opalfile
Returns a new instance of Opalfile.
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
#project ⇒ Object (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
38 39 40 |
# File 'opal/lib/opal/project.rb', line 38 def respond_to_missing?(_method, *) false end |