Class: Pod::Command::XC::Clean

Inherits:
Pod::Command::XC show all
Extended by:
Executable
Defined in:
lib/cocoapods-extension/command/xcode/clean.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Clean

Returns a new instance of Clean.



20
21
22
23
24
25
26
27
# 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

Class Method Details

.optionsObject



14
15
16
17
18
# File 'lib/cocoapods-extension/command/xcode/clean.rb', line 14

def self.options
    [
        ['--all', 'Remove all the cached without asking']
    ].concat(super)
end

Instance Method Details

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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