class Slather::Project

Attributes

build_directory[RW]
ci_service[RW]
coverage_access_token[RW]
coverage_service[RW]
ignore_list[RW]
output_directory[RW]
show_html[RW]
source_directory[RW]
xcodeproj[RW]

Public Class Methods

open(xcodeproj) click to toggle source
Calls superclass method
# File lib/slather/project.rb, line 26
def self.open(xcodeproj)
  proj = super
  proj.configure_from_yml
  proj.xcodeproj = xcodeproj
  proj
end
yml() click to toggle source
# File lib/slather/project.rb, line 66
def self.yml
  @yml ||= File.exist?(yml_filename) ? YAML.load_file(yml_filename) : {}
end
yml_filename() click to toggle source
# File lib/slather/project.rb, line 62
def self.yml_filename
  '.slather.yml'
end

Public Instance Methods

ci_service=(service) click to toggle source
# File lib/slather/project.rb, line 100
def ci_service=(service)
  @ci_service = service && service.to_sym
end
configure_build_directory_from_yml() click to toggle source
# File lib/slather/project.rb, line 80
def configure_build_directory_from_yml
  self.build_directory = self.class.yml["build_directory"] if self.class.yml["build_directory"] && !@build_directory
end
configure_ci_service_from_yml() click to toggle source
# File lib/slather/project.rb, line 96
def configure_ci_service_from_yml
  self.ci_service ||= (self.class.yml["ci_service"] || :travis_ci)
end
configure_coverage_access_token_from_yml() click to toggle source
# File lib/slather/project.rb, line 108
def configure_coverage_access_token_from_yml
  self.coverage_access_token ||= (ENV["COVERAGE_ACCESS_TOKEN"] || self.class.yml["coverage_access_token"] || "")
end
configure_coverage_service_from_yml() click to toggle source
# File lib/slather/project.rb, line 104
def configure_coverage_service_from_yml
  self.coverage_service ||= (self.class.yml["coverage_service"] || :terminal)
end
configure_from_yml() click to toggle source
# File lib/slather/project.rb, line 70
def configure_from_yml
  configure_build_directory_from_yml
  configure_ignore_list_from_yml
  configure_ci_service_from_yml
  configure_coverage_access_token_from_yml
  configure_coverage_service_from_yml
  configure_source_directory_from_yml
  configure_output_directory_from_yml
end
configure_ignore_list_from_yml() click to toggle source
# File lib/slather/project.rb, line 92
def configure_ignore_list_from_yml
  self.ignore_list ||= [(self.class.yml["ignore"] || [])].flatten
end
configure_output_directory_from_yml() click to toggle source
# File lib/slather/project.rb, line 88
def configure_output_directory_from_yml
  self.output_directory ||= self.class.yml["output_directory"] if self.class.yml["output_directory"]
end
configure_source_directory_from_yml() click to toggle source
# File lib/slather/project.rb, line 84
def configure_source_directory_from_yml
  self.source_directory ||= self.class.yml["source_directory"] if self.class.yml["source_directory"]
end
coverage_service=(service) click to toggle source
# File lib/slather/project.rb, line 112
def coverage_service=(service)
  service = service && service.to_sym
  if service == :coveralls
    extend(Slather::CoverageService::Coveralls)
  elsif service == :hardcover
    extend(Slather::CoverageService::Hardcover)
  elsif service == :terminal
    extend(Slather::CoverageService::SimpleOutput)
  elsif service == :gutter_json
    extend(Slather::CoverageService::GutterJsonOutput)
  elsif service == :cobertura_xml
    extend(Slather::CoverageService::CoberturaXmlOutput)
  elsif service == :html
    extend(Slather::CoverageService::HtmlOutput)
  else
    raise ArgumentError, "`#{coverage_service}` is not a valid coverage service. Try `terminal`, `coveralls`, `gutter_json`, `cobertura_xml` or `html`"
  end
  @coverage_service = service
end

Private Instance Methods

coverage_files() click to toggle source
# File lib/slather/project.rb, line 42
def coverage_files
  coverage_files = Dir["#{build_directory}/**/*.gcno"].map do |file|
    coverage_file = coverage_file_class.new(self, file)
    # If there's no source file for this gcno, it probably belongs to another project.
    coverage_file.source_file_pathname && !coverage_file.ignored? ? coverage_file : nil
  end.compact

  if coverage_files.empty?
    raise StandardError, "No coverage files found. Are you sure your project is setup for generating coverage files? Try `slather setup your/project.xcodeproj`"
  else
    dedupe(coverage_files)
  end
end
dedupe(coverage_files) click to toggle source
# File lib/slather/project.rb, line 57
def dedupe(coverage_files)
  coverage_files.group_by(&:source_file_pathname).values.map { |cf_array| cf_array.max_by(&:percentage_lines_tested) }
end
derived_data_dir() click to toggle source
# File lib/slather/project.rb, line 33
def derived_data_dir
  File.expand_path('~') + "/Library/Developer/Xcode/DerivedData/"
end