class Xccoveralls::Xccov
Attributes
derived_data_path[R]
ignorefile_path[R]
source_path[R]
Public Class Methods
new( derived_data_path: nil, source_path: nil, ignorefile_path: nil )
click to toggle source
# File lib/xccoveralls/xccov.rb, line 10 def initialize( derived_data_path: nil, source_path: nil, ignorefile_path: nil ) @source_path = source_path @derived_data_path = derived_data_path @ignorefile_path = ignorefile_path || File.join( source_path, '.coverallsignore' ) end
Public Instance Methods
archive_path()
click to toggle source
# File lib/xccoveralls/xccov.rb, line 26 def archive_path return @archive_path if @archive_path ext = '.xccovarchive' files = Dir[File.join(test_logs_path, "*#{ext}")] @archive_path = files.sort_by { |filename| File.mtime(filename) } .reverse.first @archive_path || user_error!("Could not find any #{ext} in #{derived_data_path}") @archive_path end
coverage(path)
click to toggle source
# File lib/xccoveralls/xccov.rb, line 37 def coverage(path) file_paths.include?(path) || user_error!("No coverage data for #{path}") res = exec(['--file', "'#{path}'"]) res.split("\n").map do |line| line = line.strip.split(/[\s:]/).reject(&:empty?) next unless line[0] =~ /^\d+$/ hits = line[1] hits == '*' ? nil : hits.to_i end end
exec(args)
click to toggle source
# File lib/xccoveralls/xccov.rb, line 92 def exec(args) cmd = %w[xcrun xccov view] + args + %W["#{archive_path}"] FastlaneCore::CommandExecutor.execute( command: cmd, print_command: false ).strip end
file(path)
click to toggle source
docs.coveralls.io/api-introduction#source-files
# File lib/xccoveralls/xccov.rb, line 66 def file(path) { name: name(path), source_digest: source_digest(path), coverage: coverage(path) } end
file_paths()
click to toggle source
# File lib/xccoveralls/xccov.rb, line 82 def file_paths return @file_paths if @file_paths paths = exec(%w[--file-list]).split("\n") if File.file?(ignorefile_path) ignore = Ignorefile.new(ignorefile_path) ignore.apply!(paths) end @file_paths = paths end
files()
click to toggle source
# File lib/xccoveralls/xccov.rb, line 74 def files file_paths.map { |path| file(path) } end
name(path)
click to toggle source
# File lib/xccoveralls/xccov.rb, line 58 def name(path) path.start_with?(source_path) || (return path) Pathname.new(path).relative_path_from( Pathname.new(source_path) ).to_s end
source_digest(path)
click to toggle source
# File lib/xccoveralls/xccov.rb, line 49 def source_digest(path) File.file?(path) || user_error!("File at #{path} does not exist") FastlaneCore::CommandExecutor.execute( command: %w[git hash-object] + %W["#{path}"], print_command: false ).strip end
test_logs_path()
click to toggle source
# File lib/xccoveralls/xccov.rb, line 22 def test_logs_path File.join derived_data_path, 'Logs', 'Test' end
to_json()
click to toggle source
# File lib/xccoveralls/xccov.rb, line 78 def to_json { source_files: files } end
Private Instance Methods
user_error!(msg)
click to toggle source
# File lib/xccoveralls/xccov.rb, line 102 def user_error!(msg) FastlaneCore::UI.user_error!(msg) end