@@ -35,6 +35,20 @@ def initialize(base_dir)
35
35
@last_msg = ""
36
36
end
37
37
38
+ # Guess whether a file is part of the vendor bundle (indicating we should ignore it).
39
+ #
40
+ # This assumes the vendor bundle will be at `vendor/bundle` and not some other location
41
+ # @param path [String] The path to check
42
+ # @return [Array<String>] The paths of the found files
43
+ def vendor_bundle? ( path )
44
+ # TODO: look for Gemfile, look for .bundle/config and get BUNDLE_PATH from there?
45
+ base = File . join ( @base_dir , "vendor" )
46
+ real = File . join ( File . realpath ( @base_dir ) , "vendor" )
47
+ return true if path . start_with? ( base )
48
+ return true if path . start_with? ( real )
49
+ false
50
+ end
51
+
38
52
# Get a list of all CPP source files in a directory and its subdirectories
39
53
# @param some_dir [String] The directory in which to begin the search
40
54
# @return [Array<String>] The paths of the found files
@@ -52,6 +66,7 @@ def cpp_files
52
66
cpp_files_in ( @base_dir ) . reject do |p |
53
67
next true if File . dirname ( p ) . include? ( tests_dir )
54
68
next true if File . dirname ( p ) . include? ( real_tests_dir )
69
+ next true if vendor_bundle? ( p )
55
70
end
56
71
end
57
72
@@ -84,7 +99,8 @@ def test_files
84
99
def header_dirs
85
100
real = File . realpath ( @base_dir )
86
101
all_files = Find . find ( real ) . reject { |path | File . directory? ( path ) }
87
- files = all_files . select { |path | HPP_EXTENSIONS . include? ( File . extname ( path ) ) }
102
+ unbundled = all_files . reject { |path | vendor_bundle? ( path ) }
103
+ files = unbundled . select { |path | HPP_EXTENSIONS . include? ( File . extname ( path ) ) }
88
104
ret = files . map { |path | File . dirname ( path ) } . uniq
89
105
puts "header_dirs found #{ files } \n returning #{ ret } "
90
106
ret
0 commit comments