verilog 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +2 -0
- data/lib/verilog.rb +2 -1
- data/lib/verilog/file_list.rb +99 -0
- data/spec/fixtures/file.list +13 -0
- data/spec/fixtures/inc_dir_test/incdir_file_one.txt +0 -0
- data/spec/fixtures/inc_dir_test/incdir_file_two.txt +0 -0
- data/spec/fixtures/secondary_file.list +3 -0
- data/spec/verilog_file_list_spec.rb +48 -0
- metadata +13 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 08658e8cfe6d74a85ae7877363158517e08705c3
|
4
|
+
data.tar.gz: 9ab6a88186f8c4f2cd5028361056da5590b1e5a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a64da72fbcf90052ff2ef5384977c9547e14b9c7e0d4cd4bba53fd93c60758fd86e947bf95860e8325592ecb9ba0ca8777017cc19ae60f1f0650bc7a8f481547
|
7
|
+
data.tar.gz: c3537cd238133fe2976c2d9d006272482bc23b4b8d5e4ec892a2fc00fca8ad77f65b1eccf74582dc9fb06be26a92605300ca8bbcbfdbd4e13fb3958a1506f290
|
data/README.md
CHANGED
data/lib/verilog.rb
CHANGED
@@ -0,0 +1,99 @@
|
|
1
|
+
module Verilog
|
2
|
+
|
3
|
+
class FileList
|
4
|
+
attr_reader :files
|
5
|
+
|
6
|
+
## Expected usage
|
7
|
+
# Use FileList to create an array of files included in design
|
8
|
+
# FileList is then used to create a Path, which loads the files into memory
|
9
|
+
# FileList and Path are separated in case you want a file list with out actually having to open the files
|
10
|
+
def initialize( a_filelist='' )
|
11
|
+
@files = []
|
12
|
+
unless ( a_filelist == '')
|
13
|
+
parse_list!( a_filelist )
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
## Unsure of the name for this
|
18
|
+
# open : it does open the file but not like other open calls
|
19
|
+
# load : opens file and loads content, load! does not imply what it modifies
|
20
|
+
# parse_list is descriptive but not what it modifies
|
21
|
+
|
22
|
+
def parse_list( filelist )
|
23
|
+
temp_files = []
|
24
|
+
## Splat (*) filelist into Array if single string
|
25
|
+
[*filelist].each do |item|
|
26
|
+
abort( "FileList parse_list item not found : #{item}") unless ::File.exist?( item )
|
27
|
+
::IO.readlines( item ).each do |line|
|
28
|
+
## Remove // or # comments
|
29
|
+
line = strip_comments( line )
|
30
|
+
|
31
|
+
## Expand Environment variables in strings
|
32
|
+
line = expand_envvars( line )
|
33
|
+
|
34
|
+
## -incdir, include the entire contents of listed directory
|
35
|
+
if line.match(/^\s*-incdir\s+(\S+)\s*/)
|
36
|
+
temp_files << incdir($1)
|
37
|
+
|
38
|
+
## Recurse on -f (file.f including other files.f)
|
39
|
+
elsif line.match(/^\s*-f\s+(\S+)\s*/)
|
40
|
+
temp_files << parse_list($1)
|
41
|
+
|
42
|
+
## Ignore Whitespace
|
43
|
+
elsif line.match(/^\s$/)
|
44
|
+
next
|
45
|
+
|
46
|
+
## Append file list line to list of files
|
47
|
+
else
|
48
|
+
temp_files << line.strip
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
## Recursion embeds arrays, return flat file list
|
54
|
+
|
55
|
+
return temp_files.flatten
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse_list!( filelist )
|
59
|
+
files.push( *parse_list( filelist ) )
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_path
|
63
|
+
new_path = Path.new
|
64
|
+
|
65
|
+
self.files.each do |f|
|
66
|
+
new_path.load_file( f )
|
67
|
+
end
|
68
|
+
|
69
|
+
return new_path
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
|
75
|
+
def incdir( in_string )
|
76
|
+
## returns array of files and links
|
77
|
+
inc_list = []
|
78
|
+
|
79
|
+
Dir.glob( ::File.join(in_string, '*') ).select do |item|
|
80
|
+
if ::File.file?( item ) or ::File.symlink?( item )
|
81
|
+
inc_list << item
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
return inc_list
|
86
|
+
end
|
87
|
+
|
88
|
+
def expand_envvars( in_string )
|
89
|
+
return in_string.gsub(/\$(\w+)/) { ENV[$1] }
|
90
|
+
end
|
91
|
+
|
92
|
+
def strip_comments( in_string )
|
93
|
+
return in_string.gsub(/(\/\/|#).*$/, '')
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
File without changes
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
describe Verilog do
|
5
|
+
|
6
|
+
it "Load file.list with init" do
|
7
|
+
test_path = File.join( File.dirname( __FILE__ ), 'fixtures' )
|
8
|
+
## Set working directory for relative file.list includes
|
9
|
+
Dir.chdir( test_path )
|
10
|
+
|
11
|
+
list_one = Verilog::FileList.new( File.join( test_path, 'file.list' ) )
|
12
|
+
answer =
|
13
|
+
["file_one.txt",
|
14
|
+
"file_two.txt",
|
15
|
+
"secondary_file_list_file1",
|
16
|
+
"secondary_file_list_file2",
|
17
|
+
"file_three.txt",
|
18
|
+
"inc_dir_test/incdir_file_one.txt",
|
19
|
+
"inc_dir_test/incdir_file_two.txt",
|
20
|
+
"file_four.txt",
|
21
|
+
]
|
22
|
+
|
23
|
+
list_one.files.inspect.should == answer.inspect
|
24
|
+
|
25
|
+
end
|
26
|
+
it "Load file.list with parse list" do
|
27
|
+
test_path = File.join( File.dirname( __FILE__ ), 'fixtures' )
|
28
|
+
## Set working directory for relative file.list includes
|
29
|
+
Dir.chdir( test_path )
|
30
|
+
|
31
|
+
#No bang method, returns array.
|
32
|
+
list_one = Verilog::FileList.new().parse_list( File.join( test_path, 'file.list' ) )
|
33
|
+
answer =
|
34
|
+
["file_one.txt",
|
35
|
+
"file_two.txt",
|
36
|
+
"secondary_file_list_file1",
|
37
|
+
"secondary_file_list_file2",
|
38
|
+
"file_three.txt",
|
39
|
+
"inc_dir_test/incdir_file_one.txt",
|
40
|
+
"inc_dir_test/incdir_file_two.txt",
|
41
|
+
"file_four.txt",
|
42
|
+
]
|
43
|
+
|
44
|
+
list_one.inspect.should == answer.inspect
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verilog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Morgan Prior
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: File helpers with specific functions for Verilog HDL
|
15
14
|
email: verilog_gem@amaras-tech.co.uk
|
@@ -20,36 +19,41 @@ files:
|
|
20
19
|
- README.md
|
21
20
|
- Rakefile
|
22
21
|
- lib/verilog/file.rb
|
22
|
+
- lib/verilog/file_list.rb
|
23
23
|
- lib/verilog/path.rb
|
24
24
|
- lib/verilog.rb
|
25
|
+
- spec/fixtures/file.list
|
26
|
+
- spec/fixtures/inc_dir_test/incdir_file_one.txt
|
27
|
+
- spec/fixtures/inc_dir_test/incdir_file_two.txt
|
28
|
+
- spec/fixtures/secondary_file.list
|
25
29
|
- spec/fixtures/test_four.vh
|
26
30
|
- spec/fixtures/test_one.v
|
27
31
|
- spec/fixtures/test_three.v
|
28
32
|
- spec/spec_helper.rb
|
33
|
+
- spec/verilog_file_list_spec.rb
|
29
34
|
- spec/verilog_file_spec.rb
|
30
35
|
- spec/verilog_path_spec.rb
|
31
36
|
homepage: http://amaras-tech.co.uk/software/verilog
|
32
37
|
licenses: []
|
38
|
+
metadata: {}
|
33
39
|
post_install_message:
|
34
40
|
rdoc_options: []
|
35
41
|
require_paths:
|
36
42
|
- lib
|
37
43
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
44
|
requirements:
|
40
|
-
- -
|
45
|
+
- - '>='
|
41
46
|
- !ruby/object:Gem::Version
|
42
47
|
version: '0'
|
43
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
49
|
requirements:
|
46
|
-
- -
|
50
|
+
- - '>='
|
47
51
|
- !ruby/object:Gem::Version
|
48
52
|
version: '0'
|
49
53
|
requirements: []
|
50
54
|
rubyforge_project:
|
51
|
-
rubygems_version:
|
55
|
+
rubygems_version: 2.0.3
|
52
56
|
signing_key:
|
53
|
-
specification_version:
|
57
|
+
specification_version: 4
|
54
58
|
summary: Helpers for working with verilog files
|
55
59
|
test_files: []
|