Class: Pod::Installer::PodfileValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/podfile_validator.rb

Overview

Validate the podfile before installing to catch errors and problems

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(podfile, podfile_dependency_cache = Analyzer::PodfileDependencyCache.from_podfile(podfile)) ⇒ PodfileValidator

Initialize a new instance

Parameters:

  • podfile (Podfile)

    The podfile to validate

  • podfile_dependency_cache (Analyzer::PodfileDependencyCache) (defaults to: Analyzer::PodfileDependencyCache.from_podfile(podfile))

    An (optional) cache of all the dependencies in the podfile



27
28
29
30
31
32
33
# File 'lib/cocoapods/installer/podfile_validator.rb', line 27

def initialize(podfile, podfile_dependency_cache = Analyzer::PodfileDependencyCache.from_podfile(podfile))
  @podfile = podfile
  @podfile_dependency_cache = podfile_dependency_cache
  @errors = []
  @warnings = []
  @validated = false
end

Instance Attribute Details

#errorsArray<String> (readonly)

Returns any errors that have occurred during the validation.

Returns:

  • (Array<String>)

    any errors that have occurred during the validation



13
14
15
# File 'lib/cocoapods/installer/podfile_validator.rb', line 13

def errors
  @errors
end

#podfilePodfile (readonly)

Returns The podfile being validated.

Returns:

  • (Podfile)

    The podfile being validated



9
10
11
# File 'lib/cocoapods/installer/podfile_validator.rb', line 9

def podfile
  @podfile
end

#warningsArray<String> (readonly)

Returns any warnings that have occurred during the validation.

Returns:

  • (Array<String>)

    any warnings that have occurred during the validation



17
18
19
# File 'lib/cocoapods/installer/podfile_validator.rb', line 17

def warnings
  @warnings
end

Instance Method Details

#messageObject

A message describing any errors in the validation



61
62
63
# File 'lib/cocoapods/installer/podfile_validator.rb', line 61

def message
  errors.join("\n")
end

#valid?Boolean

Wether the podfile is valid is not NOTE: Will execute ‘validate` if the podfile has not yet been validated

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/cocoapods/installer/podfile_validator.rb', line 52

def valid?
  validate unless @validated

  @validated && errors.empty?
end

#validateObject

Validate the podfile Errors are added to the errors array



38
39
40
41
42
43
44
45
46
# File 'lib/cocoapods/installer/podfile_validator.rb', line 38

def validate
  validate_installation_options
  validate_pod_directives
  validate_no_abstract_only_pods!
  validate_dependencies_are_present!
  validate_no_duplicate_targets!

  @validated = true
end