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) ⇒ PodfileValidator

Initialize a new instance

Parameters:

  • podfile (Podfile)

    The podfile to validate



19
20
21
22
23
# File 'lib/cocoapods/installer/podfile_validator.rb', line 19

def initialize(podfile)
  @podfile = podfile
  @errors = []
  @validated = false
end

Instance Attribute Details

#errorsArray<String> (readonly)

Returns any errors that have occured during the validation.

Returns:

  • (Array<String>)

    any errors that have occured 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

Instance Method Details

#messageObject

A message describing any errors in the validation



47
48
49
# File 'lib/cocoapods/installer/podfile_validator.rb', line 47

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)


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

def valid?
  validate unless @validated

  @validated && errors.size == 0
end

#validateObject

Validate the podfile Errors are added to the errors array



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

def validate
  validate_pod_directives

  @validated = true
end