Class: Mutant::Meta::Example::DSL Private

Inherits:
Object
  • Object
show all
Includes:
AST::Sexp
Defined in:
lib/mutant/meta/example/dsl.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Example DSL

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize DSL context



21
22
23
24
25
# File 'lib/mutant/meta/example/dsl.rb', line 21

def initialize(file)
  @file = file
  @source = nil
  @expected = []
end

Class Method Details

.run(file, block) ⇒ Example

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run DSL on block

Returns:



12
13
14
15
16
# File 'lib/mutant/meta/example/dsl.rb', line 12

def self.run(file, block)
  instance = new(file)
  instance.instance_eval(&block)
  instance.example
end

Instance Method Details

#exampleExample

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Example captured by DSL

Returns:

Raises:

  • (RuntimeError)

    in case example cannot be build



33
34
35
36
# File 'lib/mutant/meta/example/dsl.rb', line 33

def example
  fail 'source not defined' unless @source
  Example.new(@file, @source, @expected)
end