class Pod::Command::Trunk::Delete

@CocoaPods 1.0.0.beta.1

Constants

WARNING_MESSAGE

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/pod/command/trunk/delete.rb, line 22
def initialize(argv)
  @name = argv.shift_argument
  @version = argv.shift_argument
  super
end

Public Instance Methods

run() click to toggle source
# File lib/pod/command/trunk/delete.rb, line 34
def run
  return unless confirm_deletion?
  json = delete
  print_messages(json['data_url'], json['messages'], nil, nil)
end
validate!() click to toggle source
Calls superclass method
# File lib/pod/command/trunk/delete.rb, line 28
def validate!
  super
  help! 'Please specify a pod name.' unless @name
  help! 'Please specify a version.' unless @version
end

Private Instance Methods

confirm_deletion?() click to toggle source
# File lib/pod/command/trunk/delete.rb, line 46
def confirm_deletion?
  UI.puts(WARNING_MESSAGE.yellow)
  loop do
    UI.print("Are you sure you want to delete this Pod version?\n> ")
    answer = UI.gets.strip.downcase
    UI.puts # ensures a newline is printed after the user input
    affirmatives = %w(y yes true 1)
    negatives = %w(n no false 0)
    return true if affirmatives.include?(answer)
    return false if negatives.include?(answer)
  end
end
delete() click to toggle source
# File lib/pod/command/trunk/delete.rb, line 59
def delete
  response = request_path(:delete, "pods/#{@name}/#{@version}", auth_headers)
  url = response.headers['location'].first
  json(request_url(:get, url, default_headers))
rescue REST::Error => e
  raise Informative, 'There was an error deleting the pod version ' \
                           "from trunk: #{e.message}"
end