Class: Pod::Installer::PodSourcePreparer
- Inherits:
-
Object
- Object
- Pod::Installer::PodSourcePreparer
- 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
-
#path ⇒ Pathname
readonly
The folder where the source of the Pod is located.
-
#spec ⇒ Specification
readonly
The root specification of the Pod.
Preparation collapse
-
#prepare! ⇒ void
Executes the prepare command if there is one.
-
#run_prepare_command ⇒ void
private
Runs the prepare command bash script of the spec.
Instance Method Summary collapse
-
#initialize(spec, path) ⇒ PodSourcePreparer
constructor
Initialize a new instance.
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
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
#path ⇒ Pathname (readonly)
Returns 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 |
#spec ⇒ Specification (readonly)
Returns the root specification of the Pod.
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_command ⇒ void (private)
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 |