# File lib/rspec-puppet/coverage.rb, line 30
    def add_from_catalog(catalog, test_module)
      catalog.to_a.each do |resource|
        # check filters
        next if @filters.include?(resource.to_s)
        if resource.type == 'Class'
          # if the resource is a class, make sure the class belongs to
          # module test_module
          module_name = resource.title.split('::').first.downcase
          next if module_name != test_module
        elsif resource.file
          # otherwise, the source file should be available, so make
          # sure the manifest declaring the resource is in
          # test_module's directory tree or the site manifest(s)
          if Puppet.version.to_f >= 4.0
            paths = [
              (Pathname.new(Puppet[:environmentpath]) + 'fixtures' + test_module + 'manifests').to_s,
              (Pathname.new(Puppet[:environmentpath]) + 'fixtures' + 'manifests' + 'site.pp').to_s
            ]
          else
            paths = Puppet[:modulepath].split(File::PATH_SEPARATOR).map do |dir|
              (Pathname.new(dir) + test_module + 'manifests').to_s
            end
            paths << Puppet[:manifest]
          end
          next unless paths.any? { |path| resource.file.include?(path) }
        end
        add(resource)
      end
    end