Class: Pod::Command::XC::Open

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

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Open

Returns a new instance of Open.



9
10
11
# File 'lib/cocoapods-extension/command/xcode/open.rb', line 9

def initialize(argv)
    super
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cocoapods-extension/command/xcode/open.rb', line 13

def run 
    urls_w = Dir[File.join(Dir.pwd, "*.xcworkspace")] 
    urls_p = Dir[File.join(Dir.pwd, "*.xcodeproj")]
    urls = urls_w + urls_p
    if urls_w.size == 1
        open urls_w[0]
    elsif urls_p.size == 1
        open urls_p[0]
    elsif urls.size > 0
        choices = urls.map { |l| File.basename(l) }
        begin
            index = UI.choose_from_array(choices, 'Which file do you want to open?')
            open urls[index]
        rescue => exception
            UI.puts "[!] #{exception}".red
        end
    else
        open '/Applications/Xcode.app'
    end
end