def files_to_process(paths)
      paths.reject { |type, _| type == :exclude }.map do |path_type, dirs|
        dirs.map do |dir|
          exclusions = []

          unless paths[:exclude].empty?
            exclusions = Dir.glob(paths[:exclude].map do |p|
              File.join(dir, p, "**/**")
            end)
          end

          if File.directory?(dir)
            glob = if path_type == :cookbook
                     "{metadata.rb,attributes.rb,recipe.rb,{attributes,definitions,libraries,"\
                     "providers,recipes,resources}/*.rb,templates/**/*.erb}"
                   else
                     "*.rb"
                   end

            (Dir.glob(File.join(dir, glob)) +
             Dir.glob(File.join(dir, "*/#{glob}")) - exclusions)
          else
            dir unless exclusions.include?(dir)
          end
        end.compact.flatten.map do |filename|
          { filename: filename, path_type: path_type }
        end
      end.flatten
    end
def files_to_process(paths)
      paths.reject { |type, _| type == :exclude }.map do |path_type, dirs|
        dirs.map do |dir|
          exclusions = []

          unless paths[:exclude].empty?
            exclusions = Dir.glob(paths[:exclude].map do |p|
              File.join(dir, p, "**/**")
            end)
          end

          if File.directory?(dir)
            glob = if path_type == :cookbook
                     "{metadata.rb,attributes.rb,recipe.rb,{attributes,definitions,libraries,"\
                     "providers,recipes,resources}/*.rb,templates/**/*.erb}"
                   else
                     "*.rb"
                   end

            (Dir.glob(File.join(dir, glob)) +
             Dir.glob(File.join(dir, "*/#{glob}")) - exclusions)
          else
            dir unless exclusions.include?(dir)
          end
        end.compact.flatten.map do |filename|
          { filename: filename, path_type: path_type }
        end
      end.flatten
    end
Return the files within a cookbook tree that we are interested in trying to match rules against.

 @param [Hash] paths - paths of interest: {:exclude=>[], :cookbook=>[], :role=>[], :environment=>[]}
 @return [Array] array of hashes for each file {:filename=>"./metadata.rb", :path_type=>:cookbook}