Class: Origen::Tester::Doc::Generator::FlowLine

Inherits:
Object
  • Object
show all
Defined in:
lib/origen/tester/doc/generator/flow_line.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (FlowLine) initialize(type, attrs = {})

Returns a new instance of FlowLine



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 8

def initialize(type, attrs = {})
  @type = type
  @test = attrs.delete(:test)
  @context = {}
  @attributes = {}
  flow_control_options = Origen.interface.extract_flow_control_options!(attrs)
  flow_control_options.each do |opt, val|
    send("#{opt}=", val)
  end
  attrs.each do |attribute, val|
    @attributes[attribute] = val
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args, &_block)



81
82
83
84
85
86
87
88
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 81

def method_missing(method, *args, &_block)
  method = method.to_s
  if method.gsub!('=', '')
    @attributes[method] = args.first
  else
    @attributes[method]
  end
end

Instance Attribute Details

- (Object) attributes

Returns the value of attribute attributes



6
7
8
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 6

def attributes
  @attributes
end

- (Object) context

Returns the value of attribute context



6
7
8
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 6

def context
  @context
end

- (Object) description

Returns the value of attribute description



6
7
8
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 6

def description
  @description
end

- (Object) id

Returns the value of attribute id



6
7
8
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 6

def id
  @id
end

- (Object) test

Returns the value of attribute test



6
7
8
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 6

def test
  @test
end

- (Object) type

Returns the value of attribute type



6
7
8
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 6

def type
  @type
end

Class Method Details

+ (Object) unique_counter



191
192
193
194
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 191

def self.unique_counter
  @ix ||= -1
  @ix += 1
end

Instance Method Details

- (Object) attributes_to_yaml(_options = {})



39
40
41
42
43
44
45
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 39

def attributes_to_yaml(_options = {})
  a = {}
  @attributes.each do |name, val|
    a[name.to_s] = val if val
  end
  a
end

- (Object) context_to_yaml(_options = {})



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 47

def context_to_yaml(_options = {})
  # Turn attribute keys into strings for prettier yaml, this includes all
  # relationship meta data
  c = @context.reduce({}) { |memo, (k, v)| memo[k.to_s] = v; memo }
  # Now add job/enable word data
  if @enable
    c['if_enable'] = @enable
  end
  if @unless_enable
    c['unless_enable'] = @unless_enable
  end
  unless if_jobs.empty?
    c['if_jobs'] = if_jobs
  end
  unless unless_jobs.empty?
    c['unless_jobs'] = unless_jobs
  end
  c
end

- (Object) continue_on_fail



179
180
181
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 179

def continue_on_fail
  @attributes[:continue] = true
end

- (Object) if_enable=(val) Also known as: enable=, if_enabled=



111
112
113
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 111

def if_enable=(val)
  @enable = val
end

- (Object) if_job=(jobs) Also known as: if_jobs=, add_if_jobs, add_if_job



122
123
124
125
126
127
128
129
130
131
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 122

def if_job=(jobs)
  [jobs].flatten.compact.each do |job|
    job = job.to_s.upcase
    if job =~ /!/
      self.unless_job = job
    else
      if_jobs << job unless if_jobs.include?(job)
    end
  end
end

- (Object) if_jobs



103
104
105
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 103

def if_jobs
  @if_jobs ||= []
end

- (Object) job Also known as: jobs



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 90

def job
  if !if_jobs.empty? && !unless_jobs.empty?
    fail "Both if and unless jobs have been defined for test: #{parameter}"
  elsif !if_jobs.empty?
    if_jobs.join(',')
  elsif !unless_jobs.empty?
    unless_jobs.map { |j| "!#{j}" }.join(',')
  else
    ''
  end
end

- (Object) run_if_all_failed(parent)



175
176
177
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 175

def run_if_all_failed(parent)
  @context[:if_all_failed] = parent.id
end

- (Object) run_if_all_passed(parent)



167
168
169
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 167

def run_if_all_passed(parent)
  @context[:if_all_passed] = parent.id
end

- (Object) run_if_any_failed(parent)



171
172
173
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 171

def run_if_any_failed(parent)
  @context[:if_any_failed] = parent.id
end

- (Object) run_if_any_passed(parent)



163
164
165
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 163

def run_if_any_passed(parent)
  @context[:if_any_passed] = parent.id
end

- (Object) run_if_failed(id)



147
148
149
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 147

def run_if_failed(id)
  @context[:if_failed] = id
end

- (Object) run_if_passed(id)



151
152
153
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 151

def run_if_passed(id)
  @context[:if_passed] = id
end

- (Object) run_if_ran(id)



155
156
157
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 155

def run_if_ran(id)
  @context[:if_ran] = id
end

- (Object) run_unless_ran(id)



159
160
161
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 159

def run_unless_ran(id)
  @context[:unless_ran] = id
end

- (Boolean) test?

Returns:

  • (Boolean)


196
197
198
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 196

def test?
  @type == :test
end

- (Object) test_to_yaml(options = {})



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 67

def test_to_yaml(options = {})
  if @test
    if @test.is_a?(String) || @test.is_a?(Symbol)
      {
        'attributes' => {
          'name' => @test.to_s
        }
      }
    else
      @test.to_yaml(options)
    end
  end
end

- (Object) to_yaml(options = {})



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 22

def to_yaml(options = {})
  options = {
    include_descriptions: true
  }.merge(options)
  y = {
    'type'        => @type,
    'description' => description,
    'instance'    => test_to_yaml(options),
    'flow'        => {
      'attributes' => attributes_to_yaml(options),
      'context'    => context_to_yaml(options)
    }
  }
  y.delete('description') unless options[:include_descriptions]
  y
end

- (Object) unique_counter



187
188
189
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 187

def unique_counter
  @unique_counter ||= self.class.unique_counter
end

- (Object) unless_enable=(val) Also known as: unless_enabled=



117
118
119
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 117

def unless_enable=(val)
  @unless_enable = val
end

- (Object) unless_job=(jobs) Also known as: unless_jobs=, add_unless_jobs, add_unless_job



136
137
138
139
140
141
142
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 136

def unless_job=(jobs)
  [jobs].flatten.compact.each do |job|
    job = job.to_s.upcase
    job.gsub!('!', '')
    unless_jobs << job unless unless_jobs.include?(job)
  end
end

- (Object) unless_jobs



107
108
109
# File 'lib/origen/tester/doc/generator/flow_line.rb', line 107

def unless_jobs
  @unless_jobs ||= []
end