class Pod::Command::XC::Clean

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/cocoapods-extension/command/xcode/clean.rb, line 20
def initialize(argv)
    @cache_files = Hash.new
    @cache_files['Pods'] = File.join(Dir.pwd, 'Pods')
    @cache_files['Podfile.lock'] = File.join(Dir.pwd, 'Podfile.lock')
    @cache_files['DerivedData'] = File.join(File.expand_path('~'), 'Library/Developer/Xcode/DerivedData')
    @wipe_all = argv.flag?('all')
    super
end
options() click to toggle source
Calls superclass method
# File lib/cocoapods-extension/command/xcode/clean.rb, line 14
def self.options
    [
        ['--all', 'Remove all the cached without asking']
    ].concat(super)
end

Public Instance Methods

run() click to toggle source
# File lib/cocoapods-extension/command/xcode/clean.rb, line 29
def run
    if @wipe_all
        remove_indexs ['Pods', 'Podfile.lock', 'DerivedData']
    else
        begin
            choices = ['Pods', 'Podfile.lock', 'DerivedData', 'Pods and Podfile.lock', 'All']
            index = UI.choose_from_array(choices, 'Which item do you want to remove?')
            case index
            when 0
                remove_indexs ['Pods']
            when 1
                remove_indexs ['Podfile.lock']
            when 2
                remove_indexs ['DerivedData']
            when 3
                remove_indexs ['Pods', 'Podfile.lock']
            when 4
                remove_indexs ['Pods', 'Podfile.lock', 'DerivedData']
            end
        rescue => exception
            UI.puts "[!] #{exception}".red
        end
    end

end

Private Instance Methods

remove_indexs(indexs) click to toggle source
# File lib/cocoapods-extension/command/xcode/clean.rb, line 60
def remove_indexs indexs
    indexs.each do |index| 
        value = @cache_files[index]
        unless value.nil?
            UI.section("Removing #{index} => #{value}.") do
                rm! ['-rf', value]
            end
        end
    end
end