Class: Verilog::FileList
- Inherits:
-
Object
- Object
- Verilog::FileList
- Defined in:
- lib/verilog/file_list.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
-
#initialize(a_filelist = '') ⇒ FileList
constructor
Expected usage Use FileList to create an array of files included in design FileList is then used to create a Path, which loads the files into memory FileList and Path are separated in case you want a file list with out actually having to open the files.
-
#parse_list(filelist) ⇒ Object
Unsure of the name for this open : it does open the file but not like other open calls load : opens file and loads content, load! does not imply what it modifies parse_list is descriptive but not what it modifies.
- #parse_list!(filelist) ⇒ Object
- #to_path ⇒ Object
Constructor Details
#initialize(a_filelist = '') ⇒ FileList
Expected usage Use FileList to create an array of files included in design FileList is then used to create a Path, which loads the files into memory FileList and Path are separated in case you want a file list with out actually having to open the files
10 11 12 13 14 15 |
# File 'lib/verilog/file_list.rb', line 10 def initialize( a_filelist='' ) @files = [] unless ( a_filelist == '') parse_list!( a_filelist ) end end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
4 5 6 |
# File 'lib/verilog/file_list.rb', line 4 def files @files end |
Instance Method Details
#parse_list(filelist) ⇒ Object
Unsure of the name for this open : it does open the file but not like other open calls load : opens file and loads content, load! does not imply what it modifies parse_list is descriptive but not what it modifies
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/verilog/file_list.rb', line 22 def parse_list( filelist ) temp_files = [] ## Splat (*) filelist into Array if single string [*filelist].each do |item| abort( "FileList parse_list item not found : #{item}") unless ::File.exist?( item ) ::IO.readlines( item ).each do |line| ## Remove // or # comments line = strip_comments( line ) ## Expand Environment variables in strings line = ( line ) ## -incdir, include the entire contents of listed directory if line.match(/^\s*-incdir\s+(\S+)\s*/) temp_files << incdir($1) ## Recurse on -f (file.f including other files.f) elsif line.match(/^\s*-f\s+(\S+)\s*/) temp_files << parse_list($1) ## Ignore Whitespace elsif line.match(/^\s$/) next ## Append file list line to list of files else temp_files << line.strip end end end ## Recursion embeds arrays, return flat file list return temp_files.flatten end |
#parse_list!(filelist) ⇒ Object
58 59 60 |
# File 'lib/verilog/file_list.rb', line 58 def parse_list!( filelist ) files.push( *parse_list( filelist ) ) end |