Class: Beni::DSL::TargetContext

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

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

#referencesArray[String] (readonly)

Returns the value of attribute references.

Returns:

  • (Array[String])


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

def references
  @references
end

Class Method Details

.collect { ... } ⇒ Array[String]

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

Yields:

Yield Returns:

  • (void)

Returns:

  • (Array[String])


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) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol, String)


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

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

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