class Pod::TrySettings

Attributes

pre_install_commands[RW]
project_path[RW]

Public Class Methods

settings_from_folder(path) click to toggle source

Creates a TrySettings instance based on a folder path

# File lib/pod/try_settings.rb, line 7
def self.settings_from_folder(path)
  settings_path = Pathname.new(path) + '.cocoapods.yml'
  return TrySettings.new unless File.exist? settings_path

  settings = YAMLHelper.load_file(settings_path)
  try_settings = TrySettings.new
  return try_settings unless settings['try']

  if settings['try']['install']
    try_settings.pre_install_commands = Array(settings['try']['install']['pre'])
  end

  if settings['try']['project']
    try_settings.project_path = Pathname.new(path) + settings['try']['project']
  end

  try_settings
end

Public Instance Methods

prompt_for_permission() click to toggle source

If we need to run commands from pod-try we should let the users know what is going to be running on their device.

# File lib/pod/try_settings.rb, line 29
def prompt_for_permission
  UI.titled_section 'Running Pre-Install Commands' do
    commands = pre_install_commands.length > 1 ? 'commands' : 'command'
    UI.puts "In order to try this pod, CocoaPods-Try needs to run the following #{commands}:"
    pre_install_commands.each { |command| UI.puts " - #{command}" }
    UI.puts "\nPress return to run these #{commands}, or press `ctrl + c` to stop trying this pod."
  end

  # Give an elegant exit point.
  UI.gets.chomp
end
run_pre_install_commands(prompt) click to toggle source

Runs the pre_install_commands from

@param [Bool] prompt

Should CocoaPods-Try show a prompt with the commands to the user.
# File lib/pod/try_settings.rb, line 46
def run_pre_install_commands(prompt)
  if pre_install_commands
    prompt_for_permission if prompt
    pre_install_commands.each { |command| Executable.execute_command('bash', ['-ec', command], true) }
  end
end