Class: Danger::DangerXcov
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerXcov
- Defined in:
- lib/danger_plugin.rb
Overview
Validates the code coverage of the files changed within a Pull Request and generates a brief coverage report.
Instance Method Summary collapse
-
#convert_options(options) ⇒ Object
Processes the parameters passed to the plugin.
-
#output_report(report) ⇒ Object
Outputs a processed report with Danger.
-
#produce_report(*args) ⇒ Object
Produces and processes a report for use in the report method It takes the same arguments as report, and returns the same object as process_report.
-
#report(*args) ⇒ void
Validates the code coverage of the files changed within a Pull Request.
Instance Method Details
#convert_options(options) ⇒ Object
Processes the parameters passed to the plugin
110 111 112 113 114 |
# File 'lib/danger_plugin.rb', line 110 def () = .dup .delete(:verbose) end |
#output_report(report) ⇒ Object
Outputs a processed report with Danger
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/danger_plugin.rb', line 77 def output_report(report) # Create markdown report_markdown = report.markdown_value # Send markdown markdown(report_markdown) # Notify failure if minimum coverage hasn't been reached threshold = Xcov.config[:minimum_coverage_percentage].to_i if !threshold.nil? && (report.coverage * 100) < threshold fail("Code coverage under minimum of #{threshold}%") end end |
#produce_report(*args) ⇒ Object
Produces and processes a report for use in the report method It takes the same arguments as report, and returns the same object as process_report
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 |
# File 'lib/danger_plugin.rb', line 44 def produce_report(*args) # Check xcov availability, install it if needed `gem install xcov` unless xcov_available? unless xcov_available? puts "xcov is not available on this machine" return end require "xcov" require "fastlane_core" # Init Xcov config = FastlaneCore::Configuration.create(Xcov::Options., (args.first)) Xcov.config = config Xcov.ignore_handler = Xcov::IgnoreHandler.new # Init project report_json = nil manager = Xcov::Manager.new(config) if Xcov.config[:html_report] || Xcov.config[:markdown_report] || Xcov.config[:json_report] # Parse .xccoverage and create local report report_json = manager.run else # Parse .xccoverage report_json = manager.parse_xccoverage end # Map and process report process_report(Xcov::Report.map(report_json)) end |
#report(*args) ⇒ void
This method returns an undefined value.
Validates the code coverage of the files changed within a Pull Request. This method accepts the same arguments allowed by the xcov gem.
34 35 36 37 38 39 |
# File 'lib/danger_plugin.rb', line 34 def report(*args) # Run xcov to produce a processed report report = produce_report(*args) # Output the processed report output_report(report) end |