class Danger::DangerPodliblint
A Danger
plugin for Pod lib lint.
@example Ensure pod lib lint executes correctly
If a log file is specified `lint` will parse it, otherwise it will execute `pod lib lint` and parse the output.
# Optionally specify a log file: podliblint.log_file = "/tmp/podliblint.log" # Lint podliblint.lint
@example Ensure pod lib lint executes correctly as part of Fastlane
If `pod lib lint` is executed as part of [Fastlane](fastlane.tools) is possible to parse the `JUnit` report instead:
# Specify a Fastlane report file: podliblint.log_file = "/fastlane/report.xml" podliblint.is_fastlane_report = true # Lint podliblint.lint
@example Ensure pod lib lint executes correctly with custom options
Additional `pod lib lint` options can be specified through the `options` variable:
# Specify custom options podliblint.options = "--allow-warnings --private" # Lint podliblint.lint
@see valeriomazzeo/danger-podliblint @tags pod, lib, lint, cocoapods
Attributes
Allows you to specify if the pod lib lint log has been generated from fastlane. @return [Bool]
Allows you to specify a pod lib lint log file location to parse. @return [String]
Allows you to specify the pod lib lint options. see pod lib lint โhelp for more information. @return [String]
Public Class Methods
# File lib/podliblint/plugin.rb, line 98 def self.instance_name to_s.gsub("Danger", "").danger_underscore.split("/").last end
Public Instance Methods
Parses and exposes eventual warnings, errors. @return [failures]
# File lib/podliblint/plugin.rb, line 61 def lint data = nil if @log_file != nil if @is_fastlane_report require 'nokogiri' @doc = Nokogiri::XML(File.open(@log_file)) data = @doc.at_xpath('//testcase[contains(@name, "pod_lib_lint")]/failure/@message').to_s else data = File.open(@log_file, 'r').read end else podliblint_command = "pod lib lint" podliblint_command += " #{@options}" if @options require 'cocoapods' data = `#{podliblint_command}` end # Looking for something like: # [!] MyProject did not pass validation, due to 1 error and 1 warning. lint_summary = data[/(?<=\[!\]\s).*(did not pass validation|Unable to find a podspec|specification does not validate).*/i] if lint_summary fail("Pod lib lint: #{lint_summary} ๐จ") failures = data.scan(/(?<=ERROR\s\|\s).*/i) failures.each do |failure| fail("`" << ((failure.to_s.strip! || failure).to_s.gsub!(/`/,"") || failure).to_s << "`") end else message("Pod lib lint passed validation ๐") end return failures end