module Pod::Downloader::API

The Downloader::Hooks module allows to adapt the Downloader to the UI of other gems.

Public Instance Methods

check_exit_code!(executable, command, output) click to toggle source

Checks if the just executed command completed successfully.

@raise If the command failed.

@return [void]

# File lib/cocoapods-downloader/api.rb, line 25
def check_exit_code!(executable, command, output)
  if $?.exitstatus != 0
    raise DownloaderError, "Error on `#{executable} #{command}`.\n#{output}"
  end
end
execute_command(executable, command, raise_on_failure = false) click to toggle source

Executes @return [String] the output of the command.

# File lib/cocoapods-downloader/api.rb, line 10
def execute_command(executable, command, raise_on_failure = false)
  require 'shellwords'
  command = command.map(&:to_s).map(&:shellescape).join(' ')
  output = `\n#{executable} #{command} 2>&1`
  check_exit_code!(executable, command, output) if raise_on_failure
  puts output
  output
end
ui_action(message) { || ... } click to toggle source

Indicates that an action will be performed. The action is passed as a block.

@param [String] message

The message associated with the action.

@yield The action, this block is always executed.

@return [void]

# File lib/cocoapods-downloader/api.rb, line 41
def ui_action(message)
  puts message
  yield
end
ui_message(message) click to toggle source

Prints an UI message.

@param [String] message

The message associated with the action.

@return [void]

# File lib/cocoapods-downloader/api.rb, line 68
def ui_message(message)
  puts message
end
ui_sub_action(message) { || ... } click to toggle source

Indicates that a minor action will be performed. The action is passed as a block.

@param [String] message

The message associated with the action.

@yield The action, this block is always executed.

@return [void]

# File lib/cocoapods-downloader/api.rb, line 56
def ui_sub_action(message)
  puts message
  yield
end