Module: OrigenTesters::Interface
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/origen_testers/interface.rb
Overview
Include this module in any class you define as a test interface
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#app_identifier ⇒ Object
This identifier will be used to make labels and other references unique to the current application.
-
#clean_referenced_patterns ⇒ Object
Remove duplicates and file extensions from the referenced pattern lists.
- #clear_top_level_flow ⇒ Object
- #close(options = {}) ⇒ Object
-
#comment(text) ⇒ Object
Add a comment line into the buffer.
- #comments ⇒ Object
-
#compile(file, options = {}) ⇒ Object
Compile a template file.
-
#consume_comments ⇒ Object
Returns the buffered description comments and clears the buffer.
-
#descriptions ⇒ Object
A storage Hash that all generators can push comment descriptions into when generating.
- #discard_comments ⇒ Object
- #flow_generator ⇒ Object
-
#identity_map ⇒ Object
:nodoc:.
- #import(file, options = {}) ⇒ Object
- #platform ⇒ Object
-
#referenced_patterns ⇒ Object
All generators should push to this array whenever they reference a pattern so that it is captured in the pattern list, e.g.
-
#referenced_subroutine_patterns ⇒ Object
All generators should push to this array whenever they reference a subroutine pattern so that it is captured in the pattern list, e.g.
- #render(file, options = {}) ⇒ Object
-
#resources_mode ⇒ Object
Any tests generated within the given block will be generated in resources mode.
- #resources_mode? ⇒ Boolean
- #set_top_level_flow ⇒ Object
- #top_level_flow ⇒ Object (also: #top_level_flow_filename)
- #write_files(options = {}) ⇒ Object
Instance Method Details
#app_identifier ⇒ Object
This identifier will be used to make labels and other references unique to the current application. This will help to avoid name duplication if a program is comprised of many modules generated by Origen.
Override in the application interface to customize, by default the identifier will be Origen.config.initials
19 20 21 |
# File 'lib/origen_testers/interface.rb', line 19 def app_identifier Origen.config.initials || 'Anon App' end |
#clean_referenced_patterns ⇒ Object
Remove duplicates and file extensions from the referenced pattern lists
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/origen_testers/interface.rb', line 87 def clean_referenced_patterns refs = [:referenced_patterns] refs << :referenced_subroutine_patterns if Origen.tester.v93k? refs.each do |ref| ref = send(ref) ref.uniq! ref.map! do |pat| pat.sub(/\..*/, '') end ref.uniq! end end |
#clear_top_level_flow ⇒ Object
133 134 135 |
# File 'lib/origen_testers/interface.rb', line 133 def clear_top_level_flow @@top_level_flow = nil end |
#close(options = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/origen_testers/interface.rb', line 23 def close( = {}) sheet_generators.each do |generator| generator.close() end end |
#comment(text) ⇒ Object
Add a comment line into the buffer
101 102 103 |
# File 'lib/origen_testers/interface.rb', line 101 def comment(text) comments << text end |
#comments ⇒ Object
105 106 107 |
# File 'lib/origen_testers/interface.rb', line 105 def comments @@comments ||= [] end |
#compile(file, options = {}) ⇒ Object
Compile a template file
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/origen_testers/interface.rb', line 30 def compile(file, = {}) Origen.file_handler.preserve_state do begin file = Origen.file_handler.clean_path_to_template(file) Origen.generator.compile_file_or_directory(file, initial_options: ) rescue file = Origen.file_handler.clean_path_to(file) Origen.generator.compile_file_or_directory(file, initial_options: ) end end end |
#consume_comments ⇒ Object
Returns the buffered description comments and clears the buffer
114 115 116 117 118 |
# File 'lib/origen_testers/interface.rb', line 114 def consume_comments c = comments discard_comments c end |
#descriptions ⇒ Object
A storage Hash that all generators can push comment descriptions into when generating. At the end of a generation run this will contain all descriptions for all flows that were just created.
Access via Origen.interface.descriptions
143 144 145 |
# File 'lib/origen_testers/interface.rb', line 143 def descriptions @@descriptions ||= Parser::DescriptionLookup.new end |
#discard_comments ⇒ Object
109 110 111 |
# File 'lib/origen_testers/interface.rb', line 109 def discard_comments @@comments = nil end |
#flow_generator ⇒ Object
125 126 127 |
# File 'lib/origen_testers/interface.rb', line 125 def flow_generator flow end |
#identity_map ⇒ Object
:nodoc:
161 162 163 |
# File 'lib/origen_testers/interface.rb', line 161 def identity_map # :nodoc: @@identity_map ||= ::OrigenTesters::Generator::IdentityMap.new end |
#import(file, options = {}) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/origen_testers/interface.rb', line 42 def import(file, = {}) # Attach the import request to the first generator, when it imports # it any generated resources will automatically find their way to the # correct generator/collection generator = flow || sheet_generators.first generator.import(file, ) end |
#platform ⇒ Object
165 166 167 168 169 170 171 172 173 |
# File 'lib/origen_testers/interface.rb', line 165 def platform # This branch to support the ProgramGenerators module where the generator # is included into an interface instance and not the class if singleton_class.const_defined? :PLATFORM singleton_class::PLATFORM else self.class::PLATFORM end end |
#referenced_patterns ⇒ Object
All generators should push to this array whenever they reference a pattern so that it is captured in the pattern list, e.g.
Origen.interface.referenced_patterns << pattern
72 73 74 |
# File 'lib/origen_testers/interface.rb', line 72 def referenced_patterns @@referenced_patterns ||= [] end |
#referenced_subroutine_patterns ⇒ Object
All generators should push to this array whenever they reference a subroutine pattern so that it is captured in the pattern list, e.g.
Origen.interface.referenced_subroutine_patterns << pattern
79 80 81 82 83 84 |
# File 'lib/origen_testers/interface.rb', line 79 def referenced_subroutine_patterns unless Origen.tester.v93k? fail 'referenced_subroutine_patterns is currently only implemented for V93k!' end @@referenced_subroutine_patterns ||= [] end |
#render(file, options = {}) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/origen_testers/interface.rb', line 50 def render(file, = {}) if sheet_generators.size > 1 fail "You must specify which generator to render content to! e.g. i.test_instances.render '#{file}'" else sheet_generators.first.render(file, ) end end |
#resources_mode ⇒ Object
Any tests generated within the given block will be generated in resources mode. Generally this means that all resources for a given test will be generated but flow entries will be inhibited.
150 151 152 153 154 155 |
# File 'lib/origen_testers/interface.rb', line 150 def resources_mode orig = @resources_mode @resources_mode = true yield @resources_mode = orig end |
#resources_mode? ⇒ Boolean
157 158 159 |
# File 'lib/origen_testers/interface.rb', line 157 def resources_mode? @resources_mode end |
#set_top_level_flow ⇒ Object
129 130 131 |
# File 'lib/origen_testers/interface.rb', line 129 def set_top_level_flow @@top_level_flow = flow_generator.output_file end |
#top_level_flow ⇒ Object Also known as: top_level_flow_filename
120 121 122 |
# File 'lib/origen_testers/interface.rb', line 120 def top_level_flow @@top_level_flow ||= nil end |
#write_files(options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/origen_testers/interface.rb', line 58 def write_files( = {}) sheet_generators.each do |generator| generator.finalize() end sheet_generators.each do |generator| generator.write_to_file() if generator.to_be_written? end clean_referenced_patterns reset_globals end |