Class: Pod::Source::HealthReporter
- Inherits:
-
Object
- Object
- Pod::Source::HealthReporter
- Defined in:
- lib/cocoapods-core/source/health_reporter.rb
Overview
Checks a source for errors and warnings.
Defined Under Namespace
Classes: HealthReport
Actions collapse
-
#report ⇒ HealtReport
readonly
The report produced by the analysis.
Instance Attribute Summary collapse
-
#source ⇒ Source
readonly
The source to check.
Configuration collapse
-
#pre_check(&block) ⇒ void
Allows to specify an optional callback which is called before analysing every spec.
Actions collapse
-
#analyze ⇒ HealthReport
Analyzes all the specification files in the source.
Private helpers collapse
-
#check_spec_path(name, version, spec) ⇒ void
private
Ensures that the name and the version of the specification correspond to the ones expected by the repo given its path.
-
#check_stray_specs ⇒ void
private
Checks for any stray specification in the repo.
-
#lint_spec(name, version, spec_path) ⇒ Specification, Nil
private
Checks the validity of the specification with the linter.
Instance Method Summary collapse
-
#initialize(repo) ⇒ HealthReporter
constructor
A new instance of HealthReporter.
Constructor Details
#initialize(repo) ⇒ HealthReporter
Returns a new instance of HealthReporter.
12 13 14 15 16 |
# File 'lib/cocoapods-core/source/health_reporter.rb', line 12 def initialize(repo) @source = Source.new(repo) @errors = {} @linter_results = {} end |
Instance Attribute Details
#report ⇒ HealtReport (readonly)
Returns The report produced by the analysis.
65 66 67 |
# File 'lib/cocoapods-core/source/health_reporter.rb', line 65 def report @report end |
#source ⇒ Source (readonly)
Returns the source to check.
8 9 10 |
# File 'lib/cocoapods-core/source/health_reporter.rb', line 8 def source @source end |
Instance Method Details
#analyze ⇒ HealthReport
Analyzes all the specification files in the source.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cocoapods-core/source/health_reporter.rb', line 46 def analyze @report = HealthReport.new(source) source.pods.each do |name| source.versions(name).each do |version| @pre_check_callback.call(name, version) if @pre_check_callback spec_path = source.specification_path(name, version) spec = lint_spec(name, version, spec_path) check_spec_path(name, version, spec) if spec report.analyzed_paths << spec_path end end check_stray_specs report end |
#check_spec_path(name, version, spec) ⇒ void (private)
This method returns an undefined value.
Ensures that the name and the version of the specification correspond to the ones expected by the repo given its path.
110 111 112 113 114 115 |
# File 'lib/cocoapods-core/source/health_reporter.rb', line 110 def check_spec_path(name, version, spec) unless spec.name == name && spec.version.to_s == version.to_s = "Incorrect path #{spec.defined_in_file}" report.(:error, , name, spec.version) end end |
#check_stray_specs ⇒ void (private)
This method returns an undefined value.
Checks for any stray specification in the repo.
124 125 126 127 128 129 130 |
# File 'lib/cocoapods-core/source/health_reporter.rb', line 124 def check_stray_specs all_paths = Pathname.glob(source.repo + '**/*.podspec{,.json}') stray_specs = all_paths - report.analyzed_paths stray_specs.each do |path| report.(:error, 'Stray spec', path) end end |
#lint_spec(name, version, spec_path) ⇒ Specification, Nil (private)
Checks the validity of the specification with the linter.
86 87 88 89 90 91 92 93 94 |
# File 'lib/cocoapods-core/source/health_reporter.rb', line 86 def lint_spec(name, version, spec_path) linter = Specification::Linter.new(spec_path) linter.lint linter.results.each do |result| next if result.public_only? report.(result.type, result., name, version) end linter.spec end |
#pre_check(&block) ⇒ void
This method returns an undefined value.
Allows to specify an optional callback which is called before analysing every spec. Suitable for UI.
32 33 34 |
# File 'lib/cocoapods-core/source/health_reporter.rb', line 32 def pre_check(&block) @pre_check_callback = block end |