Class: ATP::Validator

Inherits:
Processor show all
Defined in:
lib/atp/validator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Processor

#clean_flag, #extract_volatiles, #handler_missing, #process_all, #run, #volatile?, #volatile_flags

Constructor Details

#initialize(flow) ⇒ Validator

Returns a new instance of Validator.



14
15
16
# File 'lib/atp/validator.rb', line 14

def initialize(flow)
  @flow = flow
end

Instance Attribute Details

#flowObject (readonly)

Returns the value of attribute flow.



4
5
6
# File 'lib/atp/validator.rb', line 4

def flow
  @flow
end

Class Method Details

.testingObject



10
11
12
# File 'lib/atp/validator.rb', line 10

def self.testing
  @testing
end

.testing=(value) ⇒ Object



6
7
8
# File 'lib/atp/validator.rb', line 6

def self.testing=(value)
  @testing = value
end

Instance Method Details

#error(message) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/atp/validator.rb', line 42

def error(message)
  # This is a hack to make the specs pass, for some reason RSpec
  # seems to be swallowing the Origen log output after the first
  # test that generates an error
  if Validator.testing
    puts message
  else
    Origen.log.error(message)
  end
end

#process(node) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/atp/validator.rb', line 18

def process(node)
  if @top_level_called
    super
  else
    @top_level_called = true
    setup
    super(node)
    unless @testing
      exit 1 if on_completion
    end
  end
end

#setupObject



39
40
# File 'lib/atp/validator.rb', line 39

def setup
end

#test_process(node) ⇒ Object

For test purposes, returns true if validation failed rather than exiting the process



33
34
35
36
37
# File 'lib/atp/validator.rb', line 33

def test_process(node)
  @testing = true
  process(node)
  on_completion
end