Module: Pod::Downloader::API

Defined in:
lib/cocoapods-downloader/api.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#check_exit_code!(executable, command, output) ⇒ void

This method returns an undefined value.

Checks if the just executed command completed successfully.

Raises:

  • If the command failed.


25
26
27
28
29
# 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) ⇒ String

Executes

Returns:

  • (String)

    the output of the command.


10
11
12
13
14
15
16
17
# 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) { ... } ⇒ void

This method returns an undefined value.

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

Parameters:

  • message (String)

    The message associated with the action.

Yields:

  • The action, this block is always executed.


41
42
43
44
# File 'lib/cocoapods-downloader/api.rb', line 41

def ui_action(message)
  puts message
  yield
end

#ui_message(message) ⇒ void

This method returns an undefined value.

Prints an UI message.

Parameters:

  • message (String)

    The message associated with the action.


68
69
70
# File 'lib/cocoapods-downloader/api.rb', line 68

def ui_message(message)
  puts message
end

#ui_sub_action(message) { ... } ⇒ void

This method returns an undefined value.

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

Parameters:

  • message (String)

    The message associated with the action.

Yields:

  • The action, this block is always executed.


56
57
58
59
# File 'lib/cocoapods-downloader/api.rb', line 56

def ui_sub_action(message)
  puts message
  yield
end