Class: Xcov::Runner
- Inherits:
-
Object
- Object
- Xcov::Runner
- Defined in:
- lib/xcov/runner.rb
Instance Method Summary collapse
Instance Method Details
#generate_xcov_report(report_json) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/xcov/runner.rb', line 30 def generate_xcov_report report_json # Create output path output_path = Xcov.config[:output_directory] FileUtils.mkdir_p(output_path) resources_path = File.join(output_path, "resources") FileUtils.mkdir_p(resources_path) # Copy images to output resources folder Dir[File.join(File.dirname(__FILE__), "../../assets/images/*")].each do |path| FileUtils.cp_r(path, resources_path) end # Copy stylesheets to output resources folder Dir[File.join(File.dirname(__FILE__), "../../assets/stylesheets/*")].each do |path| FileUtils.cp_r(path, resources_path) end # Copy javascripts to output resources folder Dir[File.join(File.dirname(__FILE__), "../../assets/javascripts/*")].each do |path| FileUtils.cp_r(path, resources_path) end # Convert report to xCov model objects report = Report.map(report_json) # Create HTML report File.open(File.join(output_path, "index.html"), "wb") do |file| file.puts report.html_value end # Post result SlackPoster.new.run(report) # Print output table_rows = [] report.targets.each do |target| table_rows << [target.name, target.displayable_coverage] end puts Terminal::Table.new({ title: "xCov Coverage Report".green, rows: table_rows }) puts "" # Raise exception in case of failure raise "Unable to create coverage report" if report.nil? end |
#parse_xccoverage ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xcov/runner.rb', line 17 def parse_xccoverage # Find .xccoverage file product_builds_path = Pathname.new(Xcov.project.default_build_settings(key: "SYMROOT")) test_logs_path = product_builds_path.parent.parent + "Logs/Test/" xccoverage_files = Dir["#{test_logs_path}*.xccoverage"].sort_by { |filename| File.mtime(filename) } unless test_logs_path.directory? && !xccoverage_files.empty? ErrorHandler.handle_error("CoverageNotFound") end Xcov::Core::Parser.parse(xccoverage_files.first) end |
#run ⇒ Object
12 13 14 15 |
# File 'lib/xcov/runner.rb', line 12 def run report_json = parse_xccoverage generate_xcov_report(report_json) end |