lib/slather/project.rb in slather-2.0.0 vs lib/slather/project.rb in slather-2.0.1
- old
+ new
@@ -48,11 +48,11 @@
end
module Slather
class Project < Xcodeproj::Project
- attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service, :coverage_access_token, :source_directory,
+ attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service, :coverage_access_token, :source_directory,
:output_directory, :xcodeproj, :show_html, :verbose_mode, :input_format, :scheme, :binary_file, :binary_basename
alias_method :setup_for_coverage, :slather_setup_for_coverage
def self.open(xcodeproj)
@@ -98,17 +98,28 @@
!coverage_file.ignored? ? coverage_file : nil
end.compact
end
private :profdata_coverage_files
+ def remove_extension(path)
+ path.split(".")[0..-2].join(".")
+ end
+
+ def first_product_name
+ first_product = self.products.first
+ # If name is not available it computes it using
+ # the path by dropping the 'extension' of the path.
+ first_product.name || remove_extension(first_product.path)
+ end
+
def profdata_coverage_dir
raise StandardError, "The specified build directory (#{self.build_directory}) does not exist" unless File.exists?(self.build_directory)
dir = nil
if self.scheme
- dir = Dir["#{build_directory}/**/CodeCoverage/#{self.scheme}"].first
+ dir = Dir[File.join("#{build_directory}","/**/CodeCoverage/#{self.scheme}")].first
else
- dir = Dir["#{build_directory}/**/#{self.products.first.name}"].first
+ dir = Dir[File.join("#{build_directory}","/**/#{first_product_name}")].first
end
raise StandardError, "No coverage directory found. Are you sure your project is setup for generating coverage files? Try `slather setup your/project.xcodeproj`" unless dir != nil
dir
end
@@ -245,20 +256,21 @@
self.coverage_access_token ||= (ENV["COVERAGE_ACCESS_TOKEN"] || self.class.yml["coverage_access_token"] || "")
end
def coverage_service=(service)
service = service && service.to_sym
- if service == :coveralls
+ case service
+ when :coveralls
extend(Slather::CoverageService::Coveralls)
- elsif service == :hardcover
+ when :hardcover
extend(Slather::CoverageService::Hardcover)
- elsif service == :terminal
+ when :terminal
extend(Slather::CoverageService::SimpleOutput)
- elsif service == :gutter_json
+ when :gutter_json
extend(Slather::CoverageService::GutterJsonOutput)
- elsif service == :cobertura_xml
+ when :cobertura_xml
extend(Slather::CoverageService::CoberturaXmlOutput)
- elsif service == :html
+ when :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