class Pod::DyInstaller::PodSourcePreparer

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

Attributes

path[R]

@return [Pathname] the folder where the source of the Pod is located.

spec[R]

@return [Specification] the root specification of the Pod.

Public Class Methods

new(spec, path) click to toggle source

Initialize a new instance

@param [Specification] spec the root specification of the Pod. @param [Pathname] path the folder where the source of the Pod is located.

# File lib/pod/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

Public Instance Methods

prepare!() click to toggle source

Executes the prepare command if there is one.

@return [void]

# File lib/pod/installer/pod_source_preparer.rb, line 36
def prepare!
  run_prepare_command
end

Private Instance Methods

run_prepare_command() click to toggle source

Runs the prepare command bash script of the spec.

@note Unsets the `CDPATH` env variable before running the

shell script to avoid issues with relative paths
(issue #1694).

@return [void]

# File lib/pod/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