Class: Beni::DSL::TargetContext

Inherits:
Object
  • Object
show all
Defined in:
lib/beni/dsl/target_context.rb

Overview

Vocabulary inside a target <name> do … end block — block-less toolchain references only. References are set-semantic: repeats collapse, and referencing mruby is legal redundancy.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTargetContext

Returns a new instance of TargetContext.



19
20
21
# File 'lib/beni/dsl/target_context.rb', line 19

def initialize
  @references = []
end

Instance Attribute Details

#referencesObject (readonly)

Returns the value of attribute references.



17
18
19
# File 'lib/beni/dsl/target_context.rb', line 17

def references
  @references
end

Class Method Details

.collectObject

Run block on a fresh context and return the collected reference names.



11
12
13
14
15
# File 'lib/beni/dsl/target_context.rb', line 11

def self.collect(&)
  context = new
  context.instance_exec(&)
  context.references
end

Instance Method Details

#toolchain(name, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/beni/dsl/target_context.rb', line 23

def toolchain(name, &block)
  if block
    raise Error,
          "`toolchain #{name.inspect}` inside a target block must not carry a block — " \
          "definitions live at the top level"
  end
  DSL.assert_known_toolchain!(name)

  @references << name unless @references.include?(name)
end