Method: Slather::CoverageFile#source_file_pathname

Defined in:
lib/slather/coverage_file.rb

#source_file_pathnameObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/slather/coverage_file.rb', line 17

def source_file_pathname
  @source_file_pathname ||= begin
    base_filename = gcno_file_pathname.basename.sub_ext("")
    path = nil
    if project.source_directory
      path = Dir["#{project.source_directory}/**/#{base_filename}.{#{supported_file_extensions.join(",")}}"].first
      path &&= Pathname(path)
    else
      pbx_file = project.files.detect { |pbx_file|
        current_base_filename = pbx_file.real_path.basename
        ext_name = File.extname(current_base_filename.to_s)[1..-1]
        current_base_filename.sub_ext("") == base_filename && supported_file_extensions.include?(ext_name)
      }
      path = pbx_file && pbx_file.real_path
    end
    path
  end
end