Class: Pod::Specification::Linter
- Inherits:
-
Object
- Object
- Pod::Specification::Linter
- Defined in:
- lib/cocoapods-core/specification/linter.rb,
lib/cocoapods-core/specification/linter/result.rb,
lib/cocoapods-core/specification/linter/analyzer.rb
Overview
The Linter check specifications for errors and warnings.
It is designed not only to guarantee the formal functionality of a specification, but also to support the maintenance of sources.
Defined Under Namespace
Instance Attribute Summary collapse
-
#file ⇒ Pathname
readonly
The path of the ‘podspec` file where #spec is defined.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#spec ⇒ Specification
readonly
The specification to lint.
Instance Method Summary collapse
-
#errors ⇒ Array<Result>
All the errors generated by the Linter.
-
#initialize(spec_or_path) ⇒ Linter
constructor
A new instance of Linter.
-
#lint ⇒ Boolean
Lints the specification adding a Result for any failed check to the #results object.
-
#warnings ⇒ Array<Result>
All the warnings generated by the Linter.
Constructor Details
#initialize(spec_or_path) ⇒ Linter
Returns a new instance of Linter.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cocoapods-core/specification/linter.rb', line 26 def initialize(spec_or_path) if spec_or_path.is_a?(Specification) @spec = spec_or_path @file = @spec.defined_in_file else @file = Pathname.new(spec_or_path) begin @spec = Specification.from_file(@file) rescue => e @spec = nil @raise_message = e. end end end |
Instance Attribute Details
#file ⇒ Pathname (readonly)
Returns the path of the ‘podspec` file where #spec is defined.
19 20 21 |
# File 'lib/cocoapods-core/specification/linter.rb', line 19 def file @file end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
21 22 23 |
# File 'lib/cocoapods-core/specification/linter.rb', line 21 def results @results end |
#spec ⇒ Specification (readonly)
Returns the specification to lint.
14 15 16 |
# File 'lib/cocoapods-core/specification/linter.rb', line 14 def spec @spec end |
Instance Method Details
#errors ⇒ Array<Result>
Returns all the errors generated by the Linter.
69 70 71 |
# File 'lib/cocoapods-core/specification/linter.rb', line 69 def errors @errors ||= results.select { |r| r.type == :error } end |
#lint ⇒ Boolean
Lints the specification adding a Result for any failed check to the #results object.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cocoapods-core/specification/linter.rb', line 46 def lint @results = Results.new if spec validate_root_name check_required_attributes check_requires_arc_attribute run_root_validation_hooks perform_all_specs_analysis else results.add_error('spec', "The specification defined in `#{file}` "\ "could not be loaded.\n\n#{@raise_message}") end results.empty? end |
#warnings ⇒ Array<Result>
Returns all the warnings generated by the Linter.
75 76 77 |
# File 'lib/cocoapods-core/specification/linter.rb', line 75 def warnings @warnings ||= results.select { |r| r.type == :warning } end |