Class: Pod::Installer::PodSourcePreparer

Inherits:
Object
  • Object
show all
Extended by:
Executable
Defined in:
lib/cocoapods/installer/pod_source_preparer.rb

Overview

Controller class responsible of executing the prepare command of a single Pod.

Instance Attribute Summary collapse

Preparation collapse

Instance Method Summary collapse

Methods included from Executable

capture_command, capture_command!, executable, execute_command, popen3, reader, which, which!

Constructor Details

#initialize(spec, path) ⇒ PodSourcePreparer

Initialize a new instance

Parameters:

  • spec (Specification)

    the root specification of the Pod.

  • path (Pathname)

    the folder where the source of the Pod is located.



20
21
22
23
24
# File 'lib/cocoapods/installer/pod_source_preparer.rb', line 20

def initialize(spec, path)
  raise "Given spec isn't a root spec, but must be." unless spec.root?
  @spec = spec
  @path = path
end

Instance Attribute Details

#pathPathname (readonly)

Returns the folder where the source of the Pod is located.

Returns:

  • (Pathname)

    the folder where the source of the Pod is located.



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

def path
  @path
end

#specSpecification (readonly)

Returns the root specification of the Pod.

Returns:



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

def spec
  @spec
end

Instance Method Details

#prepare!void

This method returns an undefined value.

Executes the prepare command if there is one.



36
37
38
# File 'lib/cocoapods/installer/pod_source_preparer.rb', line 36

def prepare!
  run_prepare_command
end

#run_prepare_commandvoid (private)

Note:

Unsets the CDPATH env variable before running the shell script to avoid issues with relative paths (issue #1694).

This method returns an undefined value.

Runs the prepare command bash script of the spec.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cocoapods/installer/pod_source_preparer.rb', line 57

def run_prepare_command
  return unless spec.prepare_command
  UI.section(' > Running prepare command', '', 1) do
    Dir.chdir(path) do
      begin
        ENV.delete('CDPATH')
        ENV['COCOAPODS_VERSION'] = Pod::VERSION
        prepare_command = spec.prepare_command.strip_heredoc.chomp
        full_command = "\nset -e\n" + prepare_command
        bash!('-c', full_command)
      ensure
        ENV.delete('COCOAPODS_VERSION')
      end
    end
  end
end