Skip to content

Commit

Permalink
Merge pull request #550 from jarrodlombardo-EventBase/jarrodlombardo/…
Browse files Browse the repository at this point in the history
…custom-ymlfile

Add option to use a custom ymlfile
  • Loading branch information
ksuther authored Nov 5, 2023
2 parents 264dd5f + 166394c commit 2aca390
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ tmp
*.o
*.a
mkmf.log
.vendor
.vendor
.ruby-version
# Xcode
#
*.pbxuser
Expand Down
2 changes: 1 addition & 1 deletion lib/cocoapods_plugin.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'slather'
require_relative 'slather'

Pod::HooksManager.register('slather', :post_install) do |installer_context|
sandbox_root = installer_context.sandbox_root
Expand Down
30 changes: 15 additions & 15 deletions lib/slather.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require 'slather/version'
require 'slather/project'
require 'slather/coverage_info'
require 'slather/coverage_file'
require 'slather/coveralls_coverage'
require 'slather/profdata_coverage_file'
require 'slather/coverage_service/cobertura_xml_output'
require 'slather/coverage_service/coveralls'
require 'slather/coverage_service/hardcover'
require 'slather/coverage_service/gutter_json_output'
require 'slather/coverage_service/simple_output'
require 'slather/coverage_service/html_output'
require 'slather/coverage_service/json_output'
require 'slather/coverage_service/llvm_cov_output'
require 'slather/coverage_service/sonarqube_xml_output'
require_relative 'slather/version'
require_relative 'slather/project'
require_relative 'slather/coverage_info'
require_relative 'slather/coverage_file'
require_relative 'slather/coveralls_coverage'
require_relative 'slather/profdata_coverage_file'
require_relative 'slather/coverage_service/cobertura_xml_output'
require_relative 'slather/coverage_service/coveralls'
require_relative 'slather/coverage_service/hardcover'
require_relative 'slather/coverage_service/gutter_json_output'
require_relative 'slather/coverage_service/simple_output'
require_relative 'slather/coverage_service/html_output'
require_relative 'slather/coverage_service/json_output'
require_relative 'slather/coverage_service/llvm_cov_output'
require_relative 'slather/coverage_service/sonarqube_xml_output'
require 'cfpropertylist'

module Slather
Expand Down
6 changes: 6 additions & 0 deletions lib/slather/command/coverage_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ class CoverageCommand < Clamp::Command
option ["--arch"], "ARCH", "Architecture to use from universal binaries"
option ["--source-files"], "SOURCE_FILES", "A Dir.glob compatible pattern used to limit the lookup to specific source files. Ignored in gcov mode.", :multivalued => true
option ["--decimals"], "DECIMALS", "The amount of decimals to use for % coverage reporting"
option ["--ymlfile"], "YMLFILE", "Relative path to a file used in place of '.slather.yml'"

def execute
puts "Slathering..."

setup_ymlfile # MUST be the first setup
setup_service_name
setup_ignore_list
setup_build_directory
Expand All @@ -64,6 +66,10 @@ def execute
puts "Slathered"
end

def setup_ymlfile
Slather::Project.yml_filename = ymlfile if ymlfile
end

def setup_build_directory
project.build_directory = build_directory if build_directory
end
Expand Down
6 changes: 6 additions & 0 deletions lib/slather/command/setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ class SetupCommand < Clamp::Command
parameter "[PROJECT]", "Path to the .xcodeproj", :attribute_name => :xcodeproj_path

option ["--format"], "FORMAT", "Type of coverage to use (gcov, clang, auto)"
option ["--ymlfile"], "YMLFILE", "Relative path to a file used in place of '.slather.yml'"

def execute
setup_ymlfile
xcodeproj_path_to_open = xcodeproj_path || Slather::Project.yml["xcodeproj"]
unless xcodeproj_path_to_open
raise StandardError, "Must provide a .xcodeproj either via the 'slather [SUBCOMMAND] [PROJECT].xcodeproj' command or through .slather.yml"
Expand All @@ -12,4 +14,8 @@ def execute
project.setup_for_coverage(format ? format.to_sym : :auto)
project.save
end

def setup_ymlfile
Slather::Project.yml_filename = ymlfile if ymlfile
end
end
4 changes: 2 additions & 2 deletions lib/slather/coverage_file.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'slather/coverage_info'
require 'slather/coveralls_coverage'
require_relative 'coverage_info'
require_relative 'coveralls_coverage'

module Slather
class CoverageFile
Expand Down
4 changes: 2 additions & 2 deletions lib/slather/profdata_coverage_file.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'slather/coverage_info'
require 'slather/coveralls_coverage'
require_relative 'coverage_info'
require_relative 'coveralls_coverage'
require 'digest/md5'

module Slather
Expand Down
8 changes: 7 additions & 1 deletion lib/slather/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,14 @@ def dedupe(coverage_files)
end
private :dedupe

@@ymlfile = '.slather.yml'

def self.yml_filename=(var)
@@ymlfile = var
end

def self.yml_filename
'.slather.yml'
@@ymlfile
end

def self.yml
Expand Down

0 comments on commit 2aca390

Please sign in to comment.